Modern software development typically includes some form of continuous integration and delivery. As such, engineering teams have to detect regressions quickly, as new code continuously gets merged into the build. An essential part of regression detection is automated tests.
What are automated tests?
As the name implies, automated tests are tests that run automatically without manual supervision.
What are Github Actions?
Github Actions enable engineering teams to automate specific parts of the software developement workflow within Github. This includes building, testing, or deploying code. For projects stored on Github, creating a workflow via Github Actions is a quick and easy way to do automated testing.
Github Actions can be added to any project by creating YAML files in
.github/workflows/, at the root of the project repository. Workflows have a simple, hierarchical structure made up of events, jobs, and steps. For a more in-depth overview, see the official tutorial.
A Basic Workflow for Automated Tests in Rails 6
This is a “starter” workflow for automatically running tests for a Rails 6 project on Github. It does the following:
- Triggers the workflow when code is pushed or a pull request is created
- Connects a PostgreSQL service container
- Pulls in the relevant branch using the
- Installs Ruby
- Installs project dependencies in
- Preps the database and runs the tests
Most of the workflow configuration file is self-explanatory, but the official documentation does a great job of breaking down the fundamental parts. It’s worth a quick read!