Skip to content

ci: PR unit -n auto, 4 lifecycle shards, 3 Windows unit shards, split macOS arm64 lane (#4030) - #4032

Merged
Daniel Meppiel (danielmeppiel) merged 5 commits into
mainfrom
danielmeppiel-bookish-invention
Nov 20, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 5 commits into
mainfrom
danielmeppiel-bookish-invention

Conversation

@danielmeppiel

@danielmeppiel Daniel Meppiel (danielmeppiel) commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Caution

Touches build-release.yml: merge only after v0.37.0 is tagged and published.

Description

TL;DR — CI layout only, for #4030. PR unit shards use every runner CPU, lifecycle smoke goes from 3 to 4 seed-balanced shards, main-push Windows units go from 2 to 3 shards, and the macOS arm64 lane is split into a unit job and a build/integration job on the same SHA. Same tests, events and release-promotion evidence; every aggregate still fails closed.

Item Before After File
R1 PR unit shards 2 shards, -n 2 --dist worksteal 2 shards, -n auto --dist worksteal (what main push already uses) ci.yml
R2 Lifecycle smoke 3 shards, --shard-count 3 4 shards, --shard-count 4, same planner + seed; Lifecycle Smoke (Linux) requires all 4 ci.yml
R3 Main-push Windows units windows-unit-1..2 windows-unit-1..3; build-windows-push needs all 3 and its gate requires push:success ×5 build-release.yml
R5 macOS arm64 one job: setup → units → build → integration → release validation unit-macos-arm (same setup, same unit command) ∥ build-and-validate-macos-arm (unchanged minus units) build-release.yml

Fail-closed and release evidence

  • Lifecycle Smoke (Linux) is if: always() and needs every shard result to be success. Missing, skipped, cancelled or failed results all fail it (tested by running the real step).
  • build-windows-push does not build, sign or upload unless plan, installer and all 3 unit shards are success.
  • unit-macos-arm runs exactly when the old unit step ran (mode != 'push' && run_unit == 'true', so full runs only). create-release needs it and requires success. The only exception is a promoted tag, where it may be skipped, the same rule integration-tests already uses. daily-release-smoke-signal also needs it.
  • Promotion evidence (scripts/release_plan.py) is unchanged: a green full run of the exact SHA. A failing unit-macos-arm fails that run, so it can no longer be evidence.
  • Out of scope, not touched: the merge queue, Windows units on PRs, test deletion, lazy imports, and changing which tests run.

Issue and approved scope

Issue: Fixes #4030

Human scope-approval comment: #4030 (comment) (eligibility.cjs: record-present, contact_confirmation_needed: false)

This PR completes the issue's Done-when, except the 20-run confirmation after merge that the record defers.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

Node-set diff on the same SHA (7ee94db). For each layout, the union of the shards equals the baseline set and their pairwise intersection is empty:

R1 PR unit, 2 shards (unchanged split; -n 2 -> -n auto): baseline=28973 shards=[15249, 13724] union=28973 union==baseline=True pairwise_intersection=0
R2 lifecycle, before: 3 shards: baseline=811 shards=[282, 239, 290] union=811 union==baseline=True pairwise_intersection=0
R2 lifecycle, after: 4 shards: baseline=811 shards=[195, 256, 186, 174] union=811 union==baseline=True pairwise_intersection=0
R3 Windows units, before: 2 shards: baseline=28654 shards=[14143, 14511] union=28654 union==baseline=True pairwise_intersection=0
R3 Windows units, after: 3 shards: baseline=28654 shards=[9445, 10128, 9081] union=28654 union==baseline=True pairwise_intersection=0
R5 macOS arm64: unit job nodes=28654 (command byte-identical to the pre-split step), build job integration nodes=1077 (MACOS_MARK_EXPR unchanged), unit&integration=0
Commands (each node set is ... --collect-only -q | grep '::' | sort, then set union/intersection in Python)
P="uv run --frozen --extra dev python -m pytest --collect-only -q -p no:cacheprovider"
export APM_E2E_TESTS=1
# R1 baseline + shards i=1..2
$P tests/unit tests/test_console.py tests/red_team tests/fixtures/policy
$P tests/unit tests/test_console.py tests/red_team tests/fixtures/policy \
  -p scripts.ci_sharding --shard-count 2 --shard-index $i --shard-durations .github/ci-durations/linux-unit.json
# R2 baseline + shards (count 3: i=1..3, count 4: i=1..4)
$P --strict-markers -m 'lifecycle_smoke and not lifecycle_merge_group' tests/integration
$P --strict-markers -m 'lifecycle_smoke and not lifecycle_merge_group' tests/integration \
  -p scripts.ci_sharding --shard-count $N --shard-index $i --shard-durations .github/ci-durations/linux-x86_64.json
# R3 baseline + shards (count 2 and 3), collected on Linux
$P tests/unit tests/test_console.py
$P tests/unit tests/test_console.py \
  -p scripts.ci_sharding --shard-count $N --shard-index $i --shard-durations .github/ci-durations/windows-unit.json
# R5: the unit job runs `uv run pytest tests/unit tests/test_console.py -n auto --dist worksteal`,
# byte-identical to the removed step on main; the integration subset is unchanged:
$P tests/integration/ -m "$MACOS_MARK_EXPR"

R1 changes only the xdist worker count, which does not affect collection. The 2-shard split is the same as before.

Pinned in tests. tests/quality/test_ci_topology.py now enforces:

  • 4 lifecycle shards, through the existing parametrized constants and test_lifecycle_shards_collect_exact_required_union, which collects every shard live;
  • PR unit -n auto --dist worksteal with xdist flags set exactly once;
  • 3 Windows unit shards, with the real Require Windows push tests gate executed against failed, cancelled, skipped, empty and missing results;
  • the macOS split: identical setup and command, no unit step left in either build job, and create-release/daily-smoke dependency plus its success-or-promoted-skip condition.

Mutation tests fail each guard. test_push_ci_gates.py and test_platform_contract_workflow.py are updated for 3 Windows shards and the three-macOS-job capacity rule.

$ uv run --extra dev pytest tests/quality/test_ci_topology.py tests/unit/test_push_ci_gates.py tests/unit/test_platform_contract_workflow.py tests/unit/test_ado_live_workflow_contract.py tests/unit/test_security_workflow_contracts.py tests/unit/test_windows_unit_diagnostics.py tests/unit/test_triage_advisory.py -q -n 4
368 passed in 51.21s
$ ruff check / ruff format --check / pylint R0801 / lint-auth-signals.sh   -> all clean
$ uv run --frozen apm audit --ci   -> All 10 check(s) passed

PR-gate wall clock. Measured from CI run start to completion of the last required check (Build & Test Shard 1/2, Windows Compatibility Gate, APM Self-Check, Lifecycle Smoke (Linux)). All required checks were green in every sample:

Sample Run Gate Critical-path job
1 44651255594 attempt 2 6:58 Build & Test Shard 1 (unit step 396 s; collection alone 128 s on that runner)
2 44651255594 attempt 3 6:50 Lifecycle Smoke (Linux) (shards 339–397 s)
3 44651255594 attempt 4 7:02 Build & Test Shard 1 (415 s; lifecycle shards 287–378 s)
4 44651255594 attempt 5 6:46 Lifecycle Smoke (Linux)
Median (n=4) 6:54

Baseline for comparison: the private audit measured 7:35. Eight green old-layout PR CI runs sampled in the same hour had a median of 8:38 (range 6:59–9:02). The new layout is about 40 s under the audit baseline and about 1:45 under the same-hour baseline. It does not yet reach the 6:05 target. The critical path now alternates between Build & Test Shard 1 (-n auto gives the unit step 231–396 s, depending on the runner) and the lifecycle shards. Lifecycle balance is limited by the seed: only about 40% of the 811 lifecycle nodes have weights in .github/ci-durations/linux-x86_64.json, and the rest are weighted at the mean. Refreshing that seed would change release integration sharding too, so it is left out of this layout-only PR as a follow-up. Runner variance is large: unit-shard collection took 48–128 s across samples.

Pre-merge checklist

  • v0.37.0 is tagged and published (this PR touches build-release.yml).
  • Rebased on main after the tag; CI green.
  • After merge: the first nightly full run shows Unit Tests (macOS arm64) and Build & Validate (macOS arm64) green on the same SHA, plus the 20-run PR-gate confirmation.

Changelog

  • One line in one section under ## [Unreleased] in CHANGELOG.md (the scope record asks for one internal line; it is under Changed, prefixed Internal:).
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

Not applicable: no req-XXX behaviour changes.

Co-authored-by: Copilot [email protected]

… macOS arm64 lane (#4030)

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.37.0 milestone Nov 20, 2026
@danielmeppiel Daniel Meppiel (danielmeppiel) changed the title [0.38] ci: PR unit -n auto, 4 lifecycle shards, 3 Windows unit shards, split macOS arm64 lane (#4030) ci: PR unit -n auto, 4 lifecycle shards, 3 Windows unit shards, split macOS arm64 lane (#4030) Nov 20, 2026
Co-authored-by: copilot-swe-agent[bot] <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The CI documentation overstates macOS validation on branch pushes and ARM integration coverage, requiring corrections in both instruction files and refreshed lockfile hashes.

1 open issue
What changed in this PR

This PR addresses #4030 by increasing parallelism in APM's CI workflows while preserving test selections and release-validation requirements.

Changes:

  • Uses -n auto for PR unit tests and expands lifecycle smoke testing to four shards.
  • Expands main-push Windows unit testing to three shards and separates macOS arm64 units from build validation.
  • Updates dependency gates, workflow contract tests, and supporting documentation.
File Description
tests/​unit/​test_push_ci_gates.py Updates Windows gate expectations for three shards.
tests/​unit/​test_platform_contract_workflow.py Accounts for the separate macOS arm64 unit job.
tests/​quality/​test_ci_topology.py Adds layout checks and mutations covering shards and release dependencies.
docs/​src/​content/​docs/​contributing/​integration-testing.md Documents four lifecycle shards and the macOS split.
CHANGELOG.md Records the internal CI layout change.
apm.lock.yaml Refreshes deployed CI instruction hashes.
.github/​workflows/​ci.yml Increases unit parallelism and adds the fourth lifecycle shard.
.github/​workflows/​build-release.yml Adds Windows and macOS unit jobs with downstream gates.
.github/​instructions/​cicd.instructions.md Updates deployed CI guidance.
.apm/​instructions/​cicd.instructions.md Updates canonical CI guidance.

Review effort: Balanced

Comment thread .apm/instructions/cicd.instructions.md Resolved
…ge over all 4 shards; CHANGELOG [Unreleased])

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 74a9dd6 into main Nov 20, 2026
31 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-bookish-invention branch November 20, 2026 08:42
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.

CI topology quick wins: PR unit -n auto, 4 lifecycle shards, 3 Windows unit shards, split macOS arm64 lane

2 participants