Skip to content

ci: reuse green PR CI results in merge queue - #55

Merged
Blind-Striker merged 1 commit into
masterfrom
ci/16-merge-group-reuse
Nov 20, 2026
Merged

Blind-Striker merged 1 commit into
masterfrom
ci/16-merge-group-reuse

Conversation

@Blind-Striker

Copy link
Copy Markdown
Contributor

Refs #16. Live merge-queue proof (full run on this guarded PR, then a reuse skip on a subsequent non-guarded PR) follows after merge, so this PR leaves #16 open.

What changes

  • tools/OpenCode.Mcp.Tools/Ci/MergeGroupReuseDecision.cs & MergeGroupReuseRunner.cs:
    • Pure fail-safe reuse decision over 12 raw fact files implementing all five rules:
      1. Two-parent master merge-group commit with valid pr-<n>- queue ref, head hash, and base hash.
      2. PR still matches head SHA and targets master.
      3. Latest pull_request run of .github/workflows/ci.yml for the head succeeded in its latest attempt, with one successful CI result job in that attempt.
      4. Unique, unexpired tested-tree-<run_attempt> artifact created within the attempt's successful Changes job window, with strict two-line tree and base-tree equality.
      5. Case-insensitive guarded-path refusal for .github/**, tools/**, Directory.Build.*, Directory.Packages.props, global.json, and nuget.config.
    • File-based runner writing reuse=true|false and reason=... and returning exit code 0 on unreadable facts or unwritable output (fail-safe; cancellation propagates).
  • Native tool CLI (NativeCommand, NativeArguments, NativeApplication):
    • Adds merge-group-reuse --facts <dir> --output <file> before manifest loading, so dotnet run tools/native.cs -- merge-group-reuse ... runs without packaging/native-manifest.json.
    • Extracts InspectAsync in NativeApplication to keep RunAsync within MA0051.
  • .github/workflows/ci.yml:
    • changes records and uploads tested-tree-<run_attempt> (7-day retention) on pull_request.
    • Adds reuse job on merge_group (10-minute timeout; read-only contents, actions, pull-requests permissions; persist-credentials: false on checkout). Its shell guard runs before .NET setup, checks freshly fetched refs/heads/master against both base_sha and HEAD^1 (blocking stacked/batched entries from running unmerged tooling) using step-scoped --config-env, and scans changed paths case-insensitively before invoking tools/native.cs.
    • lint and build-and-test depend on [changes, reuse] with !cancelled() so push to master (where reuse is skipped) and any failed/refused reuse job run full CI.
    • ci-result fails closed on the updated verdict table, permitting skipped heavy jobs on reuse only for merge_group with Changes green.
  • Canonical docs (docs/engineering/quality-gates.md, docs/engineering/workflow.md):
    • Documents the tested-tree-<run_attempt> artifact, reuse job rules, fail-safe direction, re-run failed jobs limitation, permissions, 10-minute bound, and updated CI result verdict table.

Verification

  • Tests: 59 decision rows, 5 runner cases (including fault-injected I/O and cancellation), 4 CLI/application cases (without native manifest), plus NativeArgumentsTests coverage for merge-group-reuse.
  • Mutant proofs: Verified red-then-green across 13 mutants (tree equality, earlier green run, workflow path filter, guarded paths, missing artifact, artifact time-window lower/upper bounds and inclusive boundaries, base-tree equality, pr- prefix, wrong JSON type, non-hash tree/base-tree, and blank-line tested-tree inputs).
  • Local check (7827d694): Slopwatch (0 issues), Release build with analyzers (0 warnings), dotnet format whitespace & style, tools/native.cs build, full solution test suite (1037 passed, 0 failed, 0 skipped), and validate empty-receipt CLI smoke (exit 2, 6 ordered lines) all passed.

Extract the native inspection path into InspectAsync to keep RunAsync within MA0051 after adding the reuse command.
@Blind-Striker
Blind-Striker added this pull request to the merge queue Nov 20, 2026
Merged via the queue into master with commit 6c9fecb Nov 20, 2026
33 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