feat(rust): port config validate to native Rust (Phase 1.3)#1282
Merged
mergify[bot] merged 1 commit intomainfrom Apr 28, 2026
Conversation
Member
Author
|
This pull request is part of a Mergify stack:
|
This was referenced Apr 21, 2026
Contributor
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 🤖 Continuous IntegrationWonderful, this rule succeeded.
🟢 👀 Review RequirementsWonderful, this rule succeeded.
🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 🔎 ReviewsWonderful, this rule succeeded.
🟢 📕 PR descriptionWonderful, this rule succeeded.
|
08627d5 to
8b898c2
Compare
Member
Author
Revision history
|
8b898c2 to
6ee2535
Compare
1343a0a to
76c0440
Compare
6ee2535 to
538f82f
Compare
76c0440 to
1b2f0d8
Compare
538f82f to
e20964f
Compare
e20964f to
bdfd8c0
Compare
This was referenced Apr 23, 2026
bdfd8c0 to
1bccca9
Compare
db76eee to
e40a308
Compare
e40a308 to
ce71a83
Compare
ce71a83 to
6470fc5
Compare
Base automatically changed from
devs/jd/worktree-rust-port/add-mergify-core-http-retry-typed-errors-phase-1--9c66057c
to
main
April 28, 2026 09:07
Contributor
|
@jd this pull request is now in conflict 😩 |
sileht
previously approved these changes
Apr 28, 2026
kozlek
previously approved these changes
Apr 28, 2026
First native command. Exercises every piece of the foundations work so far — HTTP fetch, JSON-schema validation, output discipline, typed exit codes — and proves the shim-fallback dispatch pattern. ## What ports natively ``mergify config validate [-f PATH]``: 1. Resolves the config file (explicit ``--config-file`` or the first of ``.mergify.yml``, ``.mergify/config.yml``, ``.github/mergify.yml``). 2. Parses it as YAML via ``serde_norway``. Empty files are treated as an empty mapping; non-mapping top-level values are rejected. 3. Fetches the published schema from ``https://docs.mergify.com/mergify-configuration-schema.json`` via the Phase 1.2b HTTP client (30s timeout, retry on 5xx). 4. Validates with the ``jsonschema`` crate (draft-07). 5. Emits a human-readable success line or a sorted, path-prefixed per-error list via ``Output::emit``. Exit codes: success → 0, missing / unparseable / schema violations → 8 (``CONFIGURATION_ERROR``), schema-fetch failure → 6 (``MERGIFY_API_ERROR``). ## Dispatch ``mergify-cli/src/main.rs`` inspects argv for a ``config validate`` pair; if present, it parses with clap and runs the native path. Everything else — including ``config simulate``, every ``stack`` command, the global ``--version`` / ``--help``, plus any invalid invocation — falls through to the Python shim unchanged. Clap is loaded only when a native match is suspected, so unknown flags on un-ported commands still produce Python's click error messages verbatim. ## Smoke-tested against the real docs CDN Missing config → exit 8. Valid config → exit 0. Invalid config → detailed error list + summary, exit 8. ``mergify --version`` still falls through to Python. ## Test coverage 11 unit tests in ``mergify-config``: - ``resolve_config_path`` with explicit, default, and missing paths - ``load_yaml`` happy path, scalar rejection, malformed YAML, empty-file-is-empty-mapping - ``validate_against_schema`` happy path + error aggregation - ``emit_result`` for success and failure rendering ## Binary size 2.7 MB → 8.0 MB. The jump is jsonschema pulling fancy-regex + the referencing crate's schema resolver. Still well under the 15 MB design target; we can trim with features later if needed. ## Follow-up - 1.3b: port ``config simulate`` - 1.4+: ``ci`` commands (first CI-facing wins for the port story) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Change-Id: I52ffe9eb817c1879c467c22e2827cbe4c0a4e327
6470fc5 to
a286dbf
Compare
Pull request has been modified.
kozlek
approved these changes
Apr 28, 2026
JulianMaurin
approved these changes
Apr 28, 2026
Contributor
Merge Queue Status
This pull request spent 48 seconds in the queue, including 2 seconds running CI. Required conditions to merge
|
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 native command. Exercises every piece of the foundations
work so far — HTTP fetch, JSON-schema validation, output
discipline, typed exit codes — and proves the shim-fallback
dispatch pattern.
What ports natively
mergify config validate [-f PATH]:--config-fileor thefirst of
.mergify.yml,.mergify/config.yml,.github/mergify.yml).serde_norway. Empty files are treatedas an empty mapping; non-mapping top-level values are rejected.
https://docs.mergify.com/mergify-configuration-schema.jsonvia the Phase 1.2b HTTP client (30s timeout, retry on 5xx).
jsonschemacrate (draft-07).per-error list via
Output::emit.Exit codes: success → 0, missing / unparseable / schema violations
→ 8 (
CONFIGURATION_ERROR), schema-fetch failure → 6(
MERGIFY_API_ERROR).Dispatch
mergify-cli/src/main.rsinspects argv for aconfig validatepair; if present, it parses with clap and runs the native path.
Everything else — including
config simulate, everystackcommand, the global
--version/--help, plus any invalidinvocation — falls through to the Python shim unchanged. Clap is
loaded only when a native match is suspected, so unknown flags on
un-ported commands still produce Python's click error messages
verbatim.
Smoke-tested against the real docs CDN
Missing config → exit 8. Valid config → exit 0. Invalid config →
detailed error list + summary, exit 8.
mergify --versionstillfalls through to Python.
Test coverage
11 unit tests in
mergify-config:resolve_config_pathwith explicit, default, and missing pathsload_yamlhappy path, scalar rejection, malformed YAML,empty-file-is-empty-mapping
validate_against_schemahappy path + error aggregationemit_resultfor success and failure renderingBinary size
2.7 MB → 8.0 MB. The jump is jsonschema pulling fancy-regex + the
referencing crate's schema resolver. Still well under the 15 MB
design target; we can trim with features later if needed.
Follow-up
config simulatecicommands (first CI-facing wins for the port story)Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com