mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-11-22 15:10:00 +08:00
fix/openclaw-python-launcher-path
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
c22cd1f1b6 |
ci(pr-health): flag stale PR branches by ref comparison (#3229)
## Description
The `status: needs rebase` label in `.github/workflows/pr-health.yml` is
driven by `mergeStateStatus == BEHIND`. GitHub only reports `BEHIND`
when the base branch requires branches to be up to date, and `main` does
not (`required_status_checks.strict = false`, per #3066). The label has
therefore never been applied since it was added in #933, so stale-base
risk is invisible on the PR.
This computes the drift directly with a ref comparison instead, so the
label works regardless of the branch-protection setting. It does not
replace the settings decision in #3066 (only a repo admin can enable
strict checks or a merge queue) — it makes the risk visible while that
is pending.
Refs #3066
## Type of Change
- [ ] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update
- [ ] Performance improvement
- [x] Code refactoring (no functional changes)
## Changes Made
- `.github/workflows/pr-health.yml`: the `label` job now asks `gh pr
view` for `baseRefName`, `headRefOid` and `files`, calls
`repos/{repo}/compare/{base}...{head}` for `behind_by` plus the merge
base, and — only when the branch is behind — calls
`compare/{merge_base}...{base}` for the files the base branch changed in
the meantime. That second call has no `[]` fallback: `base_files` is set
to an empty-string sentinel first and reset to it when the call fails,
so partial output from a call that died midway is discarded and a
missing merge base takes the same path.
- `.github/scripts/pr-health-labels.py`: added `drift_state()`,
`parse_behind_by()` and `parse_base_files()`, plus a `--field
checks|drift` switch with `--behind-by` / `--base-files`. A PR is
`stale` when it is behind **and** the base moved on files the PR also
changes, `current` otherwise, and `unknown` when either comparison call
failed. `parse_base_files()` maps the sentinel, invalid JSON and any
non-list payload to `None`, which is what makes a failed base-file
comparison `unknown` rather than an empty set of moved files; a
successful comparison that returns zero files still classifies as
`current`. `unknown` leaves the label untouched, mirroring the existing
`mergeStateStatus == UNKNOWN` guard, so a transient API error never
clears a real label. An explicit `mergeStateStatus == BEHIND` is still
honoured, so nothing regresses if strict checks are enabled later.
- The same `stale` verdict now holds back `status: ready for review`,
replacing the old `BEHIND` condition.
- File overlap is the deliberate narrowing: plain "behind by at least
one commit" matches 18 of 20 open PRs on a base branch this busy, which
would make the label noise. Overlap targets the case that hides a
semantic merge conflict from per-PR checks, which is what #3066
describes.
- Cost is 1-2 extra API calls per PR, so at most ~200 per scheduled run
at the existing 100-PR cap.
- Added unit tests for the new logic and workflow-contract assertions,
including a regression that runs the extracted `base_files` shell block
under `bash` with `gh` stubbed to print partial output and exit 1,
asserts the sentinel survives, feeds it to the script for an `unknown`
verdict, and asserts the drift dispatch has no `else` so `unknown`
neither adds nor removes the label.
## Testing
- [x] Unit tests pass (`pytest`)
- [x] Linting passes (`ruff check .`)
- [ ] Type checking passes (`mypy headroom`)
- [x] New tests added for new functionality
- [x] Manual testing performed
### Test Output
```text
$ python -m pytest scripts/tests/test_pr_health_labels.py scripts/tests/test_pr_health_workflow.py -q
scripts\tests\test_pr_health_labels.py ............. [ 65%]
scripts\tests\test_pr_health_workflow.py ....... [100%]
============================= 20 passed in 0.10s ==============================
$ ruff check .github/scripts/pr-health-labels.py scripts/tests/
All checks passed!
$ ruff format --check .github/scripts/pr-health-labels.py scripts/tests/test_pr_health_labels.py scripts/tests/test_pr_health_workflow.py
3 files already formatted
```
## Real Behavior Proof
- Environment: local checkout of the branch at
|
||
|
|
99c874d423 |
fix(codex): PR health label check state (#986)
## Description Fix the PR health label job so `status: ci failing` reflects the latest check attempt for each check, not historical failed or cancelled attempts that still appear in `statusCheckRollup`. This showed up on #984: the current checks were green, but the label job kept `status: ci failing` because older failed template runs were still present in the rollup payload. ## Type of Change - [x] Bug fix (non-breaking change that fixes an issue) - [ ] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update - [ ] Performance improvement - [ ] Code refactoring (no functional changes) ## Changes Made - Added a small `.github/scripts/pr-health-labels.py` helper that groups check-rollup entries by logical check name and evaluates only the newest entry for each check. - Updated the PR health workflow label job to call the helper instead of treating any historical failing rollup entry as current failure. - Added regression tests for historical failures followed by latest passing attempts, plus current latest failure behavior. ## Testing - [x] Unit tests pass (`pytest`) - [x] New tests added for new functionality - [x] Manual testing performed ### Test Output ```text PYTEST_ADDOPTS='-p no:cacheprovider' pytest scripts/tests -q 47 passed, 1 warning in 0.39s python .github/scripts/pr-health-labels.py --state-json '<payload with old FAILURE and latest SUCCESS>' passing data=$(gh pr view 984 --repo chopratejas/headroom --json statusCheckRollup) python .github/scripts/pr-health-labels.py --state-json "$data" passing ``` ## Real Behavior Proof - Environment: macOS local checkout, Python 3.11.7, live GitHub PR #984 check-rollup payload fetched with `gh pr view`. - Exact command / steps: Added regression coverage for historical failed/cancelled check runs followed by latest successful runs, ran the scripts test suite, and evaluated live PR #984's `statusCheckRollup` with the new helper. - Observed result: The helper returns `passing` for #984's live payload even though older failed/cancelled check runs are still present, while still returning `failing` when the latest attempt for a check failed. - Not tested: A full GitHub Actions run of the updated workflow on upstream before merge; this PR should exercise the workflow on itself. ## Review Readiness - [x] I have performed a self-review - [x] This PR is ready for human review |