CI: add concurrency cancel-in-progress to ci.yml — stop waiting for superseded runs #497

Closed
opened 2026-06-06 16:22:30 +00:00 by guettlibot · 1 comment
guettlibot commented 2026-06-06 16:22:30 +00:00 (Migrated from codeberg.org)

Problem

When you push multiple commits to a branch in quick succession (e.g. fixing a PR), every push triggers ci.yml. Each job takes ~5–6 min. With one runner slot, they queue:

push 1 → waits 0 min, runs 5 min
push 2 → waits 5 min, runs 5 min
push 3 → waits 10 min, runs 5 min
push 4 → waits 15 min, runs 5 min
push 5 → waits 20 min, runs 5 min
push 6 → waits 25 min, runs 5 min
push 7 → waits 30 min, runs 5 min
push 8 → waits 35 min, runs 5 min ← the one you care about

Measured today: queue times of 38–40 minutes during a burst of commits. The run itself is only 5 min.

Only the LAST commit matters. All earlier runs are wasted work.

Fix

Add a concurrency group to ci.yml that cancels any in-progress run for the same branch when a new commit arrives:

name: CI
on: [push, pull_request]

concurrency:
  group: ci-${{ github.ref }}
  cancel-in-progress: true

jobs:
  check:
    ...

With this in place:

  • Push 1 starts running.
  • Push 2 arrives → push 1 is cancelled, push 2 starts immediately.
  • Push 8 arrives → only push 8 runs.

Queue time goes from 35 min to ~0 min.

Expected impact

  • Queue time for the most recent commit on a branch drops from O(n × job_duration) to ~0.
  • Dramatically better feedback loop during active development.
  • No impact on main branch deploys (deploy.yml has its own concurrency domain).

Files to change

  • .forgejo/workflows/ci.yml — add the concurrency: block (2 lines)
## Problem When you push multiple commits to a branch in quick succession (e.g. fixing a PR), every push triggers ci.yml. Each job takes ~5–6 min. With one runner slot, they queue: push 1 → waits 0 min, runs 5 min push 2 → waits 5 min, runs 5 min push 3 → waits 10 min, runs 5 min push 4 → waits 15 min, runs 5 min push 5 → waits 20 min, runs 5 min push 6 → waits 25 min, runs 5 min push 7 → waits 30 min, runs 5 min push 8 → waits 35 min, runs 5 min ← the one you care about Measured today: queue times of 38–40 minutes during a burst of commits. The run itself is only 5 min. Only the LAST commit matters. All earlier runs are wasted work. ## Fix Add a concurrency group to ci.yml that cancels any in-progress run for the same branch when a new commit arrives: ```yaml name: CI on: [push, pull_request] concurrency: group: ci-${{ github.ref }} cancel-in-progress: true jobs: check: ... ``` With this in place: - Push 1 starts running. - Push 2 arrives → push 1 is cancelled, push 2 starts immediately. - Push 8 arrives → only push 8 runs. Queue time goes from 35 min to ~0 min. ## Expected impact - Queue time for the most recent commit on a branch drops from O(n × job_duration) to ~0. - Dramatically better feedback loop during active development. - No impact on main branch deploys (deploy.yml has its own concurrency domain). ## Files to change - `.forgejo/workflows/ci.yml` — add the `concurrency:` block (2 lines)
guettlibot commented 2026-06-07 00:36:56 +00:00 (Migrated from codeberg.org)

Done. Here's a summary of what was done:

Change made: Added a concurrency: block to .forgejo/workflows/ci.yml:

concurrency:
  group: ci-${{ github.ref }}
  cancel-in-progress: true

This cancels any queued/running CI job for the same branch the moment a new commit is pushed, so only the latest commit's run ever completes. Queue time drops from O(n × 5 min) to ~0.

Pull request: https://codeberg.org/guettli/sharedinbox/pulls/516 (auto-merge enabled — will merge automatically once CI is green)

Done. Here's a summary of what was done: **Change made:** Added a `concurrency:` block to `.forgejo/workflows/ci.yml`: ```yaml concurrency: group: ci-${{ github.ref }} cancel-in-progress: true ``` This cancels any queued/running CI job for the same branch the moment a new commit is pushed, so only the latest commit's run ever completes. Queue time drops from O(n × 5 min) to ~0. **Pull request:** https://codeberg.org/guettli/sharedinbox/pulls/516 (auto-merge enabled — will merge automatically once CI is green)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: guettli/sharedinbox#497