feat(rust): port config simulate to native Rust (Phase 1.3b)#1298
Conversation
Member
Author
|
This pull request is part of a Mergify stack:
|
This was referenced Apr 23, 2026
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.
|
This was referenced Apr 23, 2026
2a502cd to
e4397c6
Compare
Member
Author
Revision history
|
e4397c6 to
6dee3f1
Compare
cb257f5 to
44fc353
Compare
6dee3f1 to
cc09d55
Compare
cc09d55 to
f5f004a
Compare
Completes the config pilot. Second native command, flipped in PORT_STATUS.toml from ``shimmed`` to ``native``. ## What ports natively ``mergify config simulate PULL_REQUEST_URL [-f PATH] [-t TOKEN] [-u URL]``: 1. Parses the PR URL into ``(owner/repo, number)``. Invalid URLs are rejected by clap's ``value_parser``, which exits 2 (matching Python's ``click.BadParameter``). 2. Resolves the config file (same three-location search as ``config validate`` — shared helper in ``paths.rs``). 3. Reads the YAML as a raw string (no parsing — the simulator API accepts the text verbatim). 4. Resolves the bearer token: explicit ``--token`` → ``MERGIFY_TOKEN`` → ``GITHUB_TOKEN`` → error. Matches Python's precedence; the ``gh auth token`` subprocess fallback isn't ported yet. 5. Resolves the API URL: explicit ``--api-url`` → ``MERGIFY_API_URL`` → ``https://api.mergify.com`` default. 6. POSTs ``{"mergify_yml": <content>}`` to ``/v1/repos/<repo>/pulls/<number>/simulator`` via the 1.2b HTTP client (auth + retry + typed errors). 7. Prints the returned title + summary to stdout. Rich Markdown rendering of ``summary`` is deliberately deferred — we print raw Markdown today. Human output drift is allowed by the compat contract; machine-readable paths aren't affected because ``config simulate`` has no ``--json`` flag in Python either. ## Dispatch ``mergify-cli/src/main.rs`` now carries two clap subcommands (``validate`` + ``simulate``). The dispatch logic got a light reshape: on clap parse failure we distinguish "obvious native intent" (argv contains ``config`` + one of ``validate``/``simulate``) from "unrecognized command, fall through". Native-intent parse errors surface clap's formatted error and exit 2; anything else falls through to the Python shim so unported commands keep working. ## Refactor The config-path resolver moved from ``validate.rs`` into a shared ``paths.rs`` module so both commands share a single source of truth for the ``[".mergify.yml", ".mergify/config.yml", ".github/mergify.yml"]`` search list. ## Tests 24 tests in ``mergify-config`` (up from 11 in Phase 1.3): - 3 for the shared path resolver (moved out of ``validate.rs``) - 6 for PR URL parsing (happy path + 5 rejection cases) - 4 for token resolution (explicit, env fallback, error) - 2 for API URL resolution - 1 end-to-end wiremock test: POST + JSON body + auth header + response rendering Covered by the port-inventory guard: ``PORT_STATUS.toml`` flips ``config simulate`` from ``shimmed`` to ``native``. Binary size: 8.0 MB → 8.3 MB (small bump from simulate.rs). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Change-Id: If9194bb015c12c14cf71a9e831c4e1d67391793e
f5f004a to
d7398e1
Compare
9e9ef12 to
6def985
Compare
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.
Completes the config pilot. Second native command, flipped in
PORT_STATUS.toml from
shimmedtonative.What ports natively
mergify config simulate PULL_REQUEST_URL [-f PATH] [-t TOKEN] [-u URL]:(owner/repo, number). Invalid URLsare rejected by clap's
value_parser, which exits 2 (matchingPython's
click.BadParameter).config validate— shared helper inpaths.rs).accepts the text verbatim).
--token→MERGIFY_TOKEN→
GITHUB_TOKEN→ error. Matches Python's precedence; thegh auth tokensubprocess fallback isn't ported yet.--api-url→MERGIFY_API_URL→
https://api.mergify.comdefault.{"mergify_yml": <content>}to/v1/repos/<repo>/pulls/<number>/simulatorvia the 1.2b HTTPclient (auth + retry + typed errors).
Rich Markdown rendering of
summaryis deliberately deferred —we print raw Markdown today. Human output drift is allowed by the
compat contract; machine-readable paths aren't affected because
config simulatehas no--jsonflag in Python either.Dispatch
mergify-cli/src/main.rsnow carries two clap subcommands(
validate+simulate). The dispatch logic got a lightreshape: on clap parse failure we distinguish "obvious native
intent" (argv contains
config+ one ofvalidate/simulate)from "unrecognized command, fall through". Native-intent parse
errors surface clap's formatted error and exit 2; anything else
falls through to the Python shim so unported commands keep working.
Refactor
The config-path resolver moved from
validate.rsinto a sharedpaths.rsmodule so both commands share a single source oftruth for the
[".mergify.yml", ".mergify/config.yml", ".github/mergify.yml"]search list.Tests
24 tests in
mergify-config(up from 11 in Phase 1.3):validate.rs)response rendering
Covered by the port-inventory guard:
PORT_STATUS.tomlflipsconfig simulatefromshimmedtonative.Binary size: 8.0 MB → 8.3 MB (small bump from simulate.rs).
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
Depends-On: #1297