[quality] test.yml runs build-test twice per commit on every PR branch — narrow push to main and add a concurrency group

クローズ 初心者向け
#213 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
84/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
github-actions
領域
ci-cd

調査の方向性

.github/workflows/test.yml、特にそのトリガーと変更されていない jobs map を読み、提案された設定を prow-bot.yml:34-36 と比較します。トリガーと concurrency の変更を適用し、同じリポジトリの PR に対する次のコミットによって 1 回の build-test 実行が生成されること、置き換えられた PR の実行がキャンセルされること、main の実行がキャンセルされないことを確認します。

索引モデルが issue の本文から書いたものです。

説明

agent/quality hive/covered-by-pr hive/hosted-available-lke648397-260827-5q9t kind/cleanup quality testing

Finding

.github/workflows/test.yml:2 is on: [push, pull_request] and the workflow has no concurrency block. Every same-repo branch that has an open pull request therefore runs build-test twice per commit — once for the push event and once for pull_request, same SHA, same steps, same result — and a new push to a branch never cancels the still-running job for the previous commit.

Evidence, main @ 187c5e3:

  • #188 head 8656298: run 36255852284 (push, started 16:33:01) and run 36255855092 (pull_request, started 16:33:04) — identical SHA, both fail on the same step.
  • Of the 30 most recent Build and test code runs, 14 head SHAs appear twice (push + pull_request), across 12 branches: 10 quality/test-* branches, dependabot/npm_and_yarn/dev-dependencies-520f5d8d0e and test/e2e-sandbox (two SHAs). Reproduce: gh run list --workflow test.yml --limit 30 --json headSha,event | jq 'group_by(.headSha)|map(select(length>1))|length'.
  • prow-bot.yml:34-36 already declares a concurrency group for the bot; test.yml is the only pull_request workflow in the repository without one.

Each run is ~1 minute on ubuntu-latest, so the cost today is roughly half of all build-test minutes, not wall-clock latency. It becomes latency whenever a burst of PRs (the 19 hold-gated ones currently open, or a dependabot group) queues on the account's concurrent-job limit.

Recommendation

Fire once per commit and let a newer push to a pull request supersede the pending run. Exact replacement — replace lines 1-5 of .github/workflows/test.yml (name: through contents: read) with:

name: Build and test code
on:
  push:
    branches: [main]
  pull_request:

permissions:
  contents: read

# One run per branch: a newer push to a pull request supersedes its pending run.
# Runs on main are never cancelled, so every merge keeps its own result.
concurrency:
  group: test-${{ github.head_ref || github.ref_name }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}

The jobs: map is unchanged.

Notes for the maintainer applying this:

  • push: branches: [main] removes the duplicate outright: a same-repo PR branch runs only through pull_request; main still runs on every merge. A branch with no open PR gets no build-test run — the check has to be read from the PR, which is where it is consumed anyway.
  • github.head_ref || github.ref_name resolves to the branch name for both event types, so if the push narrowing is not wanted, the concurrency block alone still collapses the pair: the pull_request run (started seconds later) cancels the push run. That variant leaves a cancelled run on the branch's commit page; the narrowing avoids it.
  • cancel-in-progress is false on main on purpose: two merges in quick succession must each keep their own pass/fail.
  • Tag pushes currently also run test.yml; release.yml owns v* tags and runs after main was already green on the same commit, so they are not restated here. Add tags: ['v*'] under push: if that run is wanted back.
  • No path filter is added: build-test backs the PR merge gate and a filtered-out required check blocks the merge instead of skipping it.

Why no PR: the whole change is inside .github/workflows/. This agent's App token is minted at the contributor tier without the Workflows permission, so GitHub rejects any push touching that directory (the same rejection @castrojo hit on #209). It needs a human or an ISSUES_PRS_MERGE-tier agent to land. No part of the fix lies outside .github/workflows/.

Completion criteria

  • test.yml runs push only for main (or otherwise dedupes the push/pull_request pair)
  • test.yml has a concurrency group that cancels superseded pull_request runs and never cancels main
  • The next same-repo PR commit produces exactly one build-test run

Priority

  • Impact: low — ~2× build-test minutes and slower burst throughput; no correctness effect
  • Effort: low

Filed by quality agent (hold-gated mode)

🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-5q9t | SHA: 187c5e3

— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88

主要言語
TypeScript
スター
132
フォーク
24
平均マージ
1日 6時間
マージ済み PR(30日)
240

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

cncf/prow-github-actions のほかの issue

cncf/prow-github-actions の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。