Skip to content

Run the tests in the release run's six shards on pull requests - #4145

Draft
anth-volk wants to merge 2 commits into
masterfrom
shard-pull-request-tests
Draft

anth-volk wants to merge 2 commits into
masterfrom
shard-pull-request-tests

Conversation

@anth-volk

@anth-volk anth-volk commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #4144

Stacked on #4140.

Summary

Pull requests run the test suite in the same six shards as the release run, and check that each test ran in exactly one.

  • pr.yml's test job has the same strategy as push.yml's release-tests: a matrix of shard_index 1 to 6 with fail-fast: false. Its step still runs make test, with PYTEST_ADDOPTS: -p tests.release_test_shard_plugin and the three RELEASE_TEST_SHARD_* variables set as run_release_tests.sh sets them. Each shard uploads the tests it collected and ran as the artifact release-test-shard-<n>, with the same upload step as the release run.
  • check-test-shards (new job) has the same steps as check-release-test-shards: it downloads the six reports and runs python -m scripts.release_test_shards check-coverage --shard-count 6. "CI complete" needs it. It has no condition of its own, so when a shard fails, or on a stacked pull request above the lowest one, it is skipped and "CI complete" fails.
  • Coverage: each shard uploads the coverage of its own tests to Codecov, which merges the uploads for a commit, as it already does with the cross-database integration tests' upload.
  • Rules registry: every pr.yml job must enforce a registered rule, so api.quality.tests-pass now names check-test-shards too, and says each test runs in exactly one shard. docs/generated/rules.md is regenerated.
  • docs/engineering/skills/testing.md describes the pull request shards.

The job runs make test rather than run_release_tests.sh because 34 rules in rules/registry.toml name pr.yml's test job with the invocation make test, which the registry check looks for in the job's commands. The script's other work, removing deployment settings, has nothing to remove here: the pull request job sets none of them.

Expected effect

Environment variables

No new secrets or variables. The step's new variables are literals, or come from the matrix and runner.temp. The job's secrets are unchanged, and each shard gets them the same way the single job did:

  • Repository secrets: POLICYENGINE_DB_PASSWORD, CODECOV_TOKEN, GCP_WORKLOAD_IDENTITY_PROVIDER, GCP_DEPLOY_SERVICE_ACCOUNT.
  • Organization secrets: OPENAI_API_KEY, PE_UK_PRIVATE_HF_READ_TOKEN (as HUGGING_FACE_TOKEN), POLICYENGINE_GITHUB_MICRODATA_AUTH_TOKEN.
  • Repository variable: OLD_SIMULATION_GATEWAY_URL, set for the whole workflow.

check-test-shards reads no secrets.

Unverified until this pull request's CI runs

This pull request sits above #4140, so its CI skips every job and "CI complete" fails by design until #4140 merges and this one is rebased.

  • That all six shards pass on pull request runners, and that check-test-shards passes.
  • That Codecov merges six uploads per commit. Its checks are not required, but it may report lower coverage until every shard has uploaded.

Testing

  • Red: b0535a1 (tests only). test_pull_requests_run_the_tests_in_the_release_runs_shards and test_ci_complete_needs_every_pull_request_test_to_have_run_once in tests/unit/test_release_test_shards.py both failed: pr.yml's test job had no matrix, and there was no check-test-shards job.
  • Green: 02e9925. Both tests pass.
  • python scripts/run_quality_guards.py: every guard passed. python -m scripts.rules render produced the docs/generated/rules.md change included here.
  • ruff format --check and ruff check on the changed test files, with the ruff version uv.lock pins (0.15.12): clean. actionlint .github/workflows/pr.yml: clean.
  • Only the two new tests were run locally.

🤖 Generated with Claude Code

@anth-volk
anth-volk added this pull request to stack #4146 October 30, 2026 16:34
@anth-volk anth-volk changed the title shard pull request tests Run the tests in the release run's six shards on pull requests Oct 30, 2026
@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.16%. Comparing base (22c4f36) to head (e2e3640).
⚠️ Report is 9 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #4145       +/-   ##
===========================================
+ Coverage   50.63%   88.16%   +37.52%     
===========================================
  Files         258      274       +16     
  Lines       14955    16393     +1438     
  Branches     2399     2689      +290     
===========================================
+ Hits         7573    14453     +6880     
+ Misses       6751     1271     -5480     
- Partials      631      669       +38     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Base automatically changed from shard-settings-out-of-subprocesses to master October 30, 2026 16:41
anth-volk and others added 2 commits October 30, 2026 20:41
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@anth-volk
anth-volk force-pushed the shard-pull-request-tests branch from 02e9925 to e2e3640 Compare October 30, 2026 16:41

This branch was successfully deployed

1 active deployment
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.

Split the pull request tests into the same six shards as the release tests

1 participant