feat(rust): port ci scopes-send to native Rust (Phase 1.4)#1300
Conversation
|
This pull request is part of a Mergify stack:
|
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🔴 ⛓️ Depends-On RequirementsWaiting for:
This rule is failing.Requirement based on the presence of
🔴 👀 Review RequirementsWaiting for:
This rule is failing.
🔴 🔎 ReviewsWaiting for:
This rule is failing.
🟢 🤖 Continuous IntegrationWonderful, this rule succeeded.
🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 📕 PR descriptionWonderful, this rule succeeded.
|
2a502cd to
e4397c6
Compare
86a41aa to
0bbac0d
Compare
Revision history
|
e4397c6 to
6dee3f1
Compare
0bbac0d to
5d204df
Compare
5d204df to
d362a75
Compare
6dee3f1 to
cc09d55
Compare
cc09d55 to
f5f004a
Compare
d362a75 to
b37daf9
Compare
f5f004a to
d7398e1
Compare
b37daf9 to
83b1aac
Compare
|
@jd this pull request is now in conflict 😩 |
16c4ea5 to
33da35f
Compare
There was a problem hiding this comment.
Pull request overview
Ports the first mergify ci command (ci scopes-send) from the Python shim to a native Rust implementation, enabling direct HTTP POST of detected scopes to the Mergify API while keeping other ci subcommands shimmed.
Changes:
- Add a new
mergify-cicrate implementingci scopes-send(options resolution + scope collection + POST). - Extend
mergifyRust binary dispatch to recognizeci scopes-sendas a native subcommand. - Mark
ci scopes-sendasnativeinPORT_STATUS.tomland update Cargo dependencies/lockfile accordingly.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/mergify-cli/src/main.rs | Adds ci subcommand parsing + native dispatch to mergify-ci::scopes_send. |
| crates/mergify-cli/Cargo.toml | Adds path dependency on the new mergify-ci crate. |
| crates/mergify-ci/src/scopes_send.rs | Implements native ci scopes-send logic + unit/integration-style wiremock tests. |
| crates/mergify-ci/src/lib.rs | Exposes scopes_send module for the new crate. |
| crates/mergify-ci/Cargo.toml | Defines new crate metadata and dependencies for the CI subcommands. |
| PORT_STATUS.toml | Flips ci scopes-send from shimmed to native. |
| Cargo.lock | Adds mergify-ci and related dependency updates. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0d9b6f9 to
e5530f7
Compare
33da35f to
0f96088
Compare
0f96088 to
b6ffa74
Compare
1b53967 to
a745f41
Compare
a745f41 to
800a454
Compare
b6ffa74 to
1c79bf4
Compare
1c79bf4 to
ca1ea46
Compare
First ``ci`` command to go native. Straight HTTP POST to Mergify carrying the scopes detected for a pull request, no new infrastructure needed beyond what the config pilot already established. ## What ports natively ``mergify ci scopes-send [-r REPO] [-p NUMBER] [-t TOKEN] [-u URL] [-s SCOPE...] [--scopes-json FILE] [--scopes-file FILE]``: 1. Resolves the repository: ``--repository`` flag → ``GITHUB_REPOSITORY`` env → error. 2. Resolves the pull-request number: ``--pull-request`` flag → ``GITHUB_EVENT_PATH`` JSON (``.pull_request.number``) → ``None``. When ``None`` the command prints a skip message to stderr and returns 0 — matches Python's "no PR, nothing to send". 3. Resolves the token: ``--token`` flag → ``MERGIFY_TOKEN`` → ``GITHUB_TOKEN`` → error. 4. Resolves the API URL: ``--api-url`` flag → ``MERGIFY_API_URL`` → ``https://api.mergify.com``. 5. Collects scopes from up to three sources (combined in order): ``--scope`` repeated flags, ``--scopes-json`` (Pydantic ``DetectedScope`` dump), ``--scopes-file`` (plain text). 6. POSTs ``{"scopes": [...]}`` to ``/v1/repos/<repo>/pulls/<number>/scopes`` via the HTTP client. ``--file`` is a hidden deprecated alias for ``--scopes-json``. When used, the command prints a deprecation warning to stderr and proceeds — matches Python's ``click.echo(..., err=True)``. ## Layout New ``mergify-ci`` crate under ``crates/``. The ``scopes_send`` module is self-contained (duplicates ``resolve_token`` / ``resolve_api_url`` from ``mergify-config::simulate`` for now — they factor into ``mergify-core`` in a follow-up refactor PR once another command needs them). The binary's dispatch gains a ``Ci`` subcommand group, with ``scopes-send`` as its only native variant today. Everything else under ``ci`` (``git-refs``, ``scopes``, ``scopes-send`` siblings) still falls through to the Python shim. The native-intent heuristic in ``detect_native`` now recognizes both the ``config`` and ``ci`` prefixes. ## Tests 11 new unit tests in ``mergify-ci::scopes_send``: - Repository resolution: flag, env fallback, error - Pull-request resolution: explicit, from event JSON, missing - JSON file parsing (DetectedScope shape) - Text file parsing (trims + strips blanks) - End-to-end wiremock: combined scopes from all three sources - End-to-end wiremock: deprecated ``--file`` emits warning - End-to-end wiremock: skip-on-no-PR early-out ``PORT_STATUS.toml`` flips ``ci scopes-send`` from ``shimmed`` to ``native``. The port-guard test stays green. Binary size: 8.3 MB → 8.4 MB. 51 Rust tests total. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Change-Id: I7ff9df90791786c3c26f8159249d91093ba34ec1
75fad04 to
04d71cb
Compare
ca1ea46 to
3f54bf1
Compare
First
cicommand to go native. Straight HTTP POST to Mergifycarrying the scopes detected for a pull request, no new
infrastructure needed beyond what the config pilot already
established.
What ports natively
mergify ci scopes-send [-r REPO] [-p NUMBER] [-t TOKEN] [-u URL] [-s SCOPE...] [--scopes-json FILE] [--scopes-file FILE]:--repositoryflag →GITHUB_REPOSITORYenv → error.
--pull-requestflag →GITHUB_EVENT_PATHJSON (.pull_request.number) →None.When
Nonethe command prints a skip message to stderr andreturns 0 — matches Python's "no PR, nothing to send".
--tokenflag →MERGIFY_TOKEN→GITHUB_TOKEN→ error.--api-urlflag →MERGIFY_API_URL→https://api.mergify.com.--scoperepeated flags,--scopes-json(PydanticDetectedScopedump),--scopes-file(plain text).{"scopes": [...]}to/v1/repos/<repo>/pulls/<number>/scopesvia the HTTP client.--fileis a hidden deprecated alias for--scopes-json.When used, the command prints a deprecation warning to stderr
and proceeds — matches Python's
click.echo(..., err=True).Layout
New
mergify-cicrate undercrates/. Thescopes_sendmodule is self-contained (duplicates
resolve_token/resolve_api_urlfrommergify-config::simulatefor now —they factor into
mergify-corein a follow-up refactor PRonce another command needs them).
The binary's dispatch gains a
Cisubcommand group, withscopes-sendas its only native variant today. Everything elseunder
ci(git-refs,scopes,scopes-sendsiblings)still falls through to the Python shim. The native-intent
heuristic in
detect_nativenow recognizes both theconfigand
ciprefixes.Tests
11 new unit tests in
mergify-ci::scopes_send:--fileemits warningPORT_STATUS.tomlflipsci scopes-sendfromshimmedtonative. The port-guard test stays green.Binary size: 8.3 MB → 8.4 MB. 51 Rust tests total.
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
Depends-On: #1322