Skip to content
Draft
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
2 changes: 2 additions & 0 deletions .github/workflows/ontology-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ permissions:
contents: read

concurrency:
# Pull-request lifecycle events share the PR-scoped group: Draft/closed
# transitions skip validation while cancelling any older active validation.
group: ${{ github.workflow }}-${{ github.repository }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/prov-o-contract.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ permissions:
contents: read

concurrency:
# Draft/closed events intentionally skip the product job but retain the
# workflow event needed to cancel an older active run for this same PR.
group: ${{ github.workflow }}-${{ github.repository }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ permissions:
contents: read

concurrency:
# A merged pull request can report the base ref on ``closed``. Keying PR
# events by number lets that close run cancel an older queued synchronize
# run for the same PR instead of consuming runners after the PR is closed.
# Draft/closed events deliberately create a no-job run in this workflow so
# workflow-level concurrency can cancel any older active run for the same PR.
group: ${{ github.workflow }}-${{ github.repository }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

Expand Down
20 changes: 14 additions & 6 deletions tests/test_tests_workflow_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,23 @@
"converted_to_draft, closed]"
)
_DRAFT_ADMISSION = "github.event.pull_request.draft == false"
_INACTIVE_ADMISSION = (
"github.event.action != 'closed' && github.event.pull_request.draft == false"
)


def test_pull_request_concurrency_survives_closed_ref_change() -> None:
"""Key synchronize and closed events by PR number so close cancels stale work."""

workflow = (_WORKFLOW_DIRECTORY / "tests.yml").read_text(encoding="utf-8")
def test_lifecycle_events_cancel_inactive_pr_work() -> None:
"""Keep lifecycle events so Draft/close transitions cancel active local work."""

assert _PULL_REQUEST_TYPES in workflow
assert workflow.count("github.event.action != 'closed'") == 2
expected_inactive_guards = {
"tests.yml": 2,
"prov-o-contract.yml": 1,
"ontology-pages.yml": 1,
}
for workflow_name, expected_guard_count in expected_inactive_guards.items():
workflow = (_WORKFLOW_DIRECTORY / workflow_name).read_text(encoding="utf-8")
assert _PULL_REQUEST_TYPES in workflow, workflow_name
assert workflow.count(_INACTIVE_ADMISSION) == expected_guard_count, workflow_name


def test_pull_request_workflows_cancel_only_superseded_same_pr_runs() -> None:
Expand Down
Loading