Skip to content

fix(ci-insights): Use base branch presence as PR indicator for mode selection#392

Merged
mergify[bot] merged 1 commit intomainfrom
devs/remyduthu/remyduthu/mrgfy-6820-mode-selection-uses-base-branch-too-broadly/I25975a8cfe61b7d51aa28ec9a5ade3701dcc8aac
Apr 3, 2026
Merged

fix(ci-insights): Use base branch presence as PR indicator for mode selection#392
mergify[bot] merged 1 commit intomainfrom
devs/remyduthu/remyduthu/mrgfy-6820-mode-selection-uses-base-branch-too-broadly/I25975a8cfe61b7d51aa28ec9a5ade3701dcc8aac

Conversation

@remyduthu
Copy link
Copy Markdown
Contributor

@remyduthu remyduthu commented Apr 3, 2026

The mode selection between 'new' and 'unhealthy' was using branch_name
presence, which derived from BASE with HEAD fallback. Since HEAD is
almost always available (via GITHUB_REF_NAME), scheduled/push runs
incorrectly selected 'new' mode.

Fixes: MRGFY-6820

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

Copilot AI review requested due to automatic review settings April 3, 2026 08:01
@mergify
Copy link
Copy Markdown

mergify bot commented Apr 3, 2026

Merge Protections

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

🟢 Approval

Wonderful, this rule succeeded.
  • #approved-reviews-by >= 2

🟢 Continuous Integration

Wonderful, this rule succeeded.
  • all of:
    • check-success = codespell
    • check-success = test (3.10)
    • check-success = test (3.11)
    • check-success = test (3.12)
    • check-success = test (3.13)
    • check-success = test (3.14)
    • check-success = test (3.8)
    • check-success = test (3.9)

🟢 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)(?:\(.+\))?:

🟢 🔎 Reviews

Wonderful, this rule succeeded.
  • #changes-requested-reviews-by = 0
  • #review-requested = 0
  • #review-threads-unresolved = 0

🟢 📕 PR description

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

@mergify mergify bot had a problem deploying to Mergify Merge Protections April 3, 2026 08:01 Failure
@remyduthu remyduthu self-assigned this Apr 3, 2026
@mergify mergify bot requested a review from a team April 3, 2026 08:02
@remyduthu remyduthu marked this pull request as ready for review April 3, 2026 08:03
@remyduthu remyduthu force-pushed the devs/remyduthu/remyduthu/mrgfy-6820-mode-selection-uses-base-branch-too-broadly/I25975a8cfe61b7d51aa28ec9a5ade3701dcc8aac branch from 0667906 to aaa2d58 Compare April 3, 2026 08:04
@mergify mergify bot had a problem deploying to Mergify Merge Protections April 3, 2026 08:04 Failure
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

Fixes CI Insights “mode” selection so flaky detection uses new mode only in PR contexts and unhealthy mode for push/scheduled runs, avoiding incorrect new mode selection when only HEAD refs are available.

Changes:

  • Update MergifyCIInsights to select flaky-detector mode based on presence of a PR base ref attribute.
  • Refactor _load_flaky_detector() to accept an explicit mode argument.
  • Adjust CI Insights tests to model PR vs push/scheduled environments using GITHUB_BASE_REF and GITHUB_REF_NAME.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
pytest_mergify/ci_insights.py Passes an explicit flaky-detector mode chosen from resource attributes rather than relying on branch_name presence.
tests/test_ci_insights.py Updates test env setup to simulate PR vs non-PR contexts via GitHub Actions ref env vars.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pytest_mergify/ci_insights.py
Comment thread pytest_mergify/ci_insights.py Outdated
Comment thread tests/test_ci_insights.py
…election

The mode selection between 'new' and 'unhealthy' was using branch_name
presence, which derived from BASE with HEAD fallback. Since HEAD is
almost always available (via GITHUB_REF_NAME), scheduled/push runs
incorrectly selected 'new' mode.

Fixes: MRGFY-6820

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Change-Id: I25975a8cfe61b7d51aa28ec9a5ade3701dcc8aac
@remyduthu remyduthu force-pushed the devs/remyduthu/remyduthu/mrgfy-6820-mode-selection-uses-base-branch-too-broadly/I25975a8cfe61b7d51aa28ec9a5ade3701dcc8aac branch from aaa2d58 to 1c0965b Compare April 3, 2026 08:17
@mergify mergify bot deployed to Mergify Merge Protections April 3, 2026 08:18 Active
Copy link
Copy Markdown
Contributor

@JulianMaurin JulianMaurin left a comment

Choose a reason for hiding this comment

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

For push/schedule runs where GITHUB_BASE_REF="" is present in the environment, get_attributes will include VCS_REF_BASE_NAME="" in the resource. The branch_name derivation:
branch_name = resource.attributes.get(VCS_REF_BASE_NAME, resource.attributes.get(VCS_REF_HEAD_NAME))
would return "" instead of falling through to HEAD. This makes self.branch_name = "" (falsy), which means quarantine won't load for push runs even when a HEAD ref is available. This is out of scope for this PR
but worth a follow-up if quarantine is expected to work on push/schedule.

@remyduthu
Copy link
Copy Markdown
Contributor Author

For push/schedule runs where GITHUB_BASE_REF="" is present in the environment, get_attributes will include VCS_REF_BASE_NAME="" in the resource. The branch_name derivation: branch_name = resource.attributes.get(VCS_REF_BASE_NAME, resource.attributes.get(VCS_REF_HEAD_NAME)) would return "" instead of falling through to HEAD. This makes self.branch_name = "" (falsy), which means quarantine won't load for push runs even when a HEAD ref is available. This is out of scope for this PR but worth a follow-up if quarantine is expected to work on push/schedule.

Nice catch! I'll push another fix.

@remyduthu remyduthu requested a review from a team April 3, 2026 09:09
@remyduthu
Copy link
Copy Markdown
Contributor Author

This pull request is part of a stack:

  1. fix(ci-insights): Use base branch presence as PR indicator for mode selection (#392) 👈
  2. fix(ci-insights): Handle empty base ref in branch name derivation (#393)

@mergify
Copy link
Copy Markdown

mergify bot commented Apr 3, 2026

Merge Queue Status

  • Entered queue2026-04-03 11:22 UTC · Rule: default
  • Checks skipped · PR is already up-to-date
  • Merged2026-04-03 11:23 UTC · at 1c0965b4211b3ca2341606b9fb0ed7b6d1e12fe7

This pull request spent 24 seconds in the queue, including 1 second running CI.

Required conditions to merge

@mergify mergify bot added the queued label Apr 3, 2026
@mergify mergify bot merged commit 9b937c5 into main Apr 3, 2026
21 checks passed
@mergify mergify bot deleted the devs/remyduthu/remyduthu/mrgfy-6820-mode-selection-uses-base-branch-too-broadly/I25975a8cfe61b7d51aa28ec9a5ade3701dcc8aac branch April 3, 2026 11:23
@mergify mergify bot removed the queued label Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants