Skip to content

feat(rust): port ci scopes to native Rust#1461

Merged
mergify[bot] merged 1 commit into
mainfrom
devs/jd/worktree-rust-port/port-ci-scopes-native-rust--635d39bc
May 29, 2026
Merged

feat(rust): port ci scopes to native Rust#1461
mergify[bot] merged 1 commit into
mainfrom
devs/jd/worktree-rust-port/port-ci-scopes-native-rust--635d39bc

Conversation

@jd
Copy link
Copy Markdown
Member

@jd jd commented May 26, 2026

mergify ci scopes is now handled by the Rust binary: load the
.mergify.yml scopes: block, resolve (base, head) via the
existing git_refs::detect machinery (or --base/--head for
"manual" mode), shell out to git diff for changed files, and
route each path through every scope's include/exclude globs to
produce the touched-scope set.

The implementation lands in mergify-ci::scopes_detect as a
five-file module:

  • config.rs — YAML schema (Scopes / Source::Files / Source::Manual
    / FileFilters), with BTreeMap for sorted iteration that
    keeps human output deterministic without indexmap.
  • matching.rsglobset-backed file → scope routing, with
    Python-equivalent ** recursive semantics
    (literal_separator(false)).
  • changed_files.rsgit diff base...head --name-only --diff-filter=ACMRTD, with the progressive --deepen
    fetching dance Python uses to dig out a merge base on shallow
    CI clones.
  • outputs.rs — side effects: $GITHUB_OUTPUT JSON dict,
    buildkite-agent meta-data set, $GITHUB_STEP_SUMMARY
    markdown table, buildkite-agent annotate at job + build
    scope. Each one is a no-op when its environment knob isn't
    set.
  • mod.rs — the run() entry point plus the
    --write <PATH> JSON emitter consumed by
    ci scopes-send --scopes-json.

Wired into the binary as a real Subcommands::Ci(CiSubcommand:: Scopes(...)) variant (replacing the previous shim stub) and
added to NATIVE_COMMANDS. clap gains the env feature so
MERGIFY_CONFIG_PATH is honored on --config directly. Adds
globset and a workspace-internal edge mergify-ci → mergify-config for the auto-detection of .mergify.yml /
.mergify/config.yml / .github/mergify.yml. Also makes
git_refs::ReferencesSource::as_str public so the markdown
emitter can reuse the wire-format names without re-encoding the
mapping.

Live smoke test from the previous commit
(test_ci_scopes_select_all_when_no_base) now exercises the
Rust binary's "no base provided" branch end-to-end. 88
mergify-ci unit tests pass (was 75; +13 for scopes_detect).

Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com

@jd
Copy link
Copy Markdown
Member Author

jd commented May 26, 2026

This pull request is part of a Mergify stack:

# Pull Request Link
1 feat(rust): port ci scopes to native Rust #1461 👈
2 feat(ci): swap Python's JUnit XML parser for the native Rust parser #1465
3 feat(ci): swap Python's OTLP encode+upload for the native Rust pipeline #1466
4 feat(ci): promote ci junit-process and its junit-upload alias to native Rust #1467

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 26, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🟢 🤖 Continuous Integration

Wonderful, this rule succeeded.
  • all of:
    • check-success=ci-gate

🟢 👀 Review Requirements

Wonderful, this rule succeeded.
  • any of:
    • #approved-reviews-by>=2
    • author = dependabot[bot]
    • author = mergify-ci-bot
    • author = renovate[bot]

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert|ui)(?:\(.+\))?:

🟢 🔎 Reviews

Wonderful, this rule succeeded.
  • #changes-requested-reviews-by = 0
  • #review-requested = 0
  • #review-threads-unresolved = 0

🟢 📕 PR description

Wonderful, this rule succeeded.
  • body ~= (?ms:.{48,})

@jd
Copy link
Copy Markdown
Member Author

jd commented May 27, 2026

Revision history

# Type Changes Reason Date
1 initial d233611 2026-05-27 07:53 UTC
2 content d233611 → b1b850b (raw) 2026-05-27 07:53 UTC
3 content b1b850b → d3fd85c 2026-05-27 08:27 UTC
4 content d3fd85c → 2857e8a (raw) 2026-05-27 08:46 UTC
5 rebase 2857e8a → b0d5709 (rebase only) 2026-05-27 10:04 UTC
6 content b0d5709 → a7edc08 (raw) Wrap the three scopes_detect tests that call run() in with_ci_env(&[], ...) so they pick up the GITHUB_OUTPUT scrub from the consolidated CI_ENV_VARS list. Without the wrapper, on a GHA runner the ru… 2026-05-27 10:15 UTC
7 rebase e40bd7f → 854f5b9 (rebase only) 2026-05-28 09:45 UTC
8 rebase 854f5b9 → 3cd6489 (rebase only) 2026-05-29 06:35 UTC
9 rebase 3cd6489 → f13743d (rebase only) 2026-05-29 08:31 UTC

@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 27, 2026 07:53 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-scopes-native-rust--635d39bc branch from b1b850b to d3fd85c Compare May 27, 2026 08:27
@jd jd temporarily deployed to func-tests-live May 27, 2026 08:27 — with GitHub Actions Inactive
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-scopes-native-rust--635d39bc branch from e40bd7f to 854f5b9 Compare May 28, 2026 09:45
@jd jd temporarily deployed to func-tests-live May 28, 2026 09:45 — with GitHub Actions Inactive
@jd jd temporarily deployed to func-tests-live May 28, 2026 09:45 — with GitHub Actions Inactive
@jd jd temporarily deployed to func-tests-live May 28, 2026 09:45 — with GitHub Actions Inactive
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 28, 2026 09:45 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-scopes-native-rust--635d39bc branch from 854f5b9 to 3cd6489 Compare May 29, 2026 06:35
@jd jd force-pushed the devs/jd/worktree-rust-port/add-live-smoke-test-ci-scopes-select-path--14468b70 branch from 4680d78 to f58073c Compare May 29, 2026 06:35
@jd jd temporarily deployed to func-tests-live May 29, 2026 06:35 — with GitHub Actions Inactive
@jd jd temporarily deployed to func-tests-live May 29, 2026 06:35 — with GitHub Actions Inactive
@jd jd temporarily deployed to func-tests-live May 29, 2026 06:35 — with GitHub Actions Inactive
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 29, 2026 06:35 Failure
Base automatically changed from devs/jd/worktree-rust-port/add-live-smoke-test-ci-scopes-select-path--14468b70 to main May 29, 2026 08:18
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 29, 2026

@jd this pull request is now in conflict 😩

@mergify mergify Bot added the conflict label May 29, 2026
`mergify ci scopes` is now handled by the Rust binary: load the
`.mergify.yml` `scopes:` block, resolve `(base, head)` via the
existing `git_refs::detect` machinery (or `--base`/`--head` for
"manual" mode), shell out to `git diff` for changed files, and
route each path through every scope's include/exclude globs to
produce the touched-scope set.

The implementation lands in `mergify-ci::scopes_detect` as a
five-file module:

  - `config.rs` — YAML schema (`Scopes` / `Source::Files` / `Source::Manual`
    / `FileFilters`), with `BTreeMap` for sorted iteration that
    keeps human output deterministic without `indexmap`.
  - `matching.rs` — `globset`-backed file → scope routing, with
    Python-equivalent `**` recursive semantics
    (`literal_separator(false)`).
  - `changed_files.rs` — `git diff base...head --name-only
    --diff-filter=ACMRTD`, with the progressive `--deepen`
    fetching dance Python uses to dig out a merge base on shallow
    CI clones.
  - `outputs.rs` — side effects: `$GITHUB_OUTPUT` JSON dict,
    `buildkite-agent meta-data set`, `$GITHUB_STEP_SUMMARY`
    markdown table, `buildkite-agent annotate` at job + build
    scope. Each one is a no-op when its environment knob isn't
    set.
  - `mod.rs` — the `run()` entry point plus the
    `--write <PATH>` JSON emitter consumed by
    `ci scopes-send --scopes-json`.

Wired into the binary as a real `Subcommands::Ci(CiSubcommand::
Scopes(...))` variant (replacing the previous shim stub) and
added to `NATIVE_COMMANDS`. clap gains the `env` feature so
`MERGIFY_CONFIG_PATH` is honored on `--config` directly. Adds
`globset` and a workspace-internal edge `mergify-ci →
mergify-config` for the auto-detection of `.mergify.yml` /
`.mergify/config.yml` / `.github/mergify.yml`. Also makes
`git_refs::ReferencesSource::as_str` public so the markdown
emitter can reuse the wire-format names without re-encoding the
mapping.

Live smoke test from the previous commit
(`test_ci_scopes_select_all_when_no_base`) now exercises the
Rust binary's "no base provided" branch end-to-end. 88
`mergify-ci` unit tests pass (was 75; +13 for `scopes_detect`).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Change-Id: I635d39bc6a271e71663968912908bb2fb5c7aeeb
Copilot AI review requested due to automatic review settings May 29, 2026 08:31
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-scopes-native-rust--635d39bc branch from 3cd6489 to f13743d Compare May 29, 2026 08:31
@jd jd temporarily deployed to func-tests-live May 29, 2026 08:31 — with GitHub Actions Inactive
@jd jd temporarily deployed to func-tests-live May 29, 2026 08:31 — with GitHub Actions Inactive
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@mergify mergify Bot deployed to Mergify Merge Protections May 29, 2026 08:31 Active
@mergify mergify Bot removed the conflict label May 29, 2026
@mergify mergify Bot requested a review from a team May 29, 2026 09:25
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 29, 2026

Merge Queue Status

  • Entered queue2026-05-29 09:51 UTC · Rule: default
  • Checks skipped · PR is already up-to-date
  • Merged2026-05-29 09:52 UTC · at f13743de3e9e41ddce30ad60ced43f79a4435f7f · squash

This pull request spent 32 seconds in the queue, including 4 seconds running CI.

Required conditions to merge

@mergify mergify Bot added the queued label May 29, 2026
@mergify mergify Bot merged commit 51f1c48 into main May 29, 2026
36 checks passed
@mergify mergify Bot deleted the devs/jd/worktree-rust-port/port-ci-scopes-native-rust--635d39bc branch May 29, 2026 09:52
@mergify mergify Bot removed the queued label May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants