Commit 1c79bf4
feat(rust): port ci scopes-send to native Rust (Phase 1.4)
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: I7ff9df90791786c3c26f8159249d91093ba34ec11 parent 800a454 commit 1c79bf4
9 files changed
Lines changed: 674 additions & 233 deletions
File tree
- crates
- mergify-ci
- src
- mergify-cli
- src
- mergify_cli
- ci
- tests/ci
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | 50 | | |
55 | 51 | | |
56 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
0 commit comments