Posted about 1 month ago. Visible to the public.

Migrate gem tests from Travis CI to Github Actions with gemika

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.

  1. Go to a new "ci" branch:

    git checkout -b ci
  2. Update gemika to version >= 0.5.0 in all your Gemfiles.

  3. 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
  4. 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

  5. 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: port: 3306 postgresql: database: test host: localhost username: postgres password: postgres port: 5432
  6. Remove the .travis.yml file, and the spec/support/database.travis.yml.

  7. Push the branch, and make a PR against master. In the PR you can now see the CI run. Check if it passes.

  8. 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.
  9. When tests pass, merge to master and delete the CI branch.

  10. Replace the Travis CI badge in the README with one like this:

    # MyGem [![Tests](](
  11. Uninstall the Travis webhook in the Github repo (go to Settings => Webhooks)

Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for old versions of Ruby on Rails (3.2 and 2.3).

Owner of this card:

Tobias Kraze
Last edit:
27 days ago
by Tobias Kraze
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Tobias Kraze to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more