feat(rust): port ci git-refs and ci queue-info to native Rust#1353
Conversation
Member
Author
|
This pull request is part of a Mergify stack:
|
This was referenced May 5, 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.
|
253835c to
1ae9f28
Compare
0ca3459 to
9d6db8e
Compare
Member
Author
Revision history
|
9d6db8e to
a2714b7
Compare
1ae9f28 to
1670fa1
Compare
a2714b7 to
742d92c
Compare
1670fa1 to
8afcb9c
Compare
742d92c to
839ea5a
Compare
839ea5a to
4ddd589
Compare
7e85a94 to
9478efd
Compare
4ddd589 to
3df5705
Compare
9478efd to
12bc871
Compare
3df5705 to
0349b1d
Compare
12bc871 to
8485cd1
Compare
0349b1d to
c3fc948
Compare
mergify Bot
pushed a commit
that referenced
this pull request
May 6, 2026
#1357) The 2026.5.5.x release shipped a ``ci scopes-send`` regression (fixed in #1356): the Rust port deserialized the response body via ``let _: serde_json::Value = client.post(...)`` while the Python original ignored the body, and the Mergify endpoint returns an empty body on success. ``Value`` still requires valid JSON, so the Rust version surfaced ``parse response JSON: error decoding response body`` to every user once it shipped. Test mocks used ``set_body_json(json!({}))`` instead of an empty body, so the bug hid through unit tests too. The fix is structural — split the HTTP client so callers pick ``post`` (parses) vs ``post_no_response`` (drops) up front — but the bug class is broader than this one command. Capturing the lessons in AGENTS.md so the next porter (human or assistant) walks through them before opening a PR. Three categories of pitfall, all observed during the port so far: 1. **HTTP response handling** — match the Python original. If Python ignores the response, Rust must use ``post_no_response`` etc.; if Python parses, optional/nullable fields must be ``Option<T>`` + ``#[serde(default)]``. 2. **Test fixtures** — mirror the real server. ``ResponseTemplate`` bodies must match what the endpoint actually returns; an empty body is not the same as ``json!({})``. 3. **UX parity with click** — char-counted validators use ``chars().count()`` (not ``len()``); confirmation prompts go to stderr; resolve all required state before prompting. Audit of existing/in-flight ports against the checklist: - ``config validate``, ``config simulate`` (main): match - ``ci scopes-send`` (main): regressed, fix in #1356 - ``queue pause`` / ``unpause`` (#1352): match - ``ci git-refs`` / ``queue-info`` (#1353): no HTTP, no risk Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
c3fc948 to
6421363
Compare
This was referenced May 6, 2026
6421363 to
ece765d
Compare
01e7be5 to
dd391d3
Compare
ece765d to
cc96b9a
Compare
Adds `github_event` (GitHub Actions event payload deserialization) and `queue_metadata` (MQ YAML fenced-block extraction) shared modules to the mergify-ci crate, and ports two commands on top of them: - `ci queue-info` — prints MQ batch metadata as pretty JSON; errors INVALID_STATE (exit 7) outside an MQ context. Appends to `$GITHUB_OUTPUT` with the same `ghadelimiter_<uuid>` heredoc the Python version uses. - `ci git-refs` — detects base/head refs from Buildkite env, GitHub event payload, `refs/notes/mergify/<branch>` git notes, MQ PR body, or falls back to `HEAD^..HEAD`. Supports `text`/`shell`/`json` output formats, writes `base`/`head` to `$GITHUB_OUTPUT`, and calls `buildkite-agent meta-data set` when `BUILDKITE=true`. The notes reader is injected as a trait-object callback so unit tests can exercise the note-driven detection path without touching a real git repository; the production path shells out via `real_notes_reader`. The Python implementations of `ci git-refs` and `ci queue-info` are removed in the same PR — the Rust binary now owns both commands end-to-end. The looks-native heuristic in `main.rs` learns the two new subcommand names so argv errors surface as clap exit 2 instead of silently falling through to the Python shim. Adds `serde_yaml_ng` (YAML parser) and `uuid` (ghadelimiter) deps to the mergify-ci crate. Binary grows ~100KB to 8.6MB. 19 new Rust tests (8 event/metadata, 3 queue-info, 12 git-refs + 2 format round-trips merged in). Full workspace: 79 tests green, compat harness 4/4. Change-Id: I8d3f96e6cb4eb51e6cd195951b3e622cee7efdd4
cc96b9a to
45c9d93
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.
Adds
github_event(GitHub Actions event payload deserialization) andqueue_metadata(MQ YAML fenced-block extraction) shared modules to themergify-ci crate, and ports two commands on top of them:
ci queue-info— prints MQ batch metadata as pretty JSON; errorsINVALID_STATE (exit 7) outside an MQ context. Appends to
$GITHUB_OUTPUTwith the sameghadelimiter_<uuid>heredoc thePython version uses.
ci git-refs— detects base/head refs from Buildkite env, GitHubevent payload,
refs/notes/mergify/<branch>git notes, MQ PR body,or falls back to
HEAD^..HEAD. Supportstext/shell/jsonoutput formats, writes
base/headto$GITHUB_OUTPUT, and callsbuildkite-agent meta-data setwhenBUILDKITE=true.The notes reader is injected as a trait-object callback so unit tests
can exercise the note-driven detection path without touching a real
git repository; the production path shells out via
real_notes_reader.The Python implementations of
ci git-refsandci queue-infoareremoved in the same PR — the Rust binary now owns both commands
end-to-end. The looks-native heuristic in
main.rslearns the twonew subcommand names so argv errors surface as clap exit 2 instead
of silently falling through to the Python shim.
Adds
serde_yaml_ng(YAML parser) anduuid(ghadelimiter) deps tothe mergify-ci crate. Binary grows ~100KB to 8.6MB.
19 new Rust tests (8 event/metadata, 3 queue-info, 12 git-refs + 2
format round-trips merged in). Full workspace: 79 tests green,
compat harness 4/4.
Depends-On: #1352