Skip to content

Commit 7eadf73

Browse files
committed
Install gems in devenv CI smoke test, cache them
The devenv smoke test ran make test-<gem> without installing gems first, so rspec was missing on a clean runner. Add make install-<gem> steps and cache .devenv/state/.bundle keyed on the Gemfile.lock/devenv.lock hashes so native gems aren't recompiled every run. Document the one-time install for contributors too.
1 parent 6e91cf8 commit 7eadf73

3 files changed

Lines changed: 27 additions & 3 deletions

File tree

.github/workflows/devenv_setup_test.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,19 @@ jobs:
3636
name: railseventstore
3737
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
3838
- run: nix profile install nixpkgs#devenv
39+
- uses: actions/cache@v4
40+
with:
41+
path: ".devenv/state/.bundle"
42+
key: "${{ runner.os }}-devenv-gems-${{ hashFiles('**/Gemfile.lock', 'devenv.lock') }}"
43+
restore-keys: "${{ runner.os }}-devenv-gems-"
3944
- run: devenv up -d
4045
- run: for i in $(seq 1 60); do nc -z localhost 10018 && exit 0; sleep 2; done; exit 1
46+
- run: devenv shell -- make install-ruby_event_store-active_record
4147
- run: devenv shell -- make test-ruby_event_store-active_record
4248
env:
4349
DATABASE_URL: postgres://postgres:secret@localhost:10018/rails_event_store
4450
DATA_TYPE: jsonb
51+
- run: devenv shell -- make install-ruby_event_store
4552
- run: devenv shell -- make test-ruby_event_store
4653
- if: always()
4754
run: devenv processes down || true

railseventstore.org/docs/contributing/devenv_setup.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,14 @@ copied from any CI matrix cell works verbatim:
5454
5555
## Running the suites
5656

57-
Inside the devenv shell, use the regular `make` targets:
57+
Inside the devenv shell, install the gem's dependencies once, then use the regular
58+
`make` targets:
5859

5960
```
60-
make test-ruby_event_store # no database needed
61-
make test-ruby_event_store-active_record # against Postgres 18 by default
61+
make install-ruby_event_store # bundle install for that gem
62+
make test-ruby_event_store # no database needed
63+
make install-ruby_event_store-active_record # bundle install for that gem
64+
make test-ruby_event_store-active_record # against Postgres 18 by default
6265
```
6366

6467
To reproduce a specific CI matrix cell, use `res-cell`, which maps a short database

support/ci/generate

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,17 @@ class CI
335335
{ "if" => "always()", "run" => "devenv processes down || true" }
336336
end
337337

338+
def cache_gems
339+
{
340+
"uses" => "actions/cache@v4",
341+
"with" => {
342+
"path" => ".devenv/state/.bundle",
343+
"key" => "${{ runner.os }}-devenv-gems-${{ hashFiles('**/Gemfile.lock', 'devenv.lock') }}",
344+
"restore-keys" => "${{ runner.os }}-devenv-gems-",
345+
},
346+
}
347+
end
348+
338349
def make_nix_shell(target, imports: ["redis.nix"])
339350
{ "run" => <<~SHELL, "working-directory" => "${{ env.WORKING_DIRECTORY }}" }
340351
nix-shell --run "make #{target}" -E"
@@ -725,15 +736,18 @@ class CI
725736
setup_nix_flakes,
726737
setup_cachix,
727738
install_devenv,
739+
cache_gems,
728740
devenv_up,
729741
wait_for_port(10018),
742+
devenv_run("make install-ruby_event_store-active_record"),
730743
devenv_run(
731744
"make test-ruby_event_store-active_record",
732745
env: {
733746
"DATABASE_URL" => "postgres://postgres:secret@localhost:10018/rails_event_store",
734747
"DATA_TYPE" => "jsonb",
735748
},
736749
),
750+
devenv_run("make install-ruby_event_store"),
737751
devenv_run("make test-ruby_event_store"),
738752
devenv_down,
739753
],

0 commit comments

Comments
 (0)