We currently test most of our gems on Travis CI, but want to migrate those tests to Github Actions. This is a step-by-step guide on how to do this.
Note that this guide requires the gem to use gemika Show archive.org snapshot .
-
Go to a new "ci" branch:
git checkout -b ci
-
Update gemika to version >= 0.5.0 in all your Gemfiles.
-
Have gemika generate a Github Actions workflow definition by running
mkdir -p .github/workflows; bundle exec rake gemika:generate_github_actions_workflow > .github/workflows/test.yml
-
Gemika tried to detect which of your Gemfiles needed which database, but is not currently very smart about it. If your
test.yml
does not set up the database correctly, please adjust it by comparing it with https://github.com/makandra/active_type/blob/master/.github/workflows/test.yml Show archive.org snapshot . -
If necessary (i.e. the tests use databases), add a
spec/support/database.github.yml
file with this content:mysql: database: test username: root password: password host: 127.0.0.1 port: 3306 postgresql: database: test host: localhost username: postgres password: postgres port: 5432
-
Remove the
.travis.yml
file, and thespec/support/database.travis.yml
. -
Push the branch, and make a PR against master. In the PR you can now see the CI run. Check if it passes.
-
Most likely it will not. Fix the issues. Common issues are
- You're using Ruby versions that are not supported on Github Actions.
- The error messages will show you which versions are supported.
- There is no support for any Ruby version < 2.2. Just drop those, we do not have to support them any longer.
- Remember to remove unused Gemfiles.
- Remember to update the
.ruby-version
file to a version that is actually in the matrix.
- You might run into issues with the mysql2 gem, including issues bundling, and even segfaults.
- Use this card to fix these issues.
- You're using Ruby versions that are not supported on Github Actions.
-
When tests pass, merge to master and delete the CI branch.
-
Replace the Travis CI badge in the
README
with one like this:# MyGem [![Tests](https://github.com/makandra/my-gem/workflows/Tests/badge.svg)](https://github.com/makandra/my-gem/actions)
-
Uninstall the Travis webhook in the Github repo (go to Settings => Webhooks)