Skip to content

ci(workflows): [#2402] cancel superseded PR runs - #2419

Merged
josecelano merged 6 commits into
torrust:developfrom
josecelano:2402-1840-cancel-superseded-pr-runs
Oct 3, 2026
Merged

josecelano merged 6 commits into
torrust:developfrom
josecelano:2402-1840-cancel-superseded-pr-runs

Conversation

@josecelano

Copy link
Copy Markdown
Member

Summary

  • Adds workflow-level concurrency to Container and Testing.
  • Cancels older queued or in-progress runs only when a newer run belongs to the same pull request and workflow.
  • Gives every push run a unique group so push runs are neither cancelled nor replaced.
  • Records implementation and automated validation progress in the Cancel superseded pull-request CI runs #2402 specification.

Files Touched

  • .github/workflows/container.yaml
  • .github/workflows/testing.yaml
  • docs/issues/open/2402-1840-cancel-superseded-pr-runs/ISSUE.md

Validation

  • linter yaml
  • git diff --check
  • linter all
  • TORRUST_GIT_HOOKS_LOG_DIR=.tmp ./contrib/dev-tools/git/hooks/pre-commit.sh

Remaining Verification

  • Execute and record manual scenarios M1 and M2 on real GitHub Actions runs before closing the issue.

Issue

Related to #2402

Copilot AI balanced review requested due to automatic review settings October 2, 2026 17:22
@josecelano
josecelano requested a review from a team as a code owner October 2, 2026 17:22
@josecelano josecelano self-assigned this Oct 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The operations guide still permits rerunning any cancelled run, which can cancel the newer run and leaves T3 incomplete.

Review effort: Balanced
Findings: 2 Low severity

Open (2)
What changed in this PR

Adds workflow-level concurrency to reduce wasted CI capacity while preserving all push runs.

Changes:

  • Cancels superseded PR runs per workflow and PR.
  • Assigns each push run a unique concurrency group.
  • Updates issue implementation and validation progress.
File Description
.github/​workflows/​container.yaml Adds PR-aware concurrency control.
.github/​workflows/​testing.yaml Adds matching concurrency control.
docs/​issues/​open/​2402-1840-cancel-superseded-pr-runs/​ISSUE.md Records implementation progress.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

josecelano added a commit to josecelano/torrust-tracker that referenced this pull request Oct 2, 2026
josecelano added a commit to josecelano/torrust-tracker that referenced this pull request Oct 2, 2026
@josecelano
josecelano force-pushed the 2402-1840-cancel-superseded-pr-runs branch from 9c9296e to 1d4fa58 Compare October 2, 2026 20:06
@josecelano
josecelano force-pushed the 2402-1840-cancel-superseded-pr-runs branch from 1d4fa58 to 5c89eae Compare October 2, 2026 20:31
@josecelano

Copy link
Copy Markdown
Member Author

ACK 5c89eae

@josecelano
josecelano merged commit eb96d29 into torrust:develop Oct 3, 2026
20 checks passed

@da2ce7 da2ce7 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.

Reviewed at 5c89eaef45999f03f85844e24645ad28ab7b5de9 (round 1, post-merge). Recomputed from the bytes at this head.

Label: POST_MERGE_FINDINGS — this PR merged at 2026-10-03T07:13:41Z as eb96d2957 before this review was written; nothing below asks for remediation, and process-pr-review § "Reviews Submitted After Merge" governs any follow-up.

The PR ships its own audit record, docs/pr-reviews/pr-2419-review/PR-REVIEW.md, whose highest id is F2. That numbering stands, and loop findings number from F3.

What landed. Six commits from f5f370bb6 to 5c89eaef4 change five files, +95/−12:

  • one ci(workflows) commit adds the same workflow-level concurrency block to container.yaml and testing.yaml;
  • three docs(issues) commits record #2402 progress in the spec;
  • one docs(self-hosted-runner) commit rewrites step 2 of "When the Runner Is Offline";
  • one docs(pr-reviews) commit adds the audit record.

All five files are identical at develop (eb96d2957), so every finding below is live.

The expression. The two blocks are byte-identical. The >- scalar folds to one line, byte-equal to the spec's proposed group at ISSUE.md:99:
${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || format('run-{0}', github.run_id) }}

Workflow (name:) Event Group cancel-in-progress
Container pull_request (develop, main) Container-pr-<n> true
Container push (develop, main, releases/**/*) Container-run-<run_id> false
Testing pull_request (any base) Testing-pr-<n> true
Testing push (any ref) Testing-run-<run_id> false
  • Neither file has a pull_request_target, merge_group, schedule or workflow_dispatch trigger.
  • && binds tighter than ||, and format() always returns a non-empty string (even pr- for a null number). So the || branch is taken only on non-PR events.
  • AC2 holds by construction: each push run is alone in its run-<run_id> group, and a re-run keeps its run_id.
  • AC3 holds because the two names differ, the PR number is in the group, and no other workflow declares concurrency.
  • # issue: #2402 is the one-line comment T1 prescribes, in the same form as the file's existing # issue: #2107.

Coverage. Seven other workflows run on pull_request and have no concurrency key: os-compatibility, db-compatibility, db-benchmarking, security-scan, copilot-setup-steps, docs-lint and generate_coverage_pr. (coverage.yaml and labels.yaml have no PR trigger.) The spec (ISSUE.md:80-81) and the issue body both put other workflows out of scope, so this is not a finding.

Copilot's threads (review 5394886235)

Record Claim Reply Fix at head isResolved
F1 Guide must restrict re-runs to the latest run (self-hosted-runner.md:363) r4168594062, 18:24:38Z yes, :363-365 true
F2 linter all criterion ("line 189") unchecked r4168594147, 18:24:39Z yes, ISSUE.md:196 true
  • F1: the guide now says what Copilot asked: re-run only the latest run, because re-running an older cancelled run would cancel it. But it applies the rule to pull-request runs only (loop F4).
  • F2: fixed, but the record's F2 entry describes a different change (loop F3).

Findings

ID Severity Live on develop? Recomputation
loop F3 Minor yes Record F2's Solution and verification name AC4, which docs(issues): [#2402] record workflow implementation had already ticked. The cited commit ticks only the linter all row
loop F4 Minor yes Guide step 2 limits re-runs to a PR's latest run. develop push runs, which the same section says block publishing, lose their re-run instruction
loop F5 Minor yes AC4 is [x] at ISSUE.md:194 but TODO, with no evidence, at :227
loop F6 Nit yes Item 2's continuation lines are indented 2 spaces, its siblings 3 (lazy continuation; renders the same)
loop F7 Nit yes The audit record omits the template's verbatim Status Values and Completion Rules sections
loop F8 Nit yes (merge message) The PR body's "Files Touched" lists 3 of the 5 files

Checked, no finding

  • Frontmatter. status: in-progress and related-pr: 2419 are set, and last-updated-utc (18:21) equals the last progress-log entry.
  • Progress log. Each entry predates the commit that carries it: 17:17 vs 17:20:43Z, 17:52 vs 17:53:11Z, 17:54 vs 17:56:55Z, 18:21 vs 18:23:08Z. The 17:52 entry comes after the PR opened (17:22:37Z). The force-pushed commits (committed 20:30:58Z–20:31:00Z) keep their author times and change nothing in the spec, so no log entry is owed.
  • Task and checkpoint states. T1–T3 DONE match the bytes. T3 rests on self-hosted-runner.md:403, which predates this PR, plus :363-365. T4 TODO, M1 IN_PROGRESS, M2 TODO, the unchecked AC1–AC3 and the checkpoint ticks are all consistent with M1 and M2 being unfinished.
  • M1 evidence pointer. M1's evidence column points at manual-verification-evidence.md section V1, which does not exist at head or at develop. The issue template uses the same forward reference for rows not yet run (docs/templates/ISSUE.md:182), and M1 is unfinished.
  • Guide accuracy. Both runner jobs run on pull_request (container.yaml:68-69, testing.yaml:174-176). A run cancelled by the group carries the block, because a re-run keeps its commit's workflow file (self-hosted-runner.md:368-369). So re-running it cancels the latest run while that run is queued or running, which is the section's case.
  • Audit record. Ids, review id, source and reply URLs and isResolved all match the evidence. The resolution references cite subjects, so they survive both force-pushes. The repository validator exits 0 offline. The 18:27 UTC log entry comes after the replies and before the merge; when the threads were resolved is not in the evidence.
  • Hygiene.
    • All six subjects are Conventional, and author and committer times are in order.
    • No AI-attribution trailer (word-boundary grep, 0 hits), no banned token in the changed files, and git diff --check is clean.
    • The [#<issue>] reference is a PR-title rule (AGENTS.md:381), so the two untagged commit subjects break nothing.
    • The title carries [#2402], and the body's Related to #2402 is correct because M1 and M2 remain.
  • CI. The captured check runs show no startup_failure or action_required.

Checks

Orchestrator gate at 5c89eaef4 on the loop's compute pod (base f5f370bb6): the pre-commit profile exited 0 (wall 41 s), clippy-allow-reasons exited 0, the tree was clean after the gate, and the repository's linter yaml reported every YAML file passing. CI at this head: 16 check runs succeeded and 4 were skipped, none failed. Reviewed by the loop's account at the Maintainers team's review request of 2026-10-02T17:22Z; the merge preceded the review.

- Reviewer finding ID: N/A
- Source URL: https://github.com/torrust/torrust-tracker/pull/2419#discussion_r4168254819
- Concern: The issue recorded a successful `linter all` run while leaving the corresponding acceptance criterion unchecked.
- Solution: Marked AC4 complete because the operations guide now states that superseded pull-request runs are cancelled.

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.

[Minor][loop F3] Record F2's Solution and Current-tree verification describe AC4, not the linter all criterion F2 is about

Copilot's comment r4168254819 is about "the corresponding acceptance criterion at line 189". In docs(issues): [#2402] record workflow implementation (the rebased first spec commit), line 189 is - [ ] `linter all` exits with code `0` . AC4, at line 187, is already [x]: that commit ticked it, before Copilot's review.

The cited resolution commit, docs(self-hosted-runner): guide safe workflow reruns, changes only the linter all row in the spec (ISSUE.md:196) and does not touch AC4. So:

  • line 49 ("Marked AC4 complete because the operations guide now states …") names a change the resolution commit does not contain;
  • line 50 checks AC4 instead of the row the fix changed.

The reply r4168594147 names the linter all row correctly. The validator exits 0 here because it does not check prose (process-pr-review/SKILL.md:230-231).

Merged-tree-wrong test: met. The record claims a fix the resolution commit does not contain, and its verification line does not check the fixed row. Live on develop (eb96d2957, blob identical).

1. Check the service and the kernel log (see Check the Runner). If the service is `failed`, run
`systemctl reset-failed <unit>` and `systemctl start <unit>`, and look for the cause.
2. Re-run the failed or cancelled jobs: `gh run rerun <run-id> --repo torrust/torrust-tracker --failed`.
2. Re-run failed jobs only from a pull request's latest run:

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.

[Minor][loop F4] Step 2 limits re-runs to a pull request's latest run, so develop push runs lose their re-run instruction

This section also covers develop pushes: "On develop pushes the publish jobs wait for test, so nothing is published until the job runs" (:358-359). container.yaml:70 routes a develop push's Test (Docker) job to the runner.

  • Before this PR, step 2 said to re-run the failed or cancelled jobs, for any kind of run.
  • Now it allows re-runs "only from a pull request's latest run". That excludes a develop push run whose job failed while the runner was down.

The concurrency design makes that re-run safe. A push run is alone in its <workflow>-run-<run_id> group, its cancel-in-progress is false, and a re-run keeps its run_id. The latest-run rule is only needed for pull-request groups.

Merged-tree-wrong test: met. As written, the step forbids a re-run that is safe at this head and that the section's own symptom calls for. Live on develop (blob identical).

- [ ] AC3: A newer run of one workflow does not cancel the other workflow's run for the same
commit, and a pull request's runs do not cancel another pull request's runs.
- [ ] AC4: `docs/self-hosted-runner.md` states that superseded pull-request runs are cancelled.
- [x] AC4: `docs/self-hosted-runner.md` states that superseded pull-request runs are cancelled.

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.

[Minor][loop F5] AC4's state is recorded two ways: [x] here, TODO in Acceptance Verification

AC4 is ticked here (by docs(issues): [#2402] record workflow implementation). The Acceptance Verification table at :227 still reads | AC4 | TODO | |, with no evidence. That line is outside the diff, so this comment is anchored on the nearest changed line.

AC5 shows the spec's own convention: it is updated in both places ([x] at :195, and DONE | EPIC #1840 row 18 at :228).

Merged-tree-wrong test: met. The same criterion's state is stated two ways at head. Live on develop (blob identical).

`systemctl reset-failed <unit>` and `systemctl start <unit>`, and look for the cause.
2. Re-run the failed or cancelled jobs: `gh run rerun <run-id> --repo torrust/torrust-tracker --failed`.
2. Re-run failed jobs only from a pull request's latest run:
`gh run rerun <run-id> --repo torrust/torrust-tracker --failed`. Do not re-run an older cancelled

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.

[Nit][loop F6] Item 2's continuation lines are indented 2 spaces; items 1 and 3 use 3

The content of 2. starts at column 3. Lines 364-365 are indented 2 spaces, so they stay in the item only as lazy paragraph continuation lines. Items 1 (:362) and 3 (:367-369) use the 3-space hanging indent.

The output renders the same, and markdownlint accepts it:

  • MD007 (.markdownlint.json:9-11) governs unordered lists only.
  • MD005 checks marker indentation, and the markers are consistent.

This is a consistency nit only. Live on develop.


- Post-merge workflow approval: N/A

## Findings

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.

[Nit][loop F7] The audit record omits the template's ## Status Values and ## Completion Rules sections

docs/templates/PR-REVIEW-TEMPLATE.md:26 and :113 mark both sections "Copied verbatim into each audit record." This record goes from ## Ownership straight to ## Findings (here) and ends at ## Processing Log.

The adjacent records pr-2403-review, pr-2405-review and pr-2421-review carry both sections. The validator does not check for them. Live on develop.


<!-- skill-link: process-pr-review -->

# PR #2419 Review Audit

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.

[Nit][loop F8] The PR body's "Files Touched" lists 3 of the 5 changed files

The subject is the PR description, which is not a file. This comment is anchored here because this file is one of the two the description leaves out.

"Files Touched" lists the two workflows and the spec. It omits docs/self-hosted-runner.md and this audit record, and the Summary does not mention the guide change. open-pull-request/SKILL.md:105-110 requires the body to list the files touched.

The merge tool copied the body into the message of eb96d2957, so the incomplete list is part of develop history. Live (merge-commit message; immutable).

This branch was previously deployed

1 inactive deployment
coverage — 5c89eaef Deployed Oct 2, 2026 by josecelano via Generate Coverage Report #2404
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.

3 participants