We are not going to talk about product development flow (no product managers were harmed during the making of this post!). Instead, we’re framing the process starting from the moment you as a developer have a well defined feature (note that what constitutes a “well defined feature” is the topic of another lengthy post), continuing through to the point where the feature is deployed in production. Remember: this is a very opinionated workflow! This may very well not be the best for your specific situation, and that’s okay.
Serverless changes a lot — but in this context, it can be distilled down to two distinct points.
When creating a serverless development workflow three principles should guide what you build:
Feature life cycle
Type of environments we have
We chose Trello, (although as a side note I question whether it is a solution that can scale well). It is important to mention that we use Kanban as our product process. The main benefit that I see is the ability to pick a feature, develop it and push it to production without the need to wait for a “formal” sprint ending.
During this phase it is the developer’s responsibility to choose KPIs. There are two types of KPIs that should be taken into consideration:
Of course it depends on whether you use TDD or not, so writing tests might be an inner step of the implementation, the point here that you can not move forward in your flow without finishing unit tests, remember, test locally whenever you can, it’s faster. A word of caution about mocks: I prefer to avoid mocking services with with “emulator” mocks, e.g. mocks that actually do something behind the scenes like DynamoLocal from AWS due to two main reasons:
Serverless testing from the trenches_A quick overview on Serverless testing paradigms_hackernoon.com
No matter if we are talking about dynamic or static languages, linting is a mandatory step. Linting should include at bare minimum:
What do I mean by automatic? Simply put, everything is backed into a git pre-commit hook. We are using the pre-commit framework, which gives us the ability to run the linting process either manually or in CI environments. This is our .pre-commit-config.yaml
file and a bash script the developer can use to run the linter flow.
Running integration tests are mandatory in serverless environments. For those too lazy to click, this is because many interfaces are not under your control and you need to test continuously to ensure that nothing is broken. Running is mandatory, but extending is not. My rule of thumb for whether a change in code requires an addition of an integration test is whether it is a new flow, e.g. no integration test for a bug and whether it is a critical path, e.g. if it breaks does the customer leaves us.
Committing your changes without testing them on an actual native cloud environment means that the developer does not really know if his or her code actually work.
Each developer, as part of their first days in the company, prepares its own cloud environment, you can read more about the process in the following post
Serverless multi-cloud from the trenches_From the trenches series_hackernoon.com
A script enables the developer to push changes to its cloud environment and run either manual or automated testing on it.
The developers have now reached a point where they trust their code to do what it’s intended to do and that it does not break anything. It’s time to move the changes up the ladder!
We use the GitHub flow in conjunction with TravisCI . When a developer opens a PR, two things happen in parallel:
If all tests and prerequisites passed we are ready to push changes into production, only the relevant functions will get updated, not the entire application.
One of the guiding lines is creating scripts that are usable both by developers, locally, and by the CI system, for local use sensible defaults that do not require any knowledge on how to run the scripts. For example the script above is using Zappa to update an AWS environment, when using it to update the developer’s cloud environment all they have to run is ./deploy.sh
, The CI environment will use ./deploy.sh update zappa_settings.json production
.
Defining a development workflow is an art, not a science. Each development team has its own quirks and preferred way of working. That said, I do believe that core values of using serverless tools and testing in the cloud is a sensible default that should be shared among all serverless developers.
As I wrote at the beginning of the post, this is a very opinionated workflow that works quite nicely for us. Please share your thoughts or alternate workflows in the comments!