fix(strict-lane)!: 태그 push·release로만 도는 workflow는 releaseCheck에만 센다
문제: verifyStrictLaneStages의 workflow 판독기는 `push: tags:`만 있거나
`release` trigger만 있는 workflow의 명령을 모든 단계의 실행으로 센다.
태그 push는 매 변경에 돌지 않는데, 그런 workflow에만 `:integrationCheck`
같은 단계를 두어도 검사가 통과한다(round7 05 「Declined to judge」 ①).
고른 방법: 소유자 결정(2026-11-07, "권하는 안대로", 리뷰 README 18.4절
(a))대로, 요청이나 경로 필터 없이 시작하는 trigger가 release 흐름뿐인
workflow — `release`, 또는 `branches`·`branches-ignore` 없이
`tags`·`tags-ignore`가 있는 `push` — 의 명령은 `:releaseCheck`에만
센다. 경로 필터 결정(2026-11-06)과 같은 원칙이다. 판독기는 trigger를
변경·release·경로 필터·요청 넷으로 나누고, workflow의 시작을 "매 변경 /
release 흐름만 / 돌지 않을 수 있음" 셋으로 낸다. release 흐름만인
workflow를 부르는 재사용 workflow도 같다. Invocation에 releaseFlowReason을
두고, whyNotExecuting(taskPath, buildDirectory)가 `:releaseCheck` 밖의
단계에 그 이유를 준다. 실패 메시지, AGENTS.md, src/README.md,
build-logic/README.md, 업그레이드 안내 B-36, 결정 색인 2.7절을 고쳤다.
버린 대안: 지금처럼 모든 단계에 세고 문서에 적는다 — 소유자가 위 안을
골랐다. release 단계 이름을 빌드 설정(`strictLaneStages`)으로 받는다 —
결정이 `releaseCheck`를 이름으로 정했고, 파생 서비스 설정 표면이 늘어
판독기 상수로 두었다.
위험·한계: 파생 서비스가 `releaseCheck`가 아닌 단계를 태그·release
workflow에서만 돌리면 이제 verifyStrictLaneStages --dry-run이 실패한다.
이 repo의 release.yml은 `-p optional-platforms integrationCheck`도
돌리지만 integration-main.yml(main push·nightly)이 같은 단계를 돌려
판정이 그대로다(두 빌드 확인). release의 `types`는 보지 않는다.
`branches`와 `tags`를 함께 둔 push는 지금처럼 모든 단계에 센다.
검증(desktop, 로그 ~/r8-f5b-logs/):
- RED: 기준 ac3c6a81에 테스트만 얹음. 68건 중 2건 실패 —
WorkflowGradleInvocationsTest(세 workflow의 :integrationCheck가
실행으로 셈), StrictLaneStagesFunctionalTest(UnexpectedBuildSuccess,
"every strict lane is in an executed stage")
(red-release-flow.log, TEST-*.xml)
- GREEN: 같은 두 클래스 46건·22건 실패 0 (green-release-flow.log)
- -p build-logic check javadoc rc=0(build-logic 테스트 173건 실패 0),
:verifyStrictLaneStages --dry-run, -p optional-platforms
:verifyStrictLaneStages --dry-run rc=0(둘 다 "every strict lane is in
an executed stage"), check-work-docs.py와 상대 링크 검사 rc=0
(summary.txt)
Refs: docs/reviews/2026-11-03-rereview/README.md 18.4절(cb340001)
BREAKING CHANGE: `releaseCheck`가 아닌 단계(:ci, :mainCheck, :integrationCheck, :performanceCheck 등)를 태그 push(`branches` 없는 `tags`)나 `release` trigger로만 시작하는 workflow에서만 돌리면 verifyStrictLaneStages --dry-run이 실패한다. 그 단계를 매 push·pull_request·schedule에 도는 workflow에서도 돌린다(docs/upgrade/2026-11-maturity-review.md B-36).
This commit is contained in:
@@ -99,7 +99,8 @@ root `CLAUDE.md`는 작업을 시작할 때 읽는 지도이고, 이 목록을
|
||||
부른 함수 안의 `exit 0`(인자 없는 `exit`, 값을 모르는 `exit` 포함)·`exec`·`set -n` 뒤, 상태
|
||||
함수(`always()`·`success()`·`!cancelled()`)가 아닌 `if:` 아래, 요청으로만
|
||||
시작하는 workflow(`workflow_dispatch`·`repository_dispatch`·`issue_comment` 등), `paths`·`paths-ignore`
|
||||
필터가 붙은 change trigger로만 시작하는 workflow(그 경로 밖 변경에는 돌지 않는다), 세는 job이
|
||||
필터가 붙은 change trigger로만 시작하는 workflow(그 경로 밖 변경에는 돌지 않는다), 태그 push(`branches`
|
||||
없는 `tags`)나 `release`로만 시작하는 workflow(`releaseCheck` 밖의 단계), 세는 job이
|
||||
부르지 않는 `workflow_call` 재사용 workflow, 조건부이거나 `continue-on-error`인 job을 `needs`로 기다리는
|
||||
job.
|
||||
(3) 실패하면 단계도 실패하지만 검사가 읽지 않는다: `|| exit 1`, `{ }`·`( )`·`$( )`·`bash -c` 안, 다른
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -177,6 +177,7 @@
|
||||
| 에이전트가 원칙에서 바로 정한 것 | Kafka 주소 키 하나, composition이 persistence-jpa를 함께 가져옴 등 7건 | 기본값 | `docs/reviews/2026-09-25-review-followup-status.md` 「소유자 결정」 끝 목록 |
|
||||
| 묶음별 기본값 | 각 라운드 처리 표의 「결정」 칸(예: SES replay 창 1h, Retry-After 30) | 기본값 | `1101` 13·14·16절, `1103` 6·10·12·15·16·17절 표 |
|
||||
| 경로 필터 workflow와 단계 검사 | `paths:`·`paths-ignore:` trigger만 있는 workflow는 strict lane 단계 실행으로 세지 않는다 | 소유자 | `1103` 18.4절(RR7-05-01), 2026-11-06 |
|
||||
| 태그·릴리스 workflow와 단계 검사 | `push`에 `tags:`만 있거나(`branches`·`paths` 없이) `release` trigger만 있는 workflow는 `releaseCheck` 단계에서만 실행으로 센다. 다른 단계(pull request·main·nightly)로는 세지 않는다 | 소유자 | `1103` 18.4절(round7 05 Declined ①), 2026-11-07 |
|
||||
|
||||
## 3. 새 결정을 기록하는 법
|
||||
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ Checkstyle은 **포매터가 표현할 수 없는 것만** — 네이밍과 몇
|
||||
| `qualificationCheck` | 전체 기동(system) 레인과 보조 source set Checkstyle을 실행 |
|
||||
| `integrationCheck` | 선언된 strict integration lane(sample 포함)을 실행. 대부분 container runtime이 필요. 입력이 필요한 lane(Redis topology: `-Predis.topology.mode`, AWS: 보호 자격 증명 env)은 입력이 없으면 빠지고 집계가 그 이유를 출력 |
|
||||
| `performanceCheck` | 선언된 strict performance lane(부하·종료·pool·자원 상한)을 실행. 실서버·container가 필요. 상한은 매번 단언하고 끄는 속성이 없다(`-Pperformance.assertions.enabled`가 `true`가 아니면 실패, skip된 테스트가 있어도 실패). `integration-main.yml` `performance-check`가 main·nightly에 같은 명령으로 돌림 |
|
||||
| `verifyStrictLaneStages` | `--dry-run` 전용. `explicitOnly`가 아닌 strict lane이 workflow가 실제 실행하는 단계(`ci`·`:sample-portfolio:check`·`mainCheck`·`integrationCheck`·`performanceCheck`·`releaseCheck`) 중 하나의 계획에 있는지, 각 단계를 workflow가 `--dry-run` 없이 실행하는지 검사. Gradle이 작업을 돌리지 않는 명령(`--dry-run`·`-v`·`--help` 등)과, 실패해도 단계가 실패하지 않을 수 있거나(`\|\| true`, pipefail 없는 파이프, `if` 조건 등) 돌지 않을 수 있거나(조건부 `exit 0` 뒤, 요청으로만 시작하는 workflow, `paths` 필터로만 시작하는 workflow 등) 검사가 읽지 않는(`\|\| exit 1`, `{ }` 안 등) 명령은 실행으로 세지 않는다. 자세한 목록은 `build-logic/README.md`. PR 게이트가 돌림 |
|
||||
| `verifyStrictLaneStages` | `--dry-run` 전용. `explicitOnly`가 아닌 strict lane이 workflow가 실제 실행하는 단계(`ci`·`:sample-portfolio:check`·`mainCheck`·`integrationCheck`·`performanceCheck`·`releaseCheck`) 중 하나의 계획에 있는지, 각 단계를 workflow가 `--dry-run` 없이 실행하는지 검사. Gradle이 작업을 돌리지 않는 명령(`--dry-run`·`-v`·`--help` 등)과, 실패해도 단계가 실패하지 않을 수 있거나(`\|\| true`, pipefail 없는 파이프, `if` 조건 등) 돌지 않을 수 있거나(조건부 `exit 0` 뒤, 요청으로만 시작하는 workflow, `paths` 필터로만 시작하는 workflow, `releaseCheck` 밖의 단계를 태그 push·`release`로만 시작하는 workflow 등) 검사가 읽지 않는(`\|\| exit 1`, `{ }` 안 등) 명령은 실행으로 세지 않는다. 자세한 목록은 `build-logic/README.md`. PR 게이트가 돌림 |
|
||||
| `ci` | PR 게이트: 모든 leaf `check`(API surface 검사 포함, 소유자 결정 20) + `architectureCheck` + `qualityCheck` |
|
||||
| `mainCheck` | main 단계: `configContractCheck` + `qualificationCheck` + sample web 계약 + sample 전체 기동(`:sample-portfolio:systemTest`) + `verifyPublicPathSnapshot` + 전송·메시징 qualification 레인 + 각 leaf의 `mainCheck`(문서 대조 레인 `*DocumentContractTest`, objectstorage MinIO 레인) |
|
||||
| `releaseCheck` | tag 전용 검사: `verifyReleaseProvenance` + `verifyPublicPathSnapshot`(`ci`를 다시 돌리지 않음) |
|
||||
|
||||
File diff suppressed because one or more lines are too long
+6
-4
@@ -34,7 +34,7 @@ import org.gradle.api.execution.TaskExecutionGraph;
|
||||
* the way Gradle matches it, abbreviations included ({@link TaskSelectors});
|
||||
* <li>every declared stage is executed by a workflow. Not counted ({@code NOT_COUNTED}; review
|
||||
* 2026-11-03 RR-06-04, 2026-11-04 RR2-04-04, RR5-02-02, 2026-11-05 RR6-04-01..06, 2026-11-06
|
||||
* RR7-05-01): a command
|
||||
* RR7-05-01, owner decision 2026-11-07 on the release flow): a command
|
||||
* after which Gradle runs no task ({@code --dry-run}, {@code -v}, {@code --help}, …) or that
|
||||
* Gradle rejects (a short-option bundle such as {@code -mx}), one for another build, and one
|
||||
* that does not gate for one of three reasons — its failure may not fail its step, it may not
|
||||
@@ -69,13 +69,15 @@ public final class StrictLaneStagesPlugin implements Plugin<Project> {
|
||||
+ " exec or set -n, under an if: other than always()/success()/!cancelled(), in a"
|
||||
+ " workflow that starts only on a request, or on changes only through a paths or"
|
||||
+ " paths-ignore filter, or a reusable one no counted job calls, in a"
|
||||
+ " job that needs a job that may be skipped); and one this check does not read although"
|
||||
+ " job that needs a job that may be skipped, and for any stage but :releaseCheck in a"
|
||||
+ " workflow that starts only on a tag push or a release); and one this check does not"
|
||||
+ " read although"
|
||||
+ " its failure"
|
||||
+ " would fail the step (|| exit 1, inside { } or ( ), $( ), bash -c, gradlew as"
|
||||
+ " another command's argument, after a cd it does not follow, a shell other than bash"
|
||||
+ " or sh, a runner that may be Windows). Run the stage as ./gradlew on a line of its"
|
||||
+ " own, in a step and job that run on every push, pull request or schedule, with no"
|
||||
+ " paths or paths-ignore filter";
|
||||
+ " paths or paths-ignore filter (:releaseCheck may run on a tag push or a release)";
|
||||
|
||||
@Override
|
||||
public void apply(Project project) {
|
||||
@@ -231,7 +233,7 @@ public final class StrictLaneStagesPlugin implements Plugin<Project> {
|
||||
+ ": gradlew "
|
||||
+ String.join(" ", invocation.tasks())
|
||||
+ " — "
|
||||
+ invocation.whyNotExecuting(buildDirectory))));
|
||||
+ invocation.whyNotExecuting(stage, buildDirectory))));
|
||||
return lines.isEmpty()
|
||||
? ""
|
||||
: "; commands that name it but do not count:\n " + String.join("\n ", lines);
|
||||
|
||||
+172
-58
@@ -2,6 +2,7 @@ package dev.caskeleton.buildlogic.strictlane;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Deque;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -46,8 +47,11 @@ import java.util.regex.Pattern;
|
||||
* types} list, only when it holds {@code opened}, {@code synchronize} or {@code reopened}), {@code
|
||||
* merge_group}, {@code schedule}, {@code release} — and has no {@code paths} or {@code
|
||||
* paths-ignore} filter: a change that touches none of the listed paths, or only ignored ones, does
|
||||
* not start it (owner decision 2026-11-06, review RR7-05-01). Its {@code branches} and {@code tags}
|
||||
* filters are not read. One that starts only on other events — {@code
|
||||
* not start it (owner decision 2026-11-06, review RR7-05-01). A workflow whose only such triggers
|
||||
* are the release flow — {@code release}, or a {@code push} with {@code tags} or {@code
|
||||
* tags-ignore} and no {@code branches} or {@code branches-ignore}, which a branch push does not
|
||||
* start — counts only for {@code :releaseCheck}, the tag-only stage (owner decision 2026-11-07).
|
||||
* One that starts only on other events — {@code
|
||||
* workflow_dispatch}, {@code repository_dispatch}, {@code issue_comment}, a {@code labeled} pull
|
||||
* request, {@code workflow_run} and the rest — runs only when someone or something asks (review
|
||||
* 2026-11-04 RR2-04-04, RR6-04-06). A workflow that starts only on {@code workflow_call} counts
|
||||
@@ -103,6 +107,13 @@ public final class WorkflowGradleInvocations {
|
||||
Set.of("opened", "synchronize", "reopened");
|
||||
/** The trigger filters that start a workflow only for changes to some files. */
|
||||
private static final List<String> PATH_FILTERS = List.of("paths", "paths-ignore");
|
||||
/** The push filters that start it for tags; with no branch filter, a branch push does not. */
|
||||
private static final List<String> TAG_FILTERS = List.of("tags", "tags-ignore");
|
||||
private static final List<String> BRANCH_FILTERS = List.of("branches", "branches-ignore");
|
||||
private static final List<String> FILTERS =
|
||||
List.of("paths", "paths-ignore", "tags", "tags-ignore", "branches", "branches-ignore");
|
||||
/** The only stage a workflow of the release flow counts for: the tag-only one. */
|
||||
private static final String RELEASE_STAGE = ":releaseCheck";
|
||||
private static final String REUSABLE_WORKFLOWS = "./.github/workflows/";
|
||||
/**
|
||||
* Gradle 9.0's command-line options that take a value, by every name it accepts. Probed against
|
||||
@@ -176,6 +187,8 @@ public final class WorkflowGradleInvocations {
|
||||
* @param uncountedReason why the command gates nothing although it names tasks — it may not run,
|
||||
* its failure may not fail its step, this reader does not read it, or Gradle runs no task —
|
||||
* or {@code null}
|
||||
* @param releaseFlowReason why the command gates only {@code :releaseCheck} — its workflow
|
||||
* starts, of the triggers that need no request, only on the release flow — or {@code null}
|
||||
*/
|
||||
public record Invocation(
|
||||
String workingDirectory,
|
||||
@@ -183,12 +196,18 @@ public final class WorkflowGradleInvocations {
|
||||
List<String> tasks,
|
||||
boolean dryRun,
|
||||
List<String> excludedTasks,
|
||||
String uncountedReason) {
|
||||
String uncountedReason,
|
||||
String releaseFlowReason) {
|
||||
public Invocation {
|
||||
tasks = List.copyOf(tasks);
|
||||
excludedTasks = List.copyOf(excludedTasks);
|
||||
}
|
||||
|
||||
private Invocation releaseFlowOnly(String reason) {
|
||||
return new Invocation(
|
||||
workingDirectory, projectDir, tasks, dryRun, excludedTasks, uncountedReason, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* The directory of the build this command starts, from the repository root: the step's working
|
||||
* directory joined with {@code -p}. {@code .} is the repository root.
|
||||
@@ -206,11 +225,24 @@ public final class WorkflowGradleInvocations {
|
||||
* the repository root such as {@code src}.
|
||||
*/
|
||||
public boolean executes(String taskPath, String buildDirectory) {
|
||||
return requests(taskPath) && whyNotExecuting(buildDirectory) == null;
|
||||
return requests(taskPath) && whyNotExecuting(taskPath, buildDirectory) == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Why this command does not execute and gate on the tasks it names in the build in {@code
|
||||
* Why this command does not execute and gate on the task at {@code taskPath} in the build in
|
||||
* {@code buildDirectory}, or {@code null} when it does: a reason that holds for every task it
|
||||
* names, or that its workflow is of the release flow and the task is not {@code :releaseCheck}.
|
||||
*/
|
||||
public String whyNotExecuting(String taskPath, String buildDirectory) {
|
||||
String reason = whyNotExecuting(buildDirectory);
|
||||
if (reason != null || releaseFlowReason == null) {
|
||||
return reason;
|
||||
}
|
||||
return absolute(taskPath).equals(RELEASE_STAGE) ? null : releaseFlowReason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Why this command does not execute and gate on any task it names in the build in {@code
|
||||
* buildDirectory}, or {@code null} when it does: its uncounted reason, another build, or a dry
|
||||
* run.
|
||||
*/
|
||||
@@ -270,9 +302,39 @@ public final class WorkflowGradleInvocations {
|
||||
*
|
||||
* @param types its {@code types} list, or {@code null} when it has none
|
||||
* @param pathFilters which of {@code paths} and {@code paths-ignore} it has
|
||||
* @param tagsOnly whether it filters tags and no branches, so that only a tag push starts it
|
||||
*/
|
||||
private record Trigger(List<String> types, List<String> pathFilters) {
|
||||
private static final Trigger UNFILTERED = new Trigger(null, List.of());
|
||||
private record Trigger(List<String> types, List<String> pathFilters, boolean tagsOnly) {
|
||||
private static final Trigger UNFILTERED = new Trigger(null, List.of(), false);
|
||||
|
||||
private static Trigger of(List<String> types, Collection<String> filters) {
|
||||
return new Trigger(
|
||||
types,
|
||||
PATH_FILTERS.stream().filter(filters::contains).toList(),
|
||||
TAG_FILTERS.stream().anyMatch(filters::contains)
|
||||
&& BRANCH_FILTERS.stream().noneMatch(filters::contains));
|
||||
}
|
||||
}
|
||||
|
||||
/** How a trigger takes part in the stages (owner decisions 2026-11-06 and 2026-11-07). */
|
||||
private enum Flow {
|
||||
/** Starts on every change: counts for every stage. */
|
||||
CHANGE,
|
||||
/** Starts on a release or a tag push: counts for {@code :releaseCheck} only. */
|
||||
RELEASE,
|
||||
/** Starts on a change only when it touches some files: counts for no stage. */
|
||||
PATH_FILTERED,
|
||||
/** Starts only when someone or something asks: counts for no stage. */
|
||||
REQUEST
|
||||
}
|
||||
|
||||
/**
|
||||
* When a workflow starts, as the stages see it: on every change (both {@code null}), only on
|
||||
* the release flow ({@code releaseFlow} says why it counts for {@code :releaseCheck} alone), or
|
||||
* not without being asked ({@code notStarted} says why).
|
||||
*/
|
||||
private record Start(String notStarted, String releaseFlow) {
|
||||
private static final Start EVERY_CHANGE = new Start(null, null);
|
||||
}
|
||||
|
||||
/** A job: its id, the line of its key, and the column of its own keys (-1 when it has none). */
|
||||
@@ -304,10 +366,13 @@ public final class WorkflowGradleInvocations {
|
||||
workflowsByFile.forEach((file, text) -> workflows.put(file, parse(file, text)));
|
||||
Map<String, List<Invocation>> invocations = new LinkedHashMap<>();
|
||||
for (Workflow workflow : workflows.values()) {
|
||||
String notStarted = startReason(workflow, workflows, new HashSet<>());
|
||||
Start start = start(workflow, workflows, new HashSet<>());
|
||||
List<Invocation> commands = new ArrayList<>();
|
||||
for (RunStep step : runSteps(workflow, notStarted)) {
|
||||
commands.addAll(stepInvocations(step));
|
||||
for (RunStep step : runSteps(workflow, start.notStarted())) {
|
||||
for (Invocation command : stepInvocations(step)) {
|
||||
commands.add(
|
||||
start.releaseFlow() == null ? command : command.releaseFlowOnly(start.releaseFlow()));
|
||||
}
|
||||
}
|
||||
invocations.put(workflow.file(), List.copyOf(commands));
|
||||
}
|
||||
@@ -552,14 +617,13 @@ public final class WorkflowGradleInvocations {
|
||||
int detailIndent = childIndent(lines, next);
|
||||
if (detailIndent > childIndent) {
|
||||
int typesLine = mappingKey(lines, next + 1, detailIndent, "types");
|
||||
List<String> pathFilters = new ArrayList<>();
|
||||
for (String filter : PATH_FILTERS) {
|
||||
List<String> filters = new ArrayList<>();
|
||||
for (String filter : FILTERS) {
|
||||
if (mappingKey(lines, next + 1, detailIndent, filter) >= 0) {
|
||||
pathFilters.add(filter);
|
||||
filters.add(filter);
|
||||
}
|
||||
}
|
||||
trigger =
|
||||
new Trigger(typesLine < 0 ? null : listValue(lines, typesLine), pathFilters);
|
||||
trigger = Trigger.of(typesLine < 0 ? null : listValue(lines, typesLine), filters);
|
||||
}
|
||||
}
|
||||
triggers.put(stripScalarComment(colon < 0 ? key : key.substring(0, colon)), trigger);
|
||||
@@ -575,7 +639,7 @@ public final class WorkflowGradleInvocations {
|
||||
return Trigger.UNFILTERED;
|
||||
}
|
||||
List<String> types = null;
|
||||
List<String> pathFilters = new ArrayList<>();
|
||||
List<String> filters = new ArrayList<>();
|
||||
for (String entry : flowItems(value.substring(1, value.length() - 1))) {
|
||||
int colon = entry.indexOf(':');
|
||||
if (colon < 0) {
|
||||
@@ -588,48 +652,68 @@ public final class WorkflowGradleInvocations {
|
||||
detail.startsWith("[") && detail.endsWith("]")
|
||||
? flowItems(detail.substring(1, detail.length() - 1))
|
||||
: List.of(stripScalarComment(detail));
|
||||
} else if (PATH_FILTERS.contains(key)) {
|
||||
pathFilters.add(key);
|
||||
} else if (FILTERS.contains(key)) {
|
||||
filters.add(key);
|
||||
}
|
||||
}
|
||||
return new Trigger(types, pathFilters);
|
||||
return Trigger.of(types, filters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Why the workflow does not run on every change, or {@code null} when it does or writes no {@code
|
||||
* on:}. A reusable workflow runs through its callers ({@code visiting} guards a cycle).
|
||||
* When the workflow starts, as the stages see it; on every change when it writes no {@code on:}.
|
||||
* A reusable workflow runs through its callers ({@code visiting} guards a cycle).
|
||||
*/
|
||||
private static String startReason(
|
||||
private static Start start(
|
||||
Workflow workflow, Map<String, Workflow> workflows, Set<String> visiting) {
|
||||
Map<String, Trigger> triggers = workflow.triggers();
|
||||
if (triggers.isEmpty()) {
|
||||
return null;
|
||||
return Start.EVERY_CHANGE;
|
||||
}
|
||||
Map<String, Trigger> pathFiltered = new LinkedHashMap<>();
|
||||
Map<String, Trigger> releaseFlow = new LinkedHashMap<>();
|
||||
for (Map.Entry<String, Trigger> trigger : triggers.entrySet()) {
|
||||
if (!runsOnChanges(trigger.getKey(), trigger.getValue().types())) {
|
||||
continue;
|
||||
switch (flow(trigger.getKey(), trigger.getValue())) {
|
||||
case CHANGE -> {
|
||||
return Start.EVERY_CHANGE;
|
||||
}
|
||||
case PATH_FILTERED -> pathFiltered.put(trigger.getKey(), trigger.getValue());
|
||||
case RELEASE -> releaseFlow.put(trigger.getKey(), trigger.getValue());
|
||||
case REQUEST -> {
|
||||
// counted only through a caller, below, when it is workflow_call
|
||||
}
|
||||
}
|
||||
if (trigger.getValue().pathFilters().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
pathFiltered.put(trigger.getKey(), trigger.getValue());
|
||||
}
|
||||
String release =
|
||||
releaseFlow.isEmpty()
|
||||
? null
|
||||
: "its workflow starts without a request or a path filter only on the release flow ("
|
||||
+ describe(releaseFlow)
|
||||
+ "), not on every push, pull request or schedule, so it counts only for "
|
||||
+ RELEASE_STAGE;
|
||||
String described = describe(triggers);
|
||||
if (!triggers.containsKey("workflow_call") && !pathFiltered.isEmpty()) {
|
||||
return "its workflow starts on changes only through "
|
||||
+ describe(pathFiltered)
|
||||
+ ", which a change that touches none of the listed paths, or only ignored ones, does"
|
||||
+ " not start, so it may not run";
|
||||
}
|
||||
if (!triggers.containsKey("workflow_call")) {
|
||||
return "its workflow starts only on "
|
||||
+ described
|
||||
+ ", which happen only when someone or something asks, not on every push, pull request"
|
||||
+ " or schedule, so it may not run";
|
||||
if (release != null) {
|
||||
return new Start(null, release);
|
||||
}
|
||||
if (!pathFiltered.isEmpty()) {
|
||||
return new Start(
|
||||
"its workflow starts on changes only through "
|
||||
+ describe(pathFiltered)
|
||||
+ ", which a change that touches none of the listed paths, or only ignored ones,"
|
||||
+ " does not start, so it may not run",
|
||||
null);
|
||||
}
|
||||
return new Start(
|
||||
"its workflow starts only on "
|
||||
+ described
|
||||
+ ", which happen only when someone or something asks, not on every push, pull"
|
||||
+ " request or schedule, so it may not run",
|
||||
null);
|
||||
}
|
||||
if (!visiting.add(workflow.file())) {
|
||||
return "its workflow is called only through a cycle of workflow_call";
|
||||
return release != null
|
||||
? new Start(null, release)
|
||||
: new Start("its workflow is called only through a cycle of workflow_call", null);
|
||||
}
|
||||
List<String> callers = new ArrayList<>();
|
||||
for (Workflow caller : workflows.values()) {
|
||||
@@ -643,30 +727,57 @@ public final class WorkflowGradleInvocations {
|
||||
reason = needsReason(caller, job);
|
||||
}
|
||||
if (reason == null) {
|
||||
reason = startReason(caller, workflows, new HashSet<>(visiting));
|
||||
}
|
||||
if (reason == null) {
|
||||
return null;
|
||||
Start callerStart = start(caller, workflows, new HashSet<>(visiting));
|
||||
if (callerStart.equals(Start.EVERY_CHANGE)) {
|
||||
return Start.EVERY_CHANGE;
|
||||
}
|
||||
if (callerStart.notStarted() == null && release == null) {
|
||||
release =
|
||||
"its workflow is called by "
|
||||
+ caller.file()
|
||||
+ " job "
|
||||
+ job.id()
|
||||
+ ", and "
|
||||
+ callerStart.releaseFlow();
|
||||
}
|
||||
reason =
|
||||
callerStart.notStarted() == null
|
||||
? callerStart.releaseFlow()
|
||||
: callerStart.notStarted();
|
||||
}
|
||||
callers.add(caller.file() + " job " + job.id() + ": " + reason);
|
||||
}
|
||||
}
|
||||
return "its workflow starts only on "
|
||||
+ described
|
||||
+ ", and no workflow that runs on every change calls it ("
|
||||
+ (callers.isEmpty()
|
||||
? "no workflow in this directory calls it"
|
||||
: String.join("; ", callers))
|
||||
+ "), so it may not run";
|
||||
if (release != null) {
|
||||
return new Start(null, release);
|
||||
}
|
||||
return new Start(
|
||||
"its workflow starts only on "
|
||||
+ described
|
||||
+ ", and no workflow that runs on every change calls it ("
|
||||
+ (callers.isEmpty()
|
||||
? "no workflow in this directory calls it"
|
||||
: String.join("; ", callers))
|
||||
+ "), so it may not run",
|
||||
null);
|
||||
}
|
||||
|
||||
private static boolean runsOnChanges(String trigger, List<String> types) {
|
||||
if (!CHANGE_TRIGGERS.contains(trigger)) {
|
||||
return false;
|
||||
private static Flow flow(String name, Trigger trigger) {
|
||||
if (!CHANGE_TRIGGERS.contains(name)) {
|
||||
return Flow.REQUEST;
|
||||
}
|
||||
return types == null
|
||||
|| !trigger.startsWith("pull_request")
|
||||
|| types.stream().anyMatch(PULL_REQUEST_CHANGE_TYPES::contains);
|
||||
if (trigger.types() != null
|
||||
&& name.startsWith("pull_request")
|
||||
&& trigger.types().stream().noneMatch(PULL_REQUEST_CHANGE_TYPES::contains)) {
|
||||
return Flow.REQUEST;
|
||||
}
|
||||
if (!trigger.pathFilters().isEmpty()) {
|
||||
return Flow.PATH_FILTERED;
|
||||
}
|
||||
if (name.equals("release") || name.equals("push") && trigger.tagsOnly()) {
|
||||
return Flow.RELEASE;
|
||||
}
|
||||
return Flow.CHANGE;
|
||||
}
|
||||
|
||||
private static String describe(Map<String, Trigger> triggers) {
|
||||
@@ -678,6 +789,9 @@ public final class WorkflowGradleInvocations {
|
||||
filters.add("types: " + String.join(", ", trigger.types()));
|
||||
}
|
||||
filters.addAll(trigger.pathFilters());
|
||||
if (trigger.tagsOnly()) {
|
||||
filters.add("tags only");
|
||||
}
|
||||
described.add(filters.isEmpty() ? name : name + " (" + String.join("; ", filters) + ")");
|
||||
});
|
||||
return String.join(", ", described);
|
||||
@@ -1268,7 +1382,7 @@ public final class WorkflowGradleInvocations {
|
||||
if (reason == null) {
|
||||
reason = rejected != null ? rejected : runsNoTask;
|
||||
}
|
||||
return new Invocation(workingDirectory, projectDir, tasks, dryRun, excluded, reason);
|
||||
return new Invocation(workingDirectory, projectDir, tasks, dryRun, excluded, reason, null);
|
||||
}
|
||||
|
||||
private static boolean isFlag(String name) {
|
||||
|
||||
+57
@@ -698,6 +698,63 @@ class StrictLaneStagesFunctionalTest {
|
||||
.doesNotContain("stage :ci is executed by no workflow");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("태그 push로만 도는 workflow의 단계 명령은 releaseCheck에만 세고, 다른 단계는 실행되지 않은 것으로 본다")
|
||||
void aReleaseFlowWorkflowCountsOnlyForTheReleaseStage() throws Exception {
|
||||
// given
|
||||
Files.writeString(
|
||||
gradleRoot.resolve("build.gradle"),
|
||||
"""
|
||||
plugins { id 'ca.strict-lane-stages' }
|
||||
tasks.register('ci') { dependsOn ':leaf:check' }
|
||||
tasks.register('integrationCheck') { dependsOn ':leaf:integrationTestLaneCheck' }
|
||||
tasks.register('releaseCheck')
|
||||
strictLaneStages {
|
||||
stage ':ci', ':integrationCheck', ':releaseCheck'
|
||||
workflowDirectory = layout.projectDirectory.dir('../.github/workflows')
|
||||
}
|
||||
""");
|
||||
leafLanes(
|
||||
"""
|
||||
lane('databaseLane') { integration(); tag = 'db'; description = 'Real database.' }
|
||||
""");
|
||||
workflow(
|
||||
"""
|
||||
on: pull_request
|
||||
jobs:
|
||||
gate:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- working-directory: src
|
||||
run: ./gradlew :ci --stacktrace
|
||||
""");
|
||||
Files.writeString(
|
||||
repository.resolve(".github/workflows/release.yml"),
|
||||
"""
|
||||
on:
|
||||
push:
|
||||
tags: ['v*']
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- working-directory: src
|
||||
run: ./gradlew :releaseCheck
|
||||
- working-directory: src
|
||||
run: ./gradlew :integrationCheck --continue
|
||||
""");
|
||||
|
||||
// when
|
||||
BuildResult result = runner(":verifyStrictLaneStages", "--dry-run").buildAndFail();
|
||||
|
||||
// then
|
||||
assertThat(result.getOutput())
|
||||
.contains("stage :integrationCheck is executed by no workflow")
|
||||
.contains("release.yml: gradlew :integrationCheck")
|
||||
.contains("counts only for :releaseCheck")
|
||||
.doesNotContain("stage :releaseCheck is executed by no workflow");
|
||||
}
|
||||
|
||||
private void leafLanes(String lanes) throws Exception {
|
||||
Files.writeString(
|
||||
gradleRoot.resolve("leaf/build.gradle"),
|
||||
|
||||
+79
-13
@@ -1218,8 +1218,8 @@ class WorkflowGradleInvocationsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("push·pull_request·merge_group·schedule·release 중 하나로도 시작하는 workflow의 명령은 센다")
|
||||
void aWorkflowThatAlsoStartsOnTheChangeOrReleaseFlowCounts() {
|
||||
@DisplayName("push·pull_request·merge_group·schedule 중 하나로도 시작하는 workflow의 명령은 센다")
|
||||
void aWorkflowThatAlsoStartsOnTheChangeFlowCounts() {
|
||||
// given
|
||||
List<String> workflows =
|
||||
List.of(
|
||||
@@ -1252,16 +1252,6 @@ class WorkflowGradleInvocationsTest {
|
||||
run: ./gradlew :ci
|
||||
""",
|
||||
"""
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
jobs:
|
||||
main:
|
||||
steps:
|
||||
- working-directory: src
|
||||
run: ./gradlew :ci
|
||||
""",
|
||||
"""
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize, labeled]
|
||||
@@ -1279,7 +1269,7 @@ class WorkflowGradleInvocationsTest {
|
||||
|
||||
// then
|
||||
assertThat(invocations)
|
||||
.hasSize(5)
|
||||
.hasSize(4)
|
||||
.allSatisfy(invocation -> assertThat(invocation.executes(":ci", "src")).isTrue());
|
||||
}
|
||||
|
||||
@@ -1364,6 +1354,82 @@ class WorkflowGradleInvocationsTest {
|
||||
invocation -> assertThat(invocation.executes(":ci", "src")).isTrue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("태그 push나 release로만 시작하는 workflow의 명령은 releaseCheck에만 센다")
|
||||
void aWorkflowThatStartsOnlyOnTheReleaseFlowCountsOnlyForReleaseCheck() {
|
||||
// given
|
||||
List<String> workflows =
|
||||
List.of(
|
||||
"""
|
||||
on:
|
||||
push:
|
||||
tags: ['v*']
|
||||
jobs:
|
||||
release:
|
||||
steps:
|
||||
- working-directory: src
|
||||
run: ./gradlew :releaseCheck :integrationCheck
|
||||
""",
|
||||
"""
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
release:
|
||||
steps:
|
||||
- working-directory: src
|
||||
run: ./gradlew :releaseCheck :integrationCheck
|
||||
""",
|
||||
"""
|
||||
on: {push: {tags-ignore: ['nightly-*']}}
|
||||
jobs:
|
||||
release:
|
||||
steps:
|
||||
- working-directory: src
|
||||
run: ./gradlew :releaseCheck :integrationCheck
|
||||
""");
|
||||
|
||||
// when
|
||||
List<Invocation> invocations =
|
||||
workflows.stream().flatMap(workflow -> WorkflowGradleInvocations.read(workflow).stream())
|
||||
.toList();
|
||||
|
||||
// then
|
||||
assertThat(invocations)
|
||||
.hasSize(3)
|
||||
.allSatisfy(
|
||||
invocation -> {
|
||||
assertThat(invocation.executes(":releaseCheck", "src")).isTrue();
|
||||
assertThat(invocation.executes(":integrationCheck", "src")).isFalse();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("태그와 함께 브랜치도 받는 push로 시작하는 workflow의 명령은 모든 단계에 센다")
|
||||
void aPushWithBranchesBesidesTagsCountsForEveryStage() {
|
||||
// given
|
||||
String workflow =
|
||||
"""
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
tags: ['v*']
|
||||
jobs:
|
||||
main:
|
||||
steps:
|
||||
- working-directory: src
|
||||
run: ./gradlew :integrationCheck
|
||||
""";
|
||||
|
||||
// when
|
||||
List<Invocation> invocations = WorkflowGradleInvocations.read(workflow);
|
||||
|
||||
// then
|
||||
assertThat(invocations).singleElement().satisfies(
|
||||
invocation -> assertThat(invocation.executes(":integrationCheck", "src")).isTrue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("workflow_call로만 시작하는 재사용 workflow의 명령은 매 변경에 도는 호출 job이 있을 때만 센다")
|
||||
void aReusableWorkflowCountsOnlyThroughACallerThatRunsOnEveryChange() {
|
||||
|
||||
Reference in New Issue
Block a user