fix(rust): honor Buildkite/CircleCI/Jenkins env in ci scopes-send#1365
Merged
mergify[bot] merged 1 commit intoMay 5, 2026
Conversation
Contributor
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟠 🤖 Continuous IntegrationWaiting for:
Waiting checks:
|
There was a problem hiding this comment.
Pull request overview
This PR updates the Rust implementation of mergify ci scopes-send to resolve repository and pull request information from multiple CI providers (Buildkite/CircleCI/Jenkins) in a way that matches the Python CLI behavior, making the command usable outside GitHub Actions.
Changes:
- Add CI-provider detection and provider-specific repository resolution (Buildkite/CircleCI/Jenkins) with URL parsing support.
- Add Buildkite-specific pull request number resolution (
BUILDKITE_PULL_REQUEST) with edge-case handling (false/empty). - Harden tests by clearing all CI-related env vars before applying per-test overrides; add new tests for the new resolver behavior and URL parsing.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
789f791 to
87dba74
Compare
Member
Author
Revision history
|
87dba74 to
a234636
Compare
The Python ``ci scopes-send`` resolves the repository and PR number through ``detector.get_github_repository`` / ``get_github_pull_request_number``, which match ``get_ci_provider()`` and consult provider-specific env vars (``BUILDKITE_REPO`` / ``BUILDKITE_PULL_REQUEST``, ``CIRCLE_REPOSITORY_URL``, ``GIT_URL``). The Rust port only read ``GITHUB_REPOSITORY`` and ``GITHUB_EVENT_PATH``, so on Buildkite it errored on missing ``--repository`` (no ``GITHUB_REPOSITORY``) or silently skipped because no PR number was detected — making ``mergify ci scopes-send`` unusable outside GitHub Actions. Mirror the relevant slice of ``mergify_cli/ci/detector.py`` as a new ``mergify_ci::detector`` module so both languages share the same provider-detection contract: - ``CIProvider`` enum + ``get_ci_provider()`` mirror Python's ``CIProviderT`` and the Jenkins → GitHub Actions → CircleCI → Buildkite ordering. - ``get_github_repository()`` returns ``GITHUB_REPOSITORY`` on GHA and parses ``BUILDKITE_REPO`` / ``CIRCLE_REPOSITORY_URL`` / ``GIT_URL`` for the other providers via a ``parse_repository_url`` helper that recognizes SSH (``git@host:owner/repo[.git]``), HTTP(S), and bare ``owner/repo`` shapes — matching the regex pair in Python's ``_get_github_repository_from_env``. - ``get_github_pull_request_number()`` reads the GitHub event payload on GHA and parses ``BUILDKITE_PULL_REQUEST`` (treating empty / ``false`` as "no PR") on Buildkite. Per-command consumption stays narrow: ``scopes_send`` now delegates to ``detector::get_github_repository`` / ``get_github_pull_request_number`` and only retains the explicit-flag precedence + error wrapping. Other Python detector helpers (``get_pipeline_name``, ``get_head_sha``, ``get_cicd_pipeline_run_*``, ``get_base_ref_name``, …) feed ``junit_processing`` and ``ci git-refs`` — neither is ported to Rust yet, so nothing to mirror until those commands land. Tests now clear every CI-provider env var the detector inspects via a shared ``with_ci_env`` helper before applying per-test overrides, so they no longer inherit provider state from the host (e.g. Buildkite's own CI). Detector tests cover provider precedence, repo URL parsing across SSH/HTTPS/bare shapes, and Buildkite PR resolution edge cases. 26/26 tests green; clippy clean. Fixes INC-1357 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Change-Id: I0fc56c75450b9072380e9f1ea4e83fa01f308f6b
a234636 to
54c69c3
Compare
jd
approved these changes
May 5, 2026
JulianMaurin
approved these changes
May 5, 2026
Contributor
Merge Queue Status
This pull request spent 14 seconds in the queue, including 3 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.
The Python
ci scopes-sendresolves the repository and PR numberthrough
detector.get_github_repository/get_github_pull_request_number, which matchget_ci_provider()and consult provider-specific env vars(
BUILDKITE_REPO/BUILDKITE_PULL_REQUEST,CIRCLE_REPOSITORY_URL,GIT_URL). The Rust port only readGITHUB_REPOSITORYandGITHUB_EVENT_PATH, so on Buildkite iterrored on missing
--repository(noGITHUB_REPOSITORY) orsilently skipped because no PR number was detected — making
mergify ci scopes-sendunusable outside GitHub Actions.This brings the Rust resolver in line:
detect_ci_providermirrors the Python provider order(Jenkins → GitHub Actions → CircleCI → Buildkite).
resolve_repositorybranches on the detected provider andparses
BUILDKITE_REPO/CIRCLE_REPOSITORY_URL/GIT_URLvia a newparse_repo_from_urlhelper thatrecognizes SSH (
git@host:owner/repo[.git]), HTTP(S), andbare
owner/reposhapes — matching the regex pair in_get_github_repository_from_env.GITHUB_REPOSITORYstaysas the GHA + no-provider fallback.
resolve_pull_requestreadsBUILDKITE_PULL_REQUESTonBuildkite (treating empty /
falseas "no PR"); theGitHub-event-path branch is unchanged otherwise.
Tests now clear every CI-provider env var the resolver inspects via
a shared
with_ci_env/with_ci_env_asynchelper beforeapplying per-test overrides, so they no longer inherit
provider state from the host (e.g. Buildkite's own CI). Adds 10
new tests covering Buildkite / CircleCI / Jenkins repo resolution,
Buildkite PR resolution edge cases (false / unset / number), and
parse_repo_from_urlshape coverage. 23/23 tests green; clippyclean.
Other recent
detector.pyadditions (get_cicd_pipeline_run_url,get_base_ref_name,get_repository_url, 1-basedBUILDKITE_RETRY_COUNT) feedjunit_processingandci git-refs; neither is ported to Rust on this branch yet, sonothing to align there.
Fixes INC-1357
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com