feat(ci-insights): Add mergify ci tests lookup command#1382
feat(ci-insights): Add mergify ci tests lookup command#1382
mergify ci tests lookup command#1382Conversation
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🔴 🤖 Continuous IntegrationWaiting for
This rule is failing.
🔴 👀 Review RequirementsWaiting for
This rule is failing.
🔴 🔎 ReviewsWaiting for
This rule is failing.
🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 📕 PR descriptionWonderful, this rule succeeded.
|
mergify ci tests lookup commandmergify ci tests lookup command
6544154 to
57267f7
Compare
Revision history
|
There was a problem hiding this comment.
Pull request overview
Adds a new native Rust mergify ci tests lookup command to batch-resolve CI Insights test identities by name (glob-aware), fetch per-test health/metrics, and render either human output or a single JSON payload. This extends the Rust-native mergify ci surface area and introduces a reusable HTTP helper for ordered/repeated query parameters.
Changes:
- Add
mergify ci tests lookup NAME...command (CLI wiring, API calls, rendering, exit-code aggregation, and unit tests). - Add
HttpClient::get_with_queryto support ordered/repeated query params with proper encoding. - Update docs and add a live smoke test exercising the lookup endpoint.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| skills/mergify-ci/SKILL.md | Documents the new ci tests lookup command, options, and exit codes. |
| README.md | Mentions test health inspection under the mergify ci command group. |
| func-tests/test_live_smoke.py | Adds a live smoke test for the lookup endpoint (no-match path). |
| crates/mergify-core/src/http.rs | Introduces get_with_query plus unit tests for ordering/encoding behavior. |
| crates/mergify-cli/src/main.rs | Adds clap subcommand plumbing + native dispatch for ci tests lookup and JSON mode selection. |
| crates/mergify-ci/src/tests_lookup.rs | Implements lookup + details fan-out, rendering, JSON payload, exit code policy, and tests. |
| crates/mergify-ci/src/lib.rs | Exposes the new tests_lookup module. |
| crates/mergify-ci/src/detector.rs | Adds split_owner_repo helper with tests. |
| crates/mergify-ci/Cargo.toml | Adds Rust deps needed by the new command (chrono, futures). |
| Cargo.lock | Lockfile updates for newly introduced/updated dependencies. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| )) | ||
| }; | ||
| let (owner, repo) = value.split_once('/').ok_or_else(mismatch)?; | ||
| if owner.is_empty() || repo.is_empty() || repo.contains('/') { |
| /// Repository full name (owner/repo). | ||
| #[arg(long, short = 'r', required = true)] | ||
| repository: String, |
| assert result.returncode == 0, f"stdout:\n{result.stdout}\nstderr:\n{result.stderr}" | ||
| assert '"tests"' in result.stdout, ( | ||
| f"expected JSON payload with `tests` key on stdout, got:\n{result.stdout}" | ||
| ) | ||
|
|
Wraps two CI Insights endpoints into a single batch command:
- `GET /v1/ci/{owner}/repositories/{repo}/tests/lookup` resolves test
identities by name (glob-aware) on the default branch.
- `GET /v1/ci/{owner}/repositories/{repo}/tests/{test_id}` returns the
full health/metrics payload for one identity.
The lookup is a true batch API — pass one or more `<NAME>` positionals
(globs allowed) and one block per match is rendered. `--json` emits a
single `{"tests": [...]}` document; the human renderer hides metadata
lines for absent fields rather than printing placeholders. Exit code
reflects the worst health observed across results (0 = healthy or
unknown, 1 = any flaky, 6 = any broken).
Token and API URL resolution moved from `scopes_send.rs` into a new
`common.rs` so every Mergify-targeting `ci` subcommand shares the same
explicit-flag → env-var → default fallback chain. `split_owner_repo`
moved into `detector.rs` next to the existing `owner/repo` validators.
A new `HttpClient::get_with_query` helper percent-encodes values and
preserves repeated keys in caller order, which the lookup endpoint
relies on for `test_name` repetition.
Also adds a live-smoke case that exercises the lookup endpoint with a
guaranteed-nonexistent name so the round-trip stays independent of
canary repository state.
Fixes: MRGFY-7166
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Change-Id: Iafe286495b7842079e9c63b437a6305926fc22a5
57267f7 to
3d1d1d8
Compare
Wraps two CI Insights endpoints into a single batch command:
GET /v1/ci/{owner}/repositories/{repo}/tests/lookupresolves testidentities by name (glob-aware) on the default branch.
GET /v1/ci/{owner}/repositories/{repo}/tests/{test_id}returns thefull health/metrics payload for one identity.
The lookup is a true batch API — pass one or more
<NAME>positionals(globs allowed) and one block per match is rendered.
--jsonemits asingle
{"tests": [...]}document; the human renderer hides metadatalines for absent fields rather than printing placeholders. Exit code
reflects the worst health observed across results (0 = healthy or
unknown, 1 = any flaky, 6 = any broken).
Token and API URL resolution moved from
scopes_send.rsinto a newcommon.rsso every Mergify-targetingcisubcommand shares the sameexplicit-flag → env-var → default fallback chain.
split_owner_repomoved into
detector.rsnext to the existingowner/repovalidators.A new
HttpClient::get_with_queryhelper percent-encodes values andpreserves repeated keys in caller order, which the lookup endpoint
relies on for
test_namerepetition.Also adds a live-smoke case that exercises the lookup endpoint with a
guaranteed-nonexistent name so the round-trip stays independent of
canary repository state.
Fixes: MRGFY-7166
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com