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 the spec/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
.ruby-version
file to a version that is actually in the matrix.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)