ci(pr): PR 단계를 job 하나로 접는다

문제: pr.yml은 gradle·vulnerabilities·done 세 job이고 필수 검사는 `done`이다.
`done`은 앞 두 job이 끝나야 runner 대기열에 들어가는데, Gitea는 대기열에
들어온 순서로 job을 집는다. 그래서 그사이에 줄 선 다른 run의 job이 먼저
돈다. 2026-11-08 PR #7의 run 61은 gradle이 22:55에 끝났는데 `done`은 release
수동 실행(13 job)과 main 수동 실행(30 job)이 다 끝난 01:47에야 돌았다.
job마다 checkout과 준비도 다시 한다.

고른 방법: `done` job 하나가 `./gradlew :prCheck`, `verifyStrictLaneStages
--dry-run`, Trivy 검사를 차례로 돈다. 필수 검사 이름 `pr / done
(pull_request)`은 그대로라 저장소 보호 규칙은 바꾸지 않는다. strict lane
단계 선언의 PR job을 `done`으로 바꾼다. 단계 job의 step은 `./gradlew` 한
줄만 허용했는데, 저장소 스크립트 한 줄(`bash scripts/<이름>.sh <단어>...`)도
허용한다. 자기 step이라 종료 코드가 job을 실패시키고 단계 줄의 결과를 가릴
수 없다. 셸 문법을 붙인 스크립트와 저장소 밖 명령은 여전히 막는다(TestKit
시험 셋을 더했다).

버린 대안: trivy를 Gradle Exec 태스크로 감싸 `./gradlew` 줄로 만들기. desktop
verify가 도구를 내려받아 설치하게 된다(docs/work/operate.md 4.1절이 막는다).

위험·한계: Trivy가 마지막 step이라 Gradle이 실패하면 그 PR의 취약점 결과는
Gradle을 고친 뒤에 보인다. main push와 nightly가 같은 트리를 다시 검사한다.

검증: build-logic 시험(desktop), runner에서 이 PR의 `pr / done`.
This commit is contained in:
DongHyeonka
2026-11-12 01:18:07 +09:00
parent 575aa1f766
commit deeb1126b5
10 changed files with 72 additions and 47 deletions
+12 -29
View File
@@ -1,5 +1,5 @@
# Pull-request stage. Everything here blocks a merge, and the branch protection requires one check:
# `done`. Which leaves, lanes and checks the stage means is decided by the Gradle task `prCheck`
# `done`, which is the whole stage. Which leaves, lanes and checks the stage means is decided by the Gradle task `prCheck`
# (build.gradle), not here; `verifyStrictLaneStages` fails when this job stops running it as one
# line (docs/work/reference/gates.md).
#
@@ -22,39 +22,22 @@ env:
TESTCONTAINERS_REUSE_ENABLE: "false"
jobs:
gradle:
# The whole stage is this one job, and it is the one required check (`pr / done`). Separate
# gradle, scan and `done` jobs made `done` wait for the runner a second time: a job that `needs`
# others joins the runner's queue only when they finish, behind everything queued meanwhile, and
# on 2026-11-08 that put a finished pull request's `done` three hours behind a manual main run.
# One job also pays the checkout, JDK and Gradle start once instead of twice.
#
# The scan runs last. A Gradle failure therefore hides the scan's result until it is fixed; the
# main stage and the nightly run scan the same tree again.
done:
runs-on: ubuntu-latest
timeout-minutes: 60
timeout-minutes: 75
steps:
- uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # actions/checkout@v4.2.2
- uses: ./.gitea/actions/setup-java-gradle
- run: ./gradlew :prCheck
# Plans every stage (--dry-run: nothing executes), so it cannot be a dependency of prCheck.
- run: ./gradlew :verifyStrictLaneStages --dry-run
# Known High and Critical vulnerabilities and CISA KEV matches in the dependency tree.
vulnerabilities:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # actions/checkout@v4.2.2
# Known High and Critical vulnerabilities and CISA KEV matches in the dependency tree.
- run: bash scripts/ci/trivy-scan.sh filesystem
# The one required check. A job added above joins `needs` here, and the branch protection does
# not change.
done:
needs: [gradle, vulnerabilities]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Require every job of this stage to have succeeded
env:
RESULTS: ${{ needs.gradle.result }} ${{ needs.vulnerabilities.result }}
run: |
for result in ${RESULTS}; do
if [ "${result}" != success ]; then
echo "pr / done: a job of this stage ended with ${result}"
exit 1
fi
done
echo "pr / done: every job of this stage succeeded."
+4 -4
View File
@@ -1,16 +1,16 @@
# 의존성 취약점 정책
이 정책을 강제하는 것은
[`scripts/ci/trivy-scan.sh`](../scripts/ci/trivy-scan.sh)(pull request·main·nightly workflow의
`vulnerabilities` job과 release workflow의 이미지 job이 부른다),
[`scripts/ci/trivy-scan.sh`](../scripts/ci/trivy-scan.sh)(pull request workflow의 `done` job, main·nightly
workflow의 `vulnerabilities` job, release workflow의 이미지 job이 부른다),
[`../.trivyignore.yaml`](../.trivyignore.yaml), CODEOWNERS,
[`../renovate.json`](../renovate.json)이다.
## 실행 위치와 플랫폼 경계
workflow는 `.gitea/workflows`의 `pr.yml`·`main.yml`·`release.yml`이고 Gitea Actions(desktop runner)에서 돈다.
`vulnerabilities` job은 pull request, `main` push, 매일 예약 실행, 손으로 부른 실행에서 돈다. pull request의
필수 검사 `pr / done`이 그 결과를 포함한다.
검사는 pull request(필수 검사 `pr / done`의 마지막 step), `main` push, 매일 예약 실행, 손으로 부른 실행에서
돈다.
외부 action은 확인한 전체 커밋 SHA로만 실행한다. 리뷰를 위해 같은 줄 주석에 바뀌지 않는 릴리스 태그를
남긴다. 스캐너는 action이 아니라 체크섬을 고정한 릴리스 실행 파일이다.
+1 -1
View File
@@ -26,7 +26,7 @@ registry, settings, build-logic, 루트 라이프사이클이 정하는 것을
## 단계 job의 모양
- `verifyStrictLaneStages --dry-run`(PR)은 `explicitOnly`가 아닌 strict lane마다 `build.gradle`의 `strictLaneStages`가 선언한 단계 태스크 하나의 계획에 들어 있는지 본다(그래프 검사).
- 단계마다 선언한 workflow job은 step의 `run: ./gradlew <단계> <옵션>` 줄을 가지고, 다른 step `run:`도 셸 문법 없는 `./gradlew` 한 줄이며, 선언 밖의 `if:`, 선언한 조건이 `!cancelled()`·`always()`가 아닌데 `needs:`, `continue-on-error`·`shell:`·`defaults:`, 따옴표 키·flow 형식, 이 빌드 밖의 `working-directory`가 없다. workflow는 선언한 이벤트로, 선언한 필터 한 줄만 달고 시작하고, PR 단계 job 하나가 이 검사를 돌린다(형식 검사, 셸을 해석하지 않는다).
- 단계마다 선언한 workflow job은 step의 `run: ./gradlew <단계> <옵션>` 줄을 가지고, 다른 step `run:`도 셸 문법 없는 `./gradlew` 한 줄이나 `bash scripts/<이름>.sh` 한 줄이며, 선언 밖의 `if:`, 선언한 조건이 `!cancelled()`·`always()`가 아닌데 `needs:`, `continue-on-error`·`shell:`·`defaults:`, 따옴표 키·flow 형식, 이 빌드 밖의 `working-directory`가 없다. workflow는 선언한 이벤트로, 선언한 필터 한 줄만 달고 시작하고, PR 단계 job 하나가 이 검사를 돌린다(형식 검사, 셸을 해석하지 않는다).
- 단계를 더하거나 job을 바꾸면 `strictLaneStages`의 `stage` 줄과 workflow를 같은 커밋에서 고친다.
## 테스트
@@ -13,7 +13,7 @@ import org.gradle.api.file.DirectoryProperty;
* <pre>
* strictLaneStages {
* workflowDirectory = layout.projectDirectory.dir('.gitea/workflows')
* stage ':prCheck', workflow: 'pr.yml', event: 'pull_request', job: 'gradle'
* stage ':prCheck', workflow: 'pr.yml', event: 'pull_request', job: 'done'
* stage ':mainCheck', workflow: 'main.yml', event: 'push', filter: 'branches: [main]',
* job: 'main', options: '--continue'
* stage ':performanceCheck', workflow: 'main.yml', event: 'schedule', job: 'performance',
@@ -33,8 +33,9 @@ import org.gradle.api.execution.TaskExecutionGraph;
* declared stage. The plan is Gradle's own: this task depends on the stages, so its {@code
* --dry-run} builds the real plan, and the check reads it when the graph is ready.
* <li><b>Form.</b> Each stage names the workflow job that runs it, and that job has one shape.
* Its steps' {@code run:} lines are single {@code ./gradlew} commands with no shell syntax, and
* one of them is {@code ./gradlew <stage> <options>}. It has no {@code if:} but the declared
* Its steps' {@code run:} lines are single {@code ./gradlew} commands or single {@code bash
* scripts/<name>.sh} commands with no shell syntax, and one of them is {@code ./gradlew
* <stage> <options>}. It has no {@code if:} but the declared
* condition, no {@code needs:} unless that condition runs it after a skipped or failed job, no
* {@code continue-on-error}, {@code shell:} or {@code defaults:}, no quoted keys or flow
* mappings, and every {@code working-directory} in it or in the workflow's {@code defaults}
@@ -59,6 +60,9 @@ public final class StrictLaneStagesPlugin implements Plugin<Project> {
private static final Pattern STEP_RUN = Pattern.compile("^(?: {6}- | {8})run: (.*?)\\s*$");
/** One Gradle invocation and nothing a shell would read as more than words. */
private static final Pattern GRADLE_LINE = Pattern.compile("^\\./gradlew(?: [\\w:.=-]+)+$");
/** One repository script and plain words: its own step, so its exit code fails the job. */
private static final Pattern REPOSITORY_SCRIPT =
Pattern.compile("^bash scripts/[\\w./-]+\\.sh(?: [\\w:.=/-]+)*$");
private static final Pattern IF = Pattern.compile("^(\\s*)(?:-\\s+)?if:\\s*(.*?)\\s*$");
private static final Pattern WORKING_DIRECTORY =
Pattern.compile("^\\s*(?:-\\s+)?working-directory:\\s*(.*?)\\s*$");
@@ -252,8 +256,13 @@ public final class StrictLaneStagesPlugin implements Plugin<Project> {
Matcher run = STEP_RUN.matcher(line);
if (!run.matches()) {
problems.add(where + " has `" + line.strip() + "`, which is not a step's command");
} else if (!GRADLE_LINE.matcher(run.group(1)).matches()) {
problems.add(where + " runs `" + run.group(1) + "`, which is not one ./gradlew line");
} else if (!GRADLE_LINE.matcher(run.group(1)).matches()
&& !REPOSITORY_SCRIPT.matcher(run.group(1)).matches()) {
problems.add(
where
+ " runs `"
+ run.group(1)
+ "`, which is not one ./gradlew line or one repository script");
} else {
runsStage |= run.group(1).equals(stage.command());
}
@@ -107,6 +107,24 @@ class StrictLaneStagesFunctionalTest {
assertThat(result.getOutput()).contains("every strict lane is in a stage its workflow job runs");
}
@Test
@DisplayName("단계 job에 저장소 스크립트 한 줄 step이 있어도 통과한다")
void passesWithARepositoryScriptStepBesideTheStageLine() throws Exception {
// given
workflow(
"pr.yml",
PR_WORKFLOW.replace(
" - run: ./gradlew :verifyStrictLaneStages --dry-run\n",
" - run: ./gradlew :verifyStrictLaneStages --dry-run\n"
+ " - run: bash scripts/ci/trivy-scan.sh filesystem\n"));
// when
BuildResult result = runner(":verifyStrictLaneStages", "--dry-run").build();
// then
assertThat(result.getOutput()).contains("every strict lane is in a stage its workflow job runs");
}
@Test
@DisplayName("① 어느 단계에도 들지 않는 strict lane을 더하면 그 lane 이름으로 실패한다")
void failsNamingALaneThatNoStageReaches() throws Exception {
@@ -189,6 +207,21 @@ class StrictLaneStagesFunctionalTest {
"- run: ./gradlew :verifyStrictLaneStages --dry-run\n",
"- run: ./gradlew :verifyStrictLaneStages --dry-run\n - run: exit 0\n",
"pr.yml job gradle runs `exit 0`, which is not one ./gradlew line"),
Arguments.of(
"셸로 이은 저장소 스크립트",
"pr.yml",
"- run: ./gradlew :verifyStrictLaneStages --dry-run\n",
"- run: ./gradlew :verifyStrictLaneStages --dry-run\n"
+ " - run: bash scripts/ci/scan.sh filesystem || true\n",
"pr.yml job gradle runs `bash scripts/ci/scan.sh filesystem || true`, which is not one"
+ " ./gradlew line or one repository script"),
Arguments.of(
"저장소 밖 스크립트",
"pr.yml",
"- run: ./gradlew :verifyStrictLaneStages --dry-run\n",
"- run: ./gradlew :verifyStrictLaneStages --dry-run\n"
+ " - run: bash -c 'exit 0'\n",
"pr.yml job gradle runs `bash -c 'exit 0'`, which is not one ./gradlew line"),
Arguments.of(
"셸로 이은 명령",
"pr.yml",
+1 -1
View File
@@ -242,7 +242,7 @@ tasks.register('prCheck') {
// nightly, after the other heavy jobs, on a runner nothing else is using (owner decision 2026-11-07).
strictLaneStages {
workflowDirectory = layout.projectDirectory.dir('.gitea/workflows')
stage ':prCheck', workflow: 'pr.yml', event: 'pull_request', job: 'gradle'
stage ':prCheck', workflow: 'pr.yml', event: 'pull_request', job: 'done'
stage ':mainCheck', workflow: 'main.yml', event: 'push', filter: 'branches: [main]', job: 'main',
options: '--continue'
stage ':integrationCheck', workflow: 'main.yml', event: 'push', filter: 'branches: [main]', job: 'integration',
+2 -2
View File
@@ -197,8 +197,8 @@ drift하기 시작하면 그때 자동화한다. 진짜 항목을 상대로, 진
> `.github/scripts/verify-gate-matrix.sh`(568줄)는 삭제했다. 그 표는 이미 두 그래프에 있는 정보의
> 세 번째 사본이었고, 검사기는 세 사본을 서로 같게 유지하는 일을 했다. 결과적으로 체크 하나를
> 추가하려면 Gradle · workflow · 표 · 검사기 기대값 · Java 계약 테스트 다섯 곳을 같이 고쳐야 했다.
- **워크플로.** `.gitea/workflows/`의 세 파일이다. `pr.yml`의 `done` job이 PR 단계의 모든 job(`gradle`:
`./gradlew :prCheck`와 `verifyStrictLaneStages --dry-run`, `vulnerabilities`: Trivy)을 모으는 단일 필수 검사다.
- **워크플로.** `.gitea/workflows/`의 세 파일이다. `pr.yml`의 `done` job 하나가 PR 단계 전체(`./gradlew :prCheck`,
`verifyStrictLaneStages --dry-run`, Trivy)이고 단일 필수 검사다. job을 나누면 뒤 job이 runner 대기열 맨 뒤로 간다.
`main.yml`이 main 단계(`mainCheck`·`integrationCheck`·build-logic 시험·configuration cache·링크)와
nightly(행렬 job, compose smoke, 마지막에 `performanceCheck`)를, `release.yml`이 태그 단계를 돌린다.
무엇을 돌릴지는 Gradle 단계 태스크가 정하고, `verifyStrictLaneStages`가 단계 job의 모양을 지킨다.
+1 -1
View File
@@ -31,7 +31,7 @@
| `pr.yml`(`./gradlew :prCheck`, 필수 검사 `pr / done`) | PR 단계. 무엇을 돌리는지는 Gradle 태스크 `prCheck`가 정한다 |
| `main.yml`의 `main`·`integration`·`build-logic`·`configuration-cache` job | main 단계(`mainCheck`, `integrationCheck`) |
| `main.yml`의 `performance` job | nightly 성능 단계(`performanceCheck`) |
| `vulnerabilities` job(`scripts/ci/trivy-scan.sh`) | Trivy와 CISA KEV |
| `pr.yml` `done`의 Trivy step과 `main.yml`의 `vulnerabilities` job(`scripts/ci/trivy-scan.sh`) | Trivy와 CISA KEV |
| `release.yml` | `releaseCheck`, 이미지 · SBOM · 서명 |
| `scripts/verify.sh` | 사람·세션이 workflow와 같은 단계를 돌리는 진입점 |
| `prCheck`의 `documentCheck`·`testDocumentChecks` | 문서 규칙(`scripts/check-docs.py`: 언어·머리 블록·참조·숫자·지도·링크·문체)과 Gradle 밖 스크립트·편집 훅의 시험(`scripts/tests/`). 파생 서비스의 문서도 같은 규칙을 따른다(`docs/README.md`) |
+4 -4
View File
@@ -16,14 +16,14 @@ Gradle 명령과 `scripts/verify.sh`는 모두 저장소 루트(Gradle 루트)
| --- | --- | --- |
| `docs` | `check-work-docs.py`, `check-docs.py`, `scripts/tests` 자기 시험, `check-repo-layout.py`(Gradle 없음, 노트북 가능) | `pr.yml`의 `prCheck` 안 |
| `leaf <gradle-path>` | 그 leaf의 `check` | — |
| `pr` | `./gradlew :prCheck`, `./gradlew :verifyStrictLaneStages --dry-run` | `pr.yml` `gradle` |
| `pr` | `./gradlew :prCheck`, `./gradlew :verifyStrictLaneStages --dry-run` | `pr.yml` `done` |
| `main` | `:mainCheck --continue`, `:integrationCheck --continue`, `-p build-logic test`, `scripts/ci/verify-configuration-cache.sh` | `main.yml`(push) |
| `nightly` | compose smoke 전부, 마지막에 `:performanceCheck --continue` | `main.yml`(schedule·수동) |
| `release` | `:releaseCheck`(지금 커밋을 provenance로) | `release.yml` `release` |
| `app` | `scripts/bootstrap-local.sh`(앱을 띄워 health와 기본 endpoint 확인) | — |
| `round` | `pr` → `main` → `nightly` → `release`, 첫 실패에서 멈춘다 | — |
workflow에만 있는 job: `pr.yml`·`main.yml`의 `vulnerabilities`(trivy, `scripts/ci/trivy-scan.sh`), `main.yml`의 `links`(lychee), nightly 행렬(`jpa-postgresql`·`httpclient-transport`·`redis-topology`·`fileserver-nfs-ambiguity`·`notification-chaos`·`jpa-next`), `release.yml`의 release lane과 이미지 job. 도구를 내려받거나 runner 환경이 필요해 `verify.sh`에 넣지 않았다. 손으로 돌리는 법은 3절 (다)다.
workflow에만 있는 job: `pr.yml` `done`의 마지막 step과 `main.yml`의 `vulnerabilities`(trivy, `scripts/ci/trivy-scan.sh`), `main.yml`의 `links`(lychee), nightly 행렬(`jpa-postgresql`·`httpclient-transport`·`redis-topology`·`fileserver-nfs-ambiguity`·`notification-chaos`·`jpa-next`), `release.yml`의 release lane과 이미지 job. 도구를 내려받거나 runner 환경이 필요해 `verify.sh`에 넣지 않았다. 손으로 돌리는 법은 3절 (다)다.
게이트 하나씩:
@@ -35,8 +35,8 @@ workflow에만 있는 job: `pr.yml`·`main.yml`의 `vulnerabilities`(trivy, `scr
| `qualityCheck` | SpotBugs, FindSecBugs(운영 코드) | PR(`ci` 안) | `build.gradle` |
| `testQualityCheck` | 같은 분석을 모든 테스트 source set에(`config/spotbugs/exclude-test.xml` 기준) | main(`mainCheck` 안) | `build.gradle` |
| `ci` | leaf `check`(API surface 포함) + `architectureCheck` + `qualityCheck` | PR(`prCheck` 안) | `build.gradle` |
| `prCheck` | `ci` + `verifyDependencyLocks` + `verifyComposeProfiles`(compose lane이 선언대로 렌더링되는가) + `verifyRepositoryLayout`(`check-repo-layout.py`) + `documentCheck`(`check-docs.py`, 앞에 `scripts/tests` 자기 시험) | PR | `pr.yml` `gradle`: `./gradlew :prCheck` |
| `verifyStrictLaneStages --dry-run` | `explicitOnly`가 아닌 strict lane이 단계 태스크 하나의 계획에 들어 있는가(그래프 검사), 단계마다 선언한 workflow job이 `./gradlew <단계>` 한 줄을 정해진 조건으로 돌리는가(형식 검사) | PR | `pr.yml` `gradle` 둘째 줄. 형식은 `build-logic/AGENTS.md` |
| `prCheck` | `ci` + `verifyDependencyLocks` + `verifyComposeProfiles`(compose lane이 선언대로 렌더링되는가) + `verifyRepositoryLayout`(`check-repo-layout.py`) + `documentCheck`(`check-docs.py`, 앞에 `scripts/tests` 자기 시험) | PR | `pr.yml` `done`: `./gradlew :prCheck` |
| `verifyStrictLaneStages --dry-run` | `explicitOnly`가 아닌 strict lane이 단계 태스크 하나의 계획에 들어 있는가(그래프 검사), 단계마다 선언한 workflow job이 `./gradlew <단계>` 한 줄을 정해진 조건으로 돌리는가(형식 검사) | PR | `pr.yml` `done` 둘째 줄. 형식은 `build-logic/AGENTS.md` |
| `python3 scripts/check-repo-layout.py` | 저장소 루트와 `src/` 최상위에 허용 목록 밖의 항목이 없는가, registry 경로가 허용 폴더 안인가. 아무도 가리키지 않는 compose·스크립트 파일은 경고 | PR(`prCheck` 안) | `verifyRepositoryLayout` |
| `python3 scripts/check-docs.py` | 살아 있는 문서의 언어, 기록·ADR 머리 블록, 문서의 인라인 코드 경로·Gradle 경로가 지금 있는가, 복사한 숫자, 상대 링크(`docs/README.md` 「문서 검사」) | PR(`prCheck` 안) | `documentCheck` |
| `mainCheck` | `configContractCheck` + `qualificationCheck`(`testQualityCheck` 포함) + 공개 경로 스냅숏 + 전송·메시징 qualification lane + 생성 명령 왕복(`verifyFeatureScaffold`) + 모든 leaf의 `mainCheck`(document-contract lane 등) | main | `main.yml` `main`: `./gradlew :mainCheck --continue` |