Skip to content

fix(ci): reject PR runs after retargeting or target force-push - #3442

Open
ShryukGrandhi wants to merge 1 commit into
apache:masterfrom
ShryukGrandhi:fix/issue-3296-bug-ci-accepts-obsolete-pr-targets-after
Open

ShryukGrandhi wants to merge 1 commit into
apache:masterfrom
ShryukGrandhi:fix/issue-3296-bug-ci-accepts-obsolete-pr-targets-after

Conversation

@ShryukGrandhi

@ShryukGrandhi ShryukGrandhi commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Purpose of the PR

require_current_pr() checked the PR head and the target repository, but not the target branch name or whether the tested base was still part of the target's history. A run planned against master was still accepted after the PR was retargeted to another branch in the same repository, or after the target branch was force-pushed to unrelated history.

Main Changes

  • The plan now records the PR target ref (target, from pull_request.base.ref). PR events without it are rejected as missing identity.
  • require_current_pr() rejects the run when the live base.ref differs from the planned target.
  • It also calls the compare API (compare/<tested base>...<target>) and accepts only ahead or identical. That allows normal target advancement and rejects a rewritten or rewound target. The live base.sha is not used here because GitHub does not update it when the target branch moves.
  • The metadata-outage behavior is unchanged. A failed lookup during planning still falls back to conservative mainline coverage.
  • docs/ci.md freshness section updated.

Verifying these changes

  • Trivial rework / code cleanup without any test coverage. (No Need)
  • Already covered by existing tests, such as (please modify tests here).
  • Need tests and can be verified as follows:
    • python3 .github/scripts/test_ci_policy.py: all 27 tests pass.
    • The real-Git fixture test now covers a retargeted PR (rejected), an advanced target (accepted) and a target force-pushed to unrelated history (rejected). The toolchain gate test covers the retarget and diverged-target cases.
    • With only the ci-policy.py change reverted, the two updated tests fail.

Does this PR potentially affect the following parts?

  • Dependencies (add/update license info & regenerate_known_dependencies.sh)
  • Modify configurations
  • The public API
  • Other affects (typed here): CI planning/gating only. The PR preflight makes one extra read-only gh api compare call, which is covered by the existing contents: read permission.
  • Nope

Documentation Status

  • Doc - TODO: required documentation is pending; complete it before merging.
  • Doc - Done: documentation is included here or linked below.
  • Doc - No Need: no user-visible documentation is affected.

Documentation files in this PR or paired hugegraph-doc PR:

  • docs/ci.md

Visual overview

CI target freshness check

The freshness check now binds the planned target branch name to the live PR target and verifies that the current target history contains the tested base (compare status ahead or identical). Normal target advancement remains allowed; retargeting or loss of the tested base is rejected. A force-push is not rejected merely because it is a force-push. Existing head/source/repository checks and the conservative planning metadata-outage fallback remain in place. This is a mechanism illustration, not evidence that this PR’s CI, performance, or release acceptance passed. Reviewed: 2026-10-31.

Bind the PR plan to its target ref and require the live target branch to
still contain the tested merge base. Normal target advancement is still accepted.

Signed-off-by: ShryukGrandhi <85529990+ShryukGrandhi@users.noreply.github.com>
@codecov

codecov Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.20%. Comparing base (608cb1d) to head (6e657fb).
⚠️ Report is 24 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3442      +/-   ##
============================================
+ Coverage     57.27%   58.20%   +0.93%     
+ Complexity     6577     3086    -3491     
============================================
  Files           776      779       +3     
  Lines         68881    69335     +454     
  Branches       9431     9550     +119     
============================================
+ Hits          39449    40356     +907     
+ Misses        25804    25300     -504     
- Partials       3628     3679      +51     
Flag Coverage Δ *Carryforward flag
commons 96.37% <ø> (ø)
hstore 36.14% <ø> (+0.05%) ⬆️
pd 56.83% <ø> (+4.67%) ⬆️
server_hbase 42.18% <ø> (+<0.01%) ⬆️ Carriedforward from 608cb1d
server_memory 56.17% <ø> (+0.19%) ⬆️
server_rocksdb 42.75% <ø> (+0.09%) ⬆️
store 35.90% <ø> (+2.75%) ⬆️

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bitflicker64 bitflicker64 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Blocking: no. Score: 9/10. Summary: require_current_pr() now binds the plan to base.ref and rejects a target whose history no longer contains the tested base, while target advancement still passes; test_ci_policy.py passes 27/27 at this head.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] CI accepts obsolete PR targets after retargeting or force-push

2 participants