Skip to content

Key the dummy app on every input that builds it - #18

Merged
Fivell merged 1 commit into
masterfrom
fix/dummy-app-cache-key
Oct 1, 2026
Merged

Fivell merged 1 commit into
masterfrom
fix/dummy-app-cache-key

Conversation

@Fivell

@Fivell Fivell commented Oct 1, 2026

Copy link
Copy Markdown
Member

Three defects in how the dummy app is built and reused. All three hide failures rather than cause them, which is why none showed up as a red leg.

The cache key ignored the Active Admin version

The app was generated into spec/rails/rails-<rails version> and reused whenever that directory existed. But active_admin:install and formtastic:install run inside that app, so the Active Admin version is an input to what gets generated.

So the README's own documented invocation was a lie:

RAILS=7.1.0 AA=3.2.0 bundle install
RAILS=7.1.0 AA=3.2.0 bundle exec rspec spec   # reuses the 3.5 app

The leg reported on an app it never built. CI never noticed because runners start empty, so every cell generated its own.

Now keyed on both: rails-7.1.6-aa3.2.0. Verified by switching AA between runs and watching it regenerate.

A half-built app was cached forever

system 'rake setup' unless File.exist?(ENV['RAILS_ROOT'])

Two problems in one line. rails new creates the target directory before the template runs, so any template failure leaves the directory in place — and every later run then skips regeneration and dies on config/environment.rb with a LoadError that points nowhere near the actual cause. And system's return value was discarded, so a failed build proceeded as if it had worked.

This is not hypothetical: a stale half-built app was sitting in this working tree when the harness was first written, and it took a while to work out why.

Now it checks for config/environment.rb — the file the suite actually loads — clears the directory first, and aborts if the build fails. tasks/test.rake likewise aborts rather than ignoring rails new's exit status, and prints the versions it is building for.

spec_helper overwrote the variable the Gemfile reads

ENV['RAILS'] = Rails.version

CI sets RAILS=7.1.0; the Gemfile asks for ~> 7.1.0 and resolves 7.1.6. This line then rewrote ENV['RAILS'] to 7.1.6, and the rake setup child inherited it — so the child's Gemfile said ~> 7.1.6 while the lockfile recorded ~> 7.1.0. Bundler sees a changed dependency and re-resolves, rewriting the lockfile as a side effect of running tests. Under BUNDLE_FROZEN it would abort outright.

The round-trip bought nothing — the only consumer was the path on the next line. Gone; the path now comes from TestAppPaths, shared by the spec helper and the rake task.

The naming approach is lifted from active_admin_import, which already keys its dummy apps this way.

19 examples, 0 failures, before and after.

Three ways the harness hid failures instead of reporting them.

The generated app was keyed on the Rails version alone, but
active_admin:install runs inside it, so Active Admin is an input too.
`AA=3.2.0 bundle exec rspec` silently reused the app built for 3.5 and
reported on a build it never produced -- including the invocation the
README documents. CI never saw it because runners start empty.

The reuse check was `unless File.exist?(RAILS_ROOT)`, but rails new creates
that directory before the template runs, so a template that failed halfway
left it behind and every later run skipped regeneration and died on
config/environment.rb instead of showing the real error. system's exit
status was discarded as well, in both the spec helper and the rake task.
Check for config/environment.rb, clear the directory first, and abort on
failure.

spec_helper also did `ENV['RAILS'] = Rails.version`, overwriting the
variable the Gemfile reads. CI sets 7.1.0, the Gemfile resolves 7.1.6, and
the rake setup child then evaluated `~> 7.1.6` against a lockfile recording
`~> 7.1.0` -- Bundler re-resolves and rewrites the lock as a side effect of
running tests. The only consumer was the path on the next line, which now
comes from TestAppPaths.

Naming follows active_admin_import, which already keys its apps this way.
@Fivell
Fivell merged commit 362919a into master Oct 1, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant