ci(workflow): 같은 PR·브랜치의 새 push가 앞 run을 취소한다

문제: runner가 하나(capacity 1)인데 PR에 push할 때마다 run이 하나씩
쌓인다. 낡은 head의 run이 runner를 25분씩 잡아 새 head와 백엔드 run이
뒤로 밀린다.

고른 방법: workflow에 concurrency를 둔다. group은
`frontend-quality-gates-<event>-<ref>-<stage>`다. PR run의 ref는
`refs/pull/<번호>/head`라 PR마다 group 하나, branch push는 branch마다
하나, release tag는 tag마다 하나다. cancel-in-progress는 수동 실행만
거짓이다. Gitea 1.27.0은 group과 cancel-in-progress를 서버에서 식으로
계산하고(`services/actions/concurrency.go`, `inputs` 포함), 같은 group의
앞 run을 대기 중이면 언제나, 실행 중이면 cancel-in-progress가 참일 때
취소한다.
- 수동 실행에 stage를 group에 넣고 취소를 끈 이유: 다음 수동 실행이
  검증과 승격 사이의 release run을 끊지 않게 한다.
- 버린 대안: 백엔드처럼 event·ref만으로 group을 짓기. 프론트는 수동
  실행 하나가 stage 여섯을 받아, 다른 stage의 수동 실행끼리 취소된다.

위험·한계: 실제 취소는 runner에서 push 두 번으로 확인해야 한다(다음
커밋들의 PR run으로 남긴다). 이 커밋 전에 만들어진 대기 run은 group이
없어 취소되지 않는다.

검증(desktop): generate:ci-workflow, ci-workflow-generation 시험 파일
전부 통과(스냅샷 갱신 포함), check:ci-workflow rc=0, check:types rc=0,
eslint rc=0. 로그 /tmp/claude-gates/w2fe2-gen1/, w2fe2-cov1/.
This commit is contained in:
DongHyeonka
2026-11-12 22:02:56 +09:00
parent ba72b86595
commit 2f5eb2b4a5
5 changed files with 38 additions and 0 deletions
+4
View File
@@ -24,6 +24,10 @@ on:
permissions:
contents: read
concurrency:
group: frontend-quality-gates-${{ gitea.event_name }}-${{ gitea.ref }}-${{ inputs.stage }}
cancel-in-progress: ${{ gitea.event_name != 'workflow_dispatch' }}
env:
CI: "true"
VITE_BUILD_ID: "gitea-${{ gitea.run_id }}-${{ gitea.run_attempt }}"
+4
View File
@@ -11,6 +11,10 @@
있고, 실패한 게이트가 다음 게이트를 건너뛰게 하지 않는다. 검사기 자신의 음성 fixture와
gating 검사는 branch에 push한 뒤 main 단계(`main_gate`, FE-GATE-029)에서 돈다. release와
production 게이트는 matrix check로 남는다. 실패를 무시하는(soft-fail) 연결은 없다.
같은 PR이나 같은 브랜치에 새 push가 오면 workflow `concurrency`가 앞 run을 취소한다. Gitea는
앞 run의 대기 중인 job은 언제나, 돌고 있는 job은 `cancel-in-progress`가 참일 때 취소한다.
수동 실행(`workflow_dispatch`)은 ref와 stage마다 group이 따로이고 돌고 있는 run을 취소하지
않는다. 검증과 승격 사이의 release run이 다음 수동 실행에 끊기지 않게 하려는 것이다.
## 기준선 갱신과 새 프로젝트 시작 시 초기화할 기준선
+17
View File
@@ -77,6 +77,21 @@ const PRODUCT_GATE_JOB = "product_merge_gate";
*/
const PRODUCT_GATES_HOLD = "release_gate";
/**
* A newer run in the same group cancels the older one. Gitea 1.27 cancels the
* older run's waiting and blocked jobs always and its running jobs only when
* cancel-in-progress is true. A pull request run has the ref
* `refs/pull/<number>/head`, so one group per pull request; a branch push is
* one group per branch; a release tag has its own ref. A manual run is one
* group per ref and stage and does not cancel a running run: a later release
* dispatch must not stop an earlier one between verification and promotion.
*/
const CONCURRENCY_LINES = Object.freeze([
"concurrency:",
" group: frontend-quality-gates-${{ gitea.event_name }}-${{ gitea.ref }}-${{ inputs.stage }}",
" cancel-in-progress: ${{ gitea.event_name != 'workflow_dispatch' }}",
]);
export function renderCiWorkflow(
contract: CiGateContract,
productGates: readonly ProductGate[] = [],
@@ -117,6 +132,8 @@ export function renderCiWorkflow(
"permissions:",
" contents: read",
"",
...CONCURRENCY_LINES,
"",
"env:",
' CI: "true"',
' VITE_BUILD_ID: "gitea-${{ gitea.run_id }}-${{ gitea.run_attempt }}"',
@@ -27,6 +27,10 @@ on:
permissions:
contents: read
concurrency:
group: frontend-quality-gates-\${{ gitea.event_name }}-\${{ gitea.ref }}-\${{ inputs.stage }}
cancel-in-progress: \${{ gitea.event_name != 'workflow_dispatch' }}
env:
CI: "true"
VITE_BUILD_ID: "gitea-\${{ gitea.run_id }}-\${{ gitea.run_attempt }}"
@@ -1586,6 +1586,15 @@ describe("CI workflow generation", () => {
);
expect(first).not.toContain("process_dist_sha256");
expect(first).toContain("persist-credentials: false");
// A newer push to the same pull request or branch cancels the older run;
// a manual run never cancels a running one.
expect(first).toContain(
[
"concurrency:",
" group: frontend-quality-gates-${{ gitea.event_name }}-${{ gitea.ref }}-${{ inputs.stage }}",
" cancel-in-progress: ${{ gitea.event_name != 'workflow_dispatch' }}",
].join("\n"),
);
expect(
first.match(/corepack pnpm install --frozen-lockfile --ignore-scripts/gu),
).toHaveLength(12);