feat(rust): port ci scopes-send to native Rust (Phase 1.4)#1300
Conversation
Member
Author
|
This pull request is part of a Mergify stack:
|
This was referenced Apr 23, 2026
Contributor
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.
|
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
2a502cd to
e4397c6
Compare
86a41aa to
0bbac0d
Compare
Member
Author
Revision history
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: #1298