Clean up CI matrix#574
Merged
Merged
Conversation
Previously the matrix prepended ACTIVE_RECORD_VERSION (or ACTIVE_RECORD_BRANCH) onto a separate `bundle update` step because setup-ruby's bundler-cache install ran before those env vars were in scope. The cached install resolved the gemspec's default ActiveRecord, so a follow-up `bundle update` was needed to swap in the matrix's chosen version. Write the matrix's KEY=value to $GITHUB_ENV in a step that runs before setup-ruby instead. The cached install now resolves the right gems on the first try, and cache-version partitions the bundler cache per matrix entry so different ActiveRecord versions don't collide.
GitHub renders matrix job names from raw axis values by default, so runs showed up as `test (3.3, ACTIVE_RECORD_VERSION=~> 7.2.0, false)` — readable only after squinting. Group the ActiveRecord axis into an object with a short `label` and a `env` payload, then set the job `name:` to `Ruby <ruby-version> / <label>`. Runs now show up as e.g. `Ruby 3.3 / AR 7.2` or `Ruby 4.0 / AR main`.
PGPASS is not a libpq variable (the correct name is PGPASSWORD) and nothing in the repo reads it. The actual password is supplied by PGPASSWORD on the createdb step and by a hardcoded "postgres" in spec/support/database.rb when CI=true. Removing the line so the job env block accurately reflects what's in use.
Three defensive additions to .github/workflows/ci.yml: - `permissions: contents: read` at the workflow level. Nothing in the workflow needs write access to the repo, and least-privilege defaults shrink the blast radius if any action ever turns out to be hostile. - A `concurrency` group keyed on the workflow and ref, cancelling in-progress runs only when triggered by a pull request. Stacked PR pushes no longer waste CI minutes on superseded matrices; pushes to master and the Saturday cron still run to completion. - `timeout-minutes: 20` on the test job. The suite finishes in well under that locally; the timeout guards against a hung runner (most likely on the ruby-head row) eating the GH Actions budget for six hours.
e89769f to
39f9a66
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Tidies up
.github/workflows/ci.ymlacross four small commits.bundle updatestep from the matrix. Previously the matrix prependedACTIVE_RECORD_VERSION=...(orACTIVE_RECORD_BRANCH=...) onto a follow-upbundle updatestep becausesetup-ruby's bundler-cache install ran before those env vars were in scope — the cached install resolved the gemspec's default Active Record, so a second resolution was needed to swap in the matrix's chosen version. The matrix value is now written to$GITHUB_ENVin a step that runs beforesetup-ruby, the cached install picks up the right gems on the first try, and the extra step disappears. The newcache-versioninput onsetup-rubypartitions the bundler cache per matrix entry so different Active Record versions don't collide on the same cache key.labeland theenvpayload, and the job name template renders asRuby <ruby-version> / Active Record <label>— e.g.Ruby 3.3 / Active Record 7.2orRuby 4.0 / Active Record main— instead of the defaulttest (3.3, ACTIVE_RECORD_VERSION="~> 7.2.0", false). Theruby-headrow is also sorted to the bottom of the include block so the unstable entries are visually grouped.PGPASSenv.PGPASSis not a libpq variable (the right name isPGPASSWORD) and nothing in the repo reads it. The actual password comes fromPGPASSWORDon thecreatedbstep and from a hardcoded"postgres"inspec/support/database.rbwhenCI=true.permissions: contents: readat the workflow level so the defaultGITHUB_TOKENis least-privilege; aconcurrencygroup keyed on workflow + ref that cancels superseded PR runs (master pushes and the Saturday cron run to completion); andtimeout-minutes: 20on the test job to guard against a hung runner — most likely on theruby-headrow — eating six hours of the GH Actions budget.Test plan
Ruby <version> / Active Record <label>Generated with Claude Code