From 71cedbd33dbcd96a54369e55272ff77978fd99a6 Mon Sep 17 00:00:00 2001 From: Malaber Date: Sat, 11 Apr 2026 15:50:19 +0200 Subject: [PATCH] Fix isolated shard loading and docker shard task --- AGENTS.md | 1 + tasks.py | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index f4d9a9d..54c756d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -19,6 +19,7 @@ Examples: - `inv blackbox-production` - `inv scenario-main-usecase` - `inv docker-build-all` +- `inv docker-test-shard --node-index=3 --node-total=8` - `inv docker-test-http-e2e` The GitLab CI pipeline is expected to use these tasks as well. diff --git a/tasks.py b/tasks.py index 1d61fed..0721fc9 100644 --- a/tasks.py +++ b/tasks.py @@ -322,7 +322,10 @@ def test_shard(c, node_index=1, node_total=8, dry_run=False): if not files: return - c.run("bundle exec rspec " + " ".join(shlex.quote(path) for path in files), pty=True) + c.run( + "bundle exec rspec --require ./spec/rails_helper " + " ".join(shlex.quote(path) for path in files), + pty=True, + ) @task @@ -722,3 +725,17 @@ def docker_test_http_e2e( "kill \\$SERVER_PID\"" ) c.run(command, pty=True) + + +@task(name="docker-test-shard") +def docker_test_shard(c, node_index=1, node_total=8, image=TEST_TAG, build=True): + """Run one Rails-spec shard inside the test Docker image.""" + if build: + docker_build_all(c) + + command = ( + f"docker run --rm {image} bash -lc " + f"\"cd /app && bundle exec rails db:migrate && " + f"inv test-shard --node-index={node_index} --node-total={node_total}\"" + ) + c.run(command, pty=True)