Skip to content

feat(ci-insights): Add mergify ci tests lookup command#1382

Open
remyduthu wants to merge 1 commit intomainfrom
devs/remyduthu/tests-lookup-cli/add-mergify-ci-tests-lookup-cmd--afe28649
Open

feat(ci-insights): Add mergify ci tests lookup command#1382
remyduthu wants to merge 1 commit intomainfrom
devs/remyduthu/tests-lookup-cli/add-mergify-ci-tests-lookup-cmd--afe28649

Conversation

@remyduthu
Copy link
Copy Markdown
Contributor

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

Copilot AI review requested due to automatic review settings May 6, 2026 13:56
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 6, 2026 13:56 Failure
@remyduthu remyduthu self-assigned this May 6, 2026
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 6, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🔴 🤖 Continuous Integration

Waiting for

  • check-success=ci-gate
This rule is failing.
  • all of:
    • check-success=ci-gate

🔴 👀 Review Requirements

Waiting for

  • #approved-reviews-by>=2
This rule is failing.
  • any of:
    • #approved-reviews-by>=2
    • author = dependabot[bot]
    • author = mergify-ci-bot
    • author = renovate[bot]

🔴 🔎 Reviews

Waiting for

  • #review-requested = 0
  • #review-threads-unresolved = 0
This rule is failing.
  • #review-requested = 0
  • #review-threads-unresolved = 0
  • #changes-requested-reviews-by = 0

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert|ui)(?:\(.+\))?:

🟢 📕 PR description

Wonderful, this rule succeeded.
  • body ~= (?ms:.{48,})

@remyduthu remyduthu changed the title feat(rust): Add mergify ci tests lookup command feat(ci-insights): Add mergify ci tests lookup command May 6, 2026
@remyduthu remyduthu force-pushed the devs/remyduthu/tests-lookup-cli/add-mergify-ci-tests-lookup-cmd--afe28649 branch from 6544154 to 57267f7 Compare May 6, 2026 13:56
@remyduthu
Copy link
Copy Markdown
Contributor Author

remyduthu commented May 6, 2026

Revision history

# Type Changes Date
1 initial 6544154 2026-05-06 13:56 UTC
2 rebase 6544154 → 57267f7 2026-05-06 13:56 UTC
3 content 57267f7 → 3d1d1d8 2026-05-06 14:38 UTC

@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 6, 2026 13:57 Failure
@remyduthu remyduthu marked this pull request as ready for review May 6, 2026 14:00
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_query to 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('/') {
Comment on lines +378 to +380
/// Repository full name (owner/repo).
#[arg(long, short = 'r', required = true)]
repository: String,
Comment on lines +88 to +92
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}"
)

@mergify mergify Bot requested a review from a team May 6, 2026 14:10
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
@remyduthu remyduthu force-pushed the devs/remyduthu/tests-lookup-cli/add-mergify-ci-tests-lookup-cmd--afe28649 branch from 57267f7 to 3d1d1d8 Compare May 6, 2026 14:38
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 6, 2026 14:39 Failure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants