Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ updates:
development-tooling:
dependency-type: development
patterns: ["*"]
runtime-patches:
applies-to: version-updates
dependency-type: production
update-types: [patch]
labels: [dependencies, python]
commit-message:
prefix: deps
Expand Down
50 changes: 25 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,39 +31,39 @@ permissions:
contents: read

concurrency:
group: production-release
# Match authorize.if so skipped events cannot replace a pending release.
group: >-
${{
github.event.repository.private == false &&
github.ref == 'refs/heads/main' &&
(github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request' &&
github.event.action == 'closed' &&
github.event.pull_request.merged == true &&
github.event.pull_request.base.repo.full_name == github.repository &&
github.event.pull_request.base.ref == 'main' &&
github.event.pull_request.head.repo.full_name == github.repository &&
startsWith(github.event.pull_request.head.ref, 'release/v') &&
startsWith(github.event.pull_request.title, 'Release v'))) &&
'production-release' || format('release-ignored-{0}', github.run_id)
}}
cancel-in-progress: false

jobs:
classify:
name: classify-release-trigger
runs-on: ubuntu-latest
timeout-minutes: 2
outputs:
release: ${{ steps.classify.outputs.release }}
steps:
- id: classify
env:
EVENT_NAME: ${{ github.event_name }}
PR_MERGED: ${{ github.event.pull_request.merged }}
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
run: |
release=false
if [ "${EVENT_NAME}" = workflow_dispatch ]; then
release=true
elif [ "${PR_MERGED}" = true ] && [[ "${PR_HEAD_REF}" == release/v* ]]; then
release=true
fi
echo "release=${release}" >> "${GITHUB_OUTPUT}"

authorize:
name: authorize-release
needs: classify
if: >-
github.event.repository.private == false &&
github.ref == 'refs/heads/main' &&
(github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == github.repository) &&
needs.classify.outputs.release == 'true'
(github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request' &&
github.event.action == 'closed' &&
github.event.pull_request.merged == true &&
github.event.pull_request.base.repo.full_name == github.repository &&
github.event.pull_request.base.ref == 'main' &&
github.event.pull_request.head.repo.full_name == github.repository &&
startsWith(github.event.pull_request.head.ref, 'release/v') &&
startsWith(github.event.pull_request.title, 'Release v')))
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/site-release-notify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Notify toolkit site of stable release
on:
workflow_run:
workflows: [Release]
branches: ['release/v*', main]
types: [completed]

permissions: {}
Expand Down
1 change: 1 addition & 0 deletions changelog.d/364.maintenance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Skip release authorization runners for ordinary PR closures, limit site notifications to release and recovery branches, and group scheduled runtime patch updates to dev.
10 changes: 10 additions & 0 deletions docs/codex/TASKS_BACKLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,13 @@ The [signal-ownership audit](../engineering/review_signal_ownership.md) remains
- **Exclusions:** Learned online routing, per-tool models, multiple agents, or silent policy changes.
- **Validation:** Offline replay, adversarial boundaries, fallback tests, and quality thresholds.
- **Release classification expectation:** `release-required`.

## Maintainer CI

### BL-026: Avoid redundant PR validations without replacing required checks

- **Status:** planned
- **Activation trigger:** A hosted test repository can reproduce this project's required Actions and CodeQL app checks on protected branches.
- **Evidence:** A description edit on #361 cancelled checks and started a second validation of the same synthetic merge commit. During promotion, eight CI runs on Dependabot #346–349 used a combined 13,122 job-seconds on allocated runners. Four runs were created shortly after automatic closure and ran 22 test jobs to success. In #363 the macOS Python 3.12 runner waited 14m40s before starting. [Original validation](https://github.com/xeonvs/open-code-review-toolkit/actions/runs/46740538729) · [Replacement validation](https://github.com/xeonvs/open-code-review-toolkit/actions/runs/46740601948) · [Release CI](https://github.com/xeonvs/open-code-review-toolkit/actions/runs/46746189464)
- **Next safe action:** Measure runner queue and execution time separately across releases. Finalize PR descriptions before marking a PR ready. For later status updates, use PR comments. Evaluate metadata-only edits and already-closed Dependabot work in an isolated hosted repository.
- **Acceptance:** An edit to the title or body alone neither cancels work on the same revision nor emits a passing or skipped required check in place of a pending or failed one. Recheck the exact head, base and test-merge revisions on retarget, synchronization, draft/ready transitions, or ambiguous events. Verify merge eligibility for forks and repository-owned PRs with the actual required app identities. Preserve independent platform, secret, provenance and registry-install checks.
14 changes: 13 additions & 1 deletion docs/contributor-intake.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,16 @@
2. Review the full diff at those revisions before approving fork CI. Check workflow and executable changes, dependency and lockfile sources, installation and container inputs, Action pins and OCR qualification integrity values. Review additions and removals and both paths of renames and copies. Confirm a human updater's maintainer role in GitHub's repository access settings. For Dependabot updates to `dev`, verify the configured bot account, repository-owned branch and GitHub-verified commits through the reviewed head. Treat labels and branch names as context. Have a maintainer prepare dependency changes requested by an outside contributor. [Dependency audit and upstream review](development.md#dependency-audit-before-push)
3. Mark the PR ready and verify the full applicable protected CI ran and passed for the live base and head. Repeat review and checks when either revision changes. The maintainer verifies the author, source, target and revisions immediately before manual merge. Require an independent approval and dismiss stale approvals when there are two eligible maintainers. With a sole maintainer, record the exact revision reviewed and retain protected PR checks for maintainer-authored work. Squash eligible fork changes into `dev` with contributor attribution. For a CLI squash merge, supply the reviewed head with `gh pr merge "$PR_NUMBER" --squash --match-head-commit "$REVIEWED_HEAD"`. Whenever current main is no longer an ancestor of dev, including after a squash promotion or stable release, create a maintainer sync branch at the current `dev` tip, merge current `main` into it with a signed merge, and open a PR back to `dev`. Use a merge commit to preserve ancestry. Check that the current `main` tip is an ancestor of `dev` before the next promotion. [GitHub CLI merge options](https://cli.github.com/manual/gh_pr_merge)

Dependabot's `target-branch: dev` applies to scheduled version updates. GitHub opens security update PRs against the default branch. Retarget those to `dev` for review or prepare the fix there on a maintainer branch. [Dependabot target-branch behavior](https://docs.github.com/en/code-security/reference/supply-chain-security/dependabot-options-reference#target-branch)
Dependabot groups scheduled runtime patch updates into one PR to `dev`. Review the lockfile changes for each package. GitHub opens security update PRs against the default branch. Retarget those to `dev` for review or prepare the fix there on a maintainer branch. [Dependabot target-branch behavior](https://docs.github.com/en/code-security/reference/supply-chain-security/dependabot-options-reference#target-branch)

### Reconcile superseded Dependabot PRs before promotion

Before merging a protected development promotion, list open Dependabot PRs targeting its base. This covers older version-update PRs that still target `main`.

```sh
gh pr list --state open --base main --author app/dependabot --json number,title,headRefName,headRefOid
```

For a scheduled version update already incorporated in the reviewed promotion, compare the complete proposed dependency and lockfile or Action-pin diff, including transitive changes. If every change is accounted for, record the promotion PR and close the superseded bot PR before moving the base. Keep outstanding changes and security updates open until the target contains their fix.

Check for queued or in-progress PR runs on the bot branch after closure. A queued event can create a run after the PR closes. Before cancelling an individual run, re-read the PR state and verify its closed, unmerged head, source repository and branch against the run. Limit cancellation to superseded pull-request validation runs in the same repository and confirm no open PR still uses that branch and revision. Use the run ID for cancellation and read back its terminal state. Ordinary dependency PRs continue through the usual required checks.
35 changes: 27 additions & 8 deletions tests/test_release_authorization.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,31 @@ def test_required_check_and_ruleset_synchronization_are_exact() -> None:
authorize(protection=protection)


def test_release_workflow_classifies_ordinary_merges_before_authorization() -> None:
workflow = WORKFLOW.read_text(encoding="utf-8")

assert "name: classify-release-trigger" in workflow
assert '[[ "${PR_HEAD_REF}" == release/v* ]]' in workflow
assert "needs: classify" in workflow
assert "needs.classify.outputs.release == 'true'" in workflow
def test_release_workflow_guards_authorization_and_isolates_skipped_runs() -> None:
workflow = yaml.load(WORKFLOW.read_text(encoding="utf-8"), Loader=yaml.BaseLoader)
assert workflow["on"]["pull_request"] == {"types": ["closed"], "branches": ["main"]}
assert "workflow_dispatch" in workflow["on"]
jobs = workflow["jobs"]
assert {name for name, job in jobs.items() if "needs" not in job} == {"authorize"}
assert jobs["build"]["needs"] == "authorize"
assert jobs["build"]["if"] == "needs.authorize.outputs.approved == 'true'"

gate = " ".join(jobs["authorize"]["if"].split())
assert gate == (
"github.event.repository.private == false && github.ref == 'refs/heads/main' && "
"(github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && "
"github.event.action == 'closed' && github.event.pull_request.merged == true && "
"github.event.pull_request.base.repo.full_name == github.repository && "
"github.event.pull_request.base.ref == 'main' && "
"github.event.pull_request.head.repo.full_name == github.repository && "
"startsWith(github.event.pull_request.head.ref, 'release/v') && "
"startsWith(github.event.pull_request.title, 'Release v')))"
)
concurrency = workflow["concurrency"]
assert " ".join(concurrency["group"].split()) == (
f"${{{{ {gate} && 'production-release' || format('release-ignored-{{0}}', github.run_id) }}}}"
)
assert concurrency["cancel-in-progress"] == "false"


@pytest.mark.parametrize(
Expand Down Expand Up @@ -460,7 +478,8 @@ def test_release_workflow_keeps_strict_release_authorization() -> None:
assert "--validate-issue-only" in workflow
assert 'test "$(git rev-parse HEAD^{tree})" = "${EXPECTED_TREE}"' in workflow
assert 'test "$(git rev-parse FETCH_HEAD^{tree})" = "${EXPECTED_TREE}"' in workflow
assert "github.event.pull_request.merged == true" not in workflow
assert '"repos/${REPOSITORY}/pulls/${PR_NUMBER}" /tmp/release-pr.json' in workflow
assert "--pr-json /tmp/release-pr.json" in workflow


def test_bounded_github_helper_rejects_unknown_endpoints_and_writes_atomically(
Expand Down
4 changes: 3 additions & 1 deletion tests/test_site_release_notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ def _verification_step() -> str:


def test_site_dispatch_occurs_once_after_read_only_verification() -> None:
jobs = yaml.safe_load(WORKFLOW.read_text(encoding="utf-8"))["jobs"]
workflow = yaml.load(WORKFLOW.read_text(encoding="utf-8"), Loader=yaml.BaseLoader)
assert set(workflow["on"]["workflow_run"]["branches"]) == {"release/v*", "main"}
jobs = workflow["jobs"]
steps = jobs["notify"]["steps"]
assert "--method POST" not in _verification_step()
assert "OCR_SITE_DISPATCH_TOKEN" not in str(jobs["verify"])
Expand Down