Skip to content

👷 Auto-cancel interruptible jobs on new commits#4571

Merged
thomas-lebeau merged 4 commits intomainfrom
thomas.lebeau/auto-cancel-interruptible-pipelines
May 7, 2026
Merged

👷 Auto-cancel interruptible jobs on new commits#4571
thomas-lebeau merged 4 commits intomainfrom
thomas.lebeau/auto-cancel-interruptible-pipelines

Conversation

@thomas-lebeau
Copy link
Copy Markdown
Collaborator

@thomas-lebeau thomas-lebeau commented May 7, 2026

Motivation

When pushing several commits in quick succession to a branch, in-flight pipelines keep running and consume CI resources even though only the latest one matters. This is especially wasteful for jobs queued behind resource_group: browserstack, where superseded commits can sit in the BS queue for an hour and still run to completion.

GitLab's documented default for workflow.auto_cancel.on_new_commit is conservative, which should already cancel interruptible jobs on new commits to the same ref. In practice this doesn't seem to be working for our project anymore — pushing a new commit while a pipeline is still in the test stage does not cancel the older pipeline, even though all running jobs are marked interruptible: true.

Setting the keyword explicitly fixes this.

Changes

  • Add workflow.auto_cancel.on_new_commit: interruptible to .gitlab-ci.yml so pipelines superseded by a newer commit on the same branch are cancelled automatically.

Test instructions

Validated on this branch by pushing back-to-back commits:

  • Without the fix — pipeline 111916157 (commit 1) was not cancelled when commit 2 was pushed; jobs kept running and unit-bs / e2e-bs stayed queued in waiting_for_resource.
  • With the fix — pipeline 111916287 (commit 3, which introduced the fix) was correctly cancelled when commit 4 was pushed: all interruptible jobs (incl. unit-bs and e2e-bs) transitioned to canceled.

The empty 🧪 test commits on this branch were used purely to exercise the behaviour and will be dropped when squashing the PR to main.

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

Without this directive, GitLab relies on the project-level "Auto-cancel
redundant pipelines" setting, which is currently not effective for this
project. Explicitly enabling `auto_cancel.on_new_commit: interruptible`
ensures interruptible jobs (e.g. unit-bs, e2e-bs queued behind the
browserstack resource group) are cancelled when a new commit lands on
the same branch.
@thomas-lebeau thomas-lebeau marked this pull request as ready for review May 7, 2026 06:31
@thomas-lebeau thomas-lebeau requested a review from a team as a code owner May 7, 2026 06:31
@thomas-lebeau thomas-lebeau merged commit 3ab0af5 into main May 7, 2026
20 of 22 checks passed
@thomas-lebeau thomas-lebeau deleted the thomas.lebeau/auto-cancel-interruptible-pipelines branch May 7, 2026 07:49
@github-actions github-actions Bot locked and limited conversation to collaborators May 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants