Skip to content

Stop duplicate CI runs on PR branches - #166

Merged
lucaspimentel merged 2 commits into
mainfrom
lpimentel/kill-duplicate-ci-runs
Aug 17, 2026
Merged

Stop duplicate CI runs on PR branches#166
lucaspimentel merged 2 commits into
mainfrom
lpimentel/kill-duplicate-ci-runs

Conversation

@lucaspimentel

@lucaspimentel lucaspimentel commented Aug 14, 2026

Copy link
Copy Markdown
Member

Problem

on: [push, pull_request] fires both events for the same commit when a branch has an open PR, so every build job runs twice. This is visible on recent PRs (e.g. #164) where each job — lint, unit-test (3.2), integration-test (4.0), … — appears under two run IDs. Doubles CI wall-time and AWS sandbox usage per PR.

Fix

Restrict push to main:

on:
  pull_request:
  push:
    branches: [main]
  • PR branches → only pull_request fires → one run per commit (no duplicate).
  • Merges to mainpush fires → still verified.

Why not cancel-in-progress on all branches?

The alternative — keep push on all branches and rely on a concurrency block with cancel-in-progress: true to dedup — leaves the cancelled run reporting cancelled (not success). Per GitHub's required-checks docs, only success/skipped/neutral satisfy a required check. This repo has a custom merge gate (devflow/mergegate + DDCI Status + dd-gitlab/*), and introducing cancelled check states into a gate we don't control is risky. Restricting push to main means the duplicate never fires in the first place — no cancellation race, no ambiguous check state.

References: Adam Johnson, runs-on.com concurrency guide.

Trade-off

Pushes to a feature branch with no open PR no longer get CI — you get CI once the PR is opened. (This matches the behavior of most of Datadog's other serverless repos.)

Other workflows

Unchanged:

  • check-size.ymlpull_request only
  • publish.ymlworkflow_dispatch only
  • codeql-analysis.yml → standalone

`on: [push, pull_request]` fired both events for the same commit
when a branch had an open PR, doubling every lint/unit/integration
run. Restrict `push` to `main` so PR branches only trigger
`pull_request`, and add a concurrency group to cancel superseded PR
runs when new commits land. Merges to main are still verified.
@lucaspimentel
lucaspimentel requested review from a team as code owners August 14, 2026 22:27

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3355b8c1a6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/build.yml Outdated
The duplicate-run fix is handled entirely by restricting `push` to
`main`; the concurrency block only cancelled superseded PR runs on
rapid commits, which is optional. Keep the diff minimal and focused.

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.

Pull request overview

Updates the GitHub Actions build workflow triggers to avoid duplicate CI runs on PR branches by running CI on pull_request events for PR work and limiting push runs to the main branch.

Changes:

  • Replaces on: [push, pull_request] with explicit pull_request and push (restricted to main) triggers.
  • Adds an inline yamllint suppression for the on: key to satisfy YAML linting.

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

@lucaspimentel
lucaspimentel merged commit 00707a4 into main Aug 17, 2026
58 checks passed
@lucaspimentel
lucaspimentel deleted the lpimentel/kill-duplicate-ci-runs branch August 17, 2026 14:41
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.

4 participants