Skip to content

ci: run every Ruby test suite (rails, record, runtime, tools), fail on silent skips, declare the test toolchain, clear 61 lockfile advisories - #151

Open
AdamMusa wants to merge 5 commits into
mainfrom
audit/ruby-tests-ci
Open

AdamMusa wants to merge 5 commits into
mainfrom
audit/ruby-tests-ci

Conversation

@AdamMusa

@AdamMusa AdamMusa commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

Fixes #148

CI only ran packages/ruflet, ruflet_core and ruflet_server, plus tools/mruby_patches_test.rb. This PR runs every Ruby suite in CI and fails the run when a cross-check silently skips. It also declares the test toolchain the packages need and moves the two committed dev lockfiles off versions with published advisories (61 to 0).

Only CI, dev tooling, dev lockfiles, tests and contributor docs change. No gemspec, no file under lib/ and nothing else that ships is touched. Apps on published gems are unaffected.

What changed

New: tools/run_ruby_tests.rb

  • Runs a suite the way CI does:
    • the core packages run one process per test file, as before;
    • ruflet_rails and ruflet_record run through bundle exec rake test;
    • ruby_runtime/test and tools/*_test.rb run per file.
  • Packages that have a Gemfile run under it (-rbundler/setup, or bundle exec for rake).
  • Every skipped test is listed by name (minitest's --show-skips).
  • With --strict, any skip not in ALLOWED_SKIPS fails the run. That allow-list starts empty.
  • Any test process that exits non-zero, reports failures or errors, or prints no minitest summary also fails the run.

New: .github/workflows/ruby-tests.yml

  • Runs no Flutter.
  • Triggers on packages/**, tools/**, ruby_runtime/**, .ruby-version and the workflow file itself.
  • Jobs:
    • core (macOS) runs ruflet_core, ruflet_server and ruflet strictly. It checks out:
      • ruflet-template main as RUFLET_TEMPLATE_ROOT. This is not pinned, because published gems fetch template main at build time;
      • ruflet-engine as RUFLET_ENGINE_ROOT, pinned to f96aeee6 (the codex/engine-initialization head that ruflet_core's ENGINE_SERVICE_TYPES matches). Without the pin, an engine merge that adds a service would fail dsl_presented_controls_test on every later ruflet PR, while main stayed green. To move the pin, run tools/sync_engine_service_types.rb against the new engine commit and update ref: in the same PR. The workflow comment says this.
    • packages-and-tools (macOS) runs ruflet_rails, ruflet_record, ruby_runtime and tools strictly.
      • bundle install runs frozen, because these two packages commit their locks.
      • mruby is fetched at the commit the ruby_runtime/third_party/mruby gitlink pins, as RUFLET_MRUBY. The gitlink has no .gitmodules entry, so checkout cannot fetch it as a submodule.
    • audit (ubuntu-24.04) runs bundle-audit against all five packages. For the core packages, which commit no lock, it resolves a lock first.
  • Concurrency: only pull-request runs share a group, so a newer push cancels a PR's unfinished run. Every push and manual run gets a group of its own. With one group per branch, a merge to main would cancel the pending run of the merge before it.
  • build-ruflet-client.yml is unchanged. It still runs the core suites with plain ruby on the default gems (minitest 5) before building releases, so that path stays covered too.

Development-only Gemfiles

  • New Gemfiles for ruflet_core, ruflet_server and ruflet. Each declares:
    • gemspec;
    • path gems for the sibling packages;
    • minitest >= 5.25, < 7 plus minitest-mock, so the suites load on minitest 5 and 6;
    • the cross-check gems: nokogiri, msgpack, bootsnap and railties >= 8.1.
  • Their Gemfile.lock is gitignored and resolved fresh, the way a user's app resolves these gems. The gemspecs' files lists don't include the Gemfiles.
  • ruflet_rails gains sqlite3 in its test group. Two rails_executor_test scenarios used to skip without it.
  • ruflet_record pins minitest to the same range as the others.

Lockfiles

  • ruflet_rails (bundle update --conservative --minor --strict):
    • rails and its components 8.1.3.1 → 8.1.4.1. This fixes the Critical GHSA-f3w6-w445-fwh9 in activestorage.
    • rack 3.2.6 → 3.2.9
    • nokogiri 1.19.4 → 1.19.7
    • loofah 2.25.2 → 2.25.3
    • crass 1.0.7 → 1.0.8
    • json 2.21.1 → 2.21.2
    • rails-html-sanitizer 1.7.1 → 1.7.2
    • sqlite3 2.10.2 is added.
  • ruflet_record:
    • sqlite3 2.9.5 → 2.10.2
    • the same platform list as ruflet_rails; it used to list arm64-darwin only.
  • bundle-audit check --no-update (advisory database of 2026-11-20) finds 0 advisories in all five packages. On main it finds 59 (ruflet_rails) + 2 (ruflet_record).

New tests

  • packages/ruflet_rails/test/template_source_test.rb (plus test/support/template_source_app.rb):
    • Boots a minimal Rails app in its own process, with the Railtie loaded, and fetches screens through TemplateSource#fetch, the fetcher erb_to_native uses in production.
    • Covers:
      • app helpers, Railtie DSL helpers and partials;
      • re-running the screen's own action;
      • redirect_to and redirect loops;
      • render :other;
      • path and form params;
      • the missing screen;
      • a template edited mid-session.
  • tools/run_ruby_tests_test.rb checks how the runner treats:
    • a pass, a failure, an erroring test, a load error and a missing summary;
    • a file that exits non-zero after a clean summary;
    • failure and error counts in a file that exits 0;
    • a named skip, --strict, and an allowed skip.
  • tools/ruby_tests_workflow_test.rb pins the CI contract:
    • every Ruby test file belongs to a suite. The exception is tools/embedded_vm_harness/tests, which run inside an mruby VM build;
    • ruby-tests.yml runs every suite exactly once with --strict;
    • its pull_request and push paths cover every file in each suite's folder (lib/, Gemfile, Gemfile.lock, tests) and everything under tools/. ! patterns are applied the way GitHub applies them;
    • every package with a Gemfile is bundle installed;
    • the ruflet-engine checkout is pinned to a commit.

Other

  • .github/dependabot.yml sets up weekly grouped updates:

    • bundler for ruflet_rails and ruflet_record;
    • pub for ruby_runtime;
    • github-actions.

    bundler and pub use versioning-strategy: lockfile-only, so Dependabot never edits a Gemfile, gemspec or pubspec.yaml.

  • release.md's "Run the package tests" command printed Could not locate Gemfile. It now runs bundle install and then tools/run_ruby_tests.rb --strict <suite>, and lists the environment variables CI sets.

  • CONTRIBUTING_RUFLET.md had the same broken all-in-one-process command, and two example test files that no longer exist. Both are fixed.

How verified

All runs were on head 9c0a6dad (main 57d07019 merged in), with Ruby 4.0.5 / Bundler 4.0.11 unless noted, against:

  • ruflet-template main at 8b085697;
  • ruflet-engine at the pinned f96aeee6;
  • mruby at the pinned 449627d0.

Gems were installed into a scratch BUNDLE_PATH.

  • Every suite, strict. ruby tools/run_ruby_tests.rb --strict gives 268 processes, 4054 runs, 0 failed, 0 skips. CI's Ruby tests run on the same head (Ruby 3.4.5) agrees: core 260 processes and 3598 runs, packages-and-tools 8 processes and 456 runs, 0 skips, and a clean audit. On main, CI reported 5 skips (railties, bootsnap, RUFLET_ENGINE_ROOT, nokogiri, pinned mruby), and ruflet_rails skipped 2 more locally (sqlite3).
  • Planted bugs from CI never runs the ruflet_rails, ruflet_record, ruby_runtime or tools suites, ignores tools/** changes, skips five cross-checks silently and needs minitest 5 preinstalled; dev lockfiles carry 61 advisories #148 are now caught.
    • ruflet_record sql.rb: an open range >= ? changed to > ?.
    • ruflet_rails execution.rb: return yield if executor.nil? changed to return yield.
    • With both in place, the new CI step fails. ruflet_rails rake test has 4 failures, the four rails_executor_test scenarios. ruflet_record rake test has 5, all in open_range_test.
    • The old CI steps stay green with the same two bugs. I replayed the test steps of build-ruflet-client.yml with the same commands on Ruby 3.4.5: plain ruby -Ilib -Itest, a gem environment holding only minitest 5.25.5 and msgpack, and BUNDLE_PATH pointing at an empty directory. All 260 files exit 0 (with the 5 skips main's CI shows), tools/mruby_patches_test.rb exits 0, and nothing activated the new Gemfiles: the directory stayed empty.
  • Planted TemplateSource bugs are now caught. With redirects ignored and the screen's own action not re-run, template_source_test.rb has 3 failures: the re-run, the redirect and the redirect-loop tests. Every other ruflet_rails test file stays green with the same bugs (315 runs, 0 failures).
  • Planted workflow gaps are now caught. ruby_tests_workflow_test.rb fails in each of these cases:
    • with main's build-ruflet-client.yml substituted for the new workflow (4 failures);
    • with tools/** dropped from the pull_request paths;
    • with packages/** narrowed to packages/*/test/**, so a lib/ change would no longer start it;
    • with '!packages/*/lib/**' added after packages/**;
    • with ruflet_rails dropped from the run, or from bundle install;
    • with the engine checkout's ref: removed, or set to a branch name.
  • Planted runner bugs are now caught. run_ruby_tests_test.rb fails for each of these mutations of Run#failed?:
    • ignoring both the exit status and the error count (3 failures);
    • ignoring only the exit status, only errors, only failures, or a missing summary (1 failure each).
  • Strict mode. With RUFLET_MRUBY pointing nowhere, --strict tools exits 1 and names MrubyPatchesTest#test_fits_the_pinned_mruby.
  • H1 goldens. cd packages/ruflet && ruby test/compat/compat.rb --jobs 4 checked 359 goldens. ruby -Ilib -Itest test/compat_goldens_test.rb: 367 runs, 0 failures.
  • bundle-audit check --no-update is clean in all five packages, and BUNDLE_FROZEN=true bundle install succeeds in ruflet_rails and ruflet_record.
  • Shipped files are unchanged. git diff --name-only origin/main lists no gemspec and no file under lib/. Gem::Specification.load for each gemspec gives the same files and runtime dependencies as on main.

Behavior changes

None for anyone writing or running Ruflet apps. The gems, their dependency ranges and their contents are unchanged. For contributors and CI:

  • A PR touching packages/**, tools/**, ruby_runtime/** or .ruby-version now also runs Ruby tests. That workflow fails on a skipped test or on a known advisory in a package lockfile.
  • packages/ruflet_core, ruflet_server and ruflet now have a Gemfile, so bundle install works there.
    • ruflet run uses the Gemfile nearest to the directory it starts in. Apps live outside these package folders, so nothing changes for them.
    • The exception is the repository's own fixture apps under packages/ruflet/test/compat/fixtures/ (for example services_app and icons_app). Started in place with ruflet run, they now find packages/ruflet/Gemfile, so ruflet run runs bundle check (and bundle install if needed) and starts them with -rbundler/setup instead of plain ruby. This only affects contributors running those fixtures by hand. The compat goldens copy each fixture into a temporary directory before running it, so they are unaffected.
    • The plain and bundled suites and the compat goldens pass unchanged.

Not covered here

…ckfiles

CI ran only packages/ruflet, ruflet_core and ruflet_server plus
tools/mruby_patches_test.rb. The ruflet_rails, ruflet_record, ruby_runtime
and other tools suites never ran, a tools/** change started no workflow,
five cross-checks skipped on every run, and the core suites only loaded on
a Ruby that bundles minitest 5.

- tools/run_ruby_tests.rb runs each suite as CI does and, with --strict,
  fails on any skip not on its (empty) allow-list.
- .github/workflows/ruby-tests.yml runs every suite strictly on macOS
  with a template and engine checkout and the pinned mruby, on
  packages/**, tools/**, ruby_runtime/** and .ruby-version, plus a
  bundler-audit job over all five packages.
- Development-only Gemfiles for ruflet_core, ruflet_server and ruflet
  (minitest 5 or 6 with minitest-mock, and the cross-check gems);
  sqlite3 for ruflet_rails' executor scenarios.
- ruflet_rails: rails 8.1.4.1, rack 3.2.9, nokogiri 1.19.7, loofah
  2.25.3, crass 1.0.8, json 2.21.2, rails-html-sanitizer 1.7.2.
  ruflet_record: sqlite3 2.10.2, Linux/Intel platforms. 61 advisories -> 0.
- A booted-Rails test for TemplateSource#fetch, the production
  erb_to_native fetcher.
- tools tests pin the contract: every test file is in a suite, the
  workflow runs every suite strictly, and its paths cover them.
- Dependabot (lockfile-only bundler and pub, github-actions).
- release.md and CONTRIBUTING_RUFLET.md test commands now work.

No gemspec, lib/ or other shipped file changes.

Fixes #148
…tests

- ruby-tests.yml checks out ruflet-engine at a pinned commit, so an engine
  merge that adds a service no longer fails later ruflet runs; the comment
  says how to move it. ruflet-template stays unpinned on purpose.
- Only pull request runs share a concurrency group, so a merge to main no
  longer cancels the run of the merge before it.
- ruby_tests_workflow_test watches every file in each suite's folder (lib/,
  Gemfile, Gemfile.lock) and all of tools/, applies !patterns the way
  GitHub does, and checks the engine ref is a commit.
- run_ruby_tests_test covers an erroring file, a file that exits non-zero
  after a clean summary, and failure/error counts on exit 0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant