Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/scripts/classify-change-scope.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const SHARED_FILES = new Set([
"gradle.properties",
"gradlew",
"gradlew.bat",
"dev-tools/validation/run-gradle-with-dependency-recovery.sh",
"dev-tools/validation/run-locked-gradle.sh",
"dev-tools/validation/gradle-run-supervisor.py",
]);
Expand Down
1 change: 1 addition & 0 deletions .github/scripts/classify-change-scope.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ test("workflow and Gradle wrapper changes force all module validation", () => {
".github/scripts/classify-change-scope.cjs",
"gradlew",
"gradlew.bat",
"dev-tools/validation/run-gradle-with-dependency-recovery.sh",
"dev-tools/validation/run-locked-gradle.sh",
"dev-tools/validation/gradle-run-supervisor.py",
]) {
Expand Down
310 changes: 7 additions & 303 deletions .github/scripts/run-gradle-module-checks.sh
Original file line number Diff line number Diff line change
@@ -1,313 +1,17 @@
#!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
readonly ROOT_DIR
readonly MODULE="${1:-}"
if [[ $# -ne 1 || ! "$MODULE" =~ ^[a-z0-9]+(-[a-z0-9]+)*$ ]]; then
echo "usage: run-gradle-module-checks.sh <module-name>" >&2
exit 64
fi

readonly -a CHECK_ARGS=(
--max-workers=2
'-Dorg.gradle.jvmargs=-Xmx2500m -Dfile.encoding=UTF-8'
":${MODULE}:check"
bash "$ROOT_DIR/dev-tools/validation/run-gradle-with-dependency-recovery.sh" \
--runner "$ROOT_DIR/gradlew" -- \
--max-workers=2 \
'-Dorg.gradle.jvmargs=-Xmx2500m -Dfile.encoding=UTF-8' \
":${MODULE}:check" \
-PfullCheck
)

readonly TEMP_ROOT="${RUNNER_TEMP:-${TMPDIR:-/tmp}}"
if ! TEMP_DIR="$(mktemp -d "${TEMP_ROOT%/}/firemud-gradle-check.XXXXXX")"; then
echo "unable to create Gradle check log directory" >&2
exit 125
fi
readonly TEMP_DIR
readonly NORMAL_LOG="$TEMP_DIR/normal.log"
readonly REFRESH_LOG="$TEMP_DIR/refresh.log"

# Invoked indirectly by the EXIT trap below.
# shellcheck disable=SC2329
cleanup() {
rm -f -- "$NORMAL_LOG" "$REFRESH_LOG"
rmdir -- "$TEMP_DIR"
}
trap cleanup EXIT
trap 'exit 130' INT
trap 'exit 143' TERM
trap 'exit 129' HUP

GRADLE_EXIT=0
run_gradle_check() {
local refresh="$1"
local log_path="$2"
local -a pipeline_status=()

set +e
if [[ "$refresh" == true ]]; then
./gradlew --refresh-dependencies "${CHECK_ARGS[@]}" 2>&1 | tee "$log_path"
else
./gradlew "${CHECK_ARGS[@]}" 2>&1 | tee "$log_path"
fi
pipeline_status=("${PIPESTATUS[@]}")
set -e

GRADLE_EXIT="${pipeline_status[0]:-125}"
if [[ "${pipeline_status[1]:-125}" -ne 0 ]]; then
echo "failed to capture complete Gradle output; refusing dependency retry" >&2
exit 125
fi
}

has_substantive_failure() {
local log_path="$1"

grep -Eq '(^|[[:space:]])(Compilation failed|Compilation error|error:|e: file:|There were failing tests)' "$log_path" && return 0

awk '
/^> Task / {
task = $3
outcome = $4
name = task
sub(/^.*:/, "", name)

is_compile = name ~ /^compile[A-Z][A-Za-z0-9]*$/
is_test = !is_compile && name ~ /(^|[A-Za-z0-9])(test|Test)[A-Za-z0-9]*$/
# buildSrc compiles the build logic during Gradle setup, not the target
# module sources whose successful execution must remain unretried.
is_build_logic = task ~ /^:buildSrc(:|$)/
is_compile = !is_build_logic && is_compile
if (!is_test && !is_compile) {
next
}

cached_or_skipped = outcome == "FROM-CACHE" || outcome == "UP-TO-DATE" || outcome == "NO-SOURCE" || outcome == "SKIPPED"
if (is_test && !cached_or_skipped) {
found = 1
} else if (is_compile && outcome != "FAILED" && !cached_or_skipped) {
found = 1
}
if (is_compile && outcome == "FAILED" && !cached_or_skipped) {
failed_compile = 1
}
}
END {
if (found) {
exit 0
}
if (failed_compile) {
exit 2
}
exit 1
}
' "$log_path"
return $?
}

failure_body() {
local log_path="$1"

awk '
/^FAILURE: Build failed with an exception\.$/ {
failures++
in_failure = 1
next
}
in_failure && /^\* What went wrong:$/ {
sections++
in_body = 1
next
}
in_body && /^\* Try:$/ {
in_body = 0
ended = 1
next
}
in_body {
print
}
END {
if (failures != 1 || sections != 1 || !ended || invalid) {
exit 1
}
}
' "$log_path"
}

classify_failure_body() {
local log_path="$1"

awk '
function trim(s) {
sub(/^[[:space:]]+/, "", s)
sub(/[[:space:]]+$/, "", s)
return s
}
{
line = trim($0)
if (line == "" || line == "* What went wrong:") {
next
}

if (line == "1 problem was found storing the configuration cache.") {
cache_summary++
next
}
if (line ~ /^Configuration cache state could not be cached: field `classpath` of task `:[^`]+:compile[A-Za-z0-9]+` of type .*JavaCompile.*: error writing value of type .*DefaultResolvableConfiguration/ ||
line ~ /^- Task `:[^`]+:compile[A-Za-z0-9]+` of type .*JavaCompile.*: error writing value of type .*DefaultResolvableConfiguration/) {
if (match(line, /`:[^`]+:compile[A-Za-z0-9]+`/)) {
task_reference = substr(line, RSTART, RLENGTH)
if (cache_task != "" && cache_task != task_reference) {
invalid++
}
cache_task = task_reference
} else {
invalid++
}
cache_cause++
next
}
if (line ~ /^See the complete report at file:.*configuration-cache\//) {
next
}
if (line ~ /^\[Incubating\] Problems report is available at: file:.*\/build\/reports\/problems\/problems-report\.html$/ ||
line == "Deprecated Gradle features were used in this build, making it incompatible with Gradle 10." ||
line == "You can use \047--warning-mode all\047 to show the individual deprecation warnings and determine if they come from your own scripts or plugins." ||
line == "For more on this, please refer to https://docs.gradle.org/9.8.1/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation." ||
line ~ /^[0-9]+ actionable tasks: [0-9]+ executed, [0-9]+ from cache$/) {
next
}

if (line ~ /^> Could not resolve all (artifacts|files) for configuration .+\.$/) {
resolver_roots++
if (line ~ /(compileClasspath|testCompileClasspath|integrationTestCompileClasspath|crossServiceTestCompileClasspath)/) {
compile_classpath_roots++
}
next
}
if (line ~ /^> Could not (find|resolve) [[:alnum:]_.-]+:[[:alnum:]_.-]+:[0-9][[:alnum:]_.-]*\.$/ ||
line ~ /^> Could not find [^[:space:]]+ \([[:alnum:]_.-]+:[[:alnum:]_.-]+:[0-9][[:alnum:]_.-]*\)\.$/) {
coordinates++
next
}
if (line ~ /^> Could not (get resource|GET|HEAD) [\047\042]?https?:\/\// ||
line ~ /^> Could not GET https?:\/\//) {
repository_requests++
next
}
if (line ~ /^Execution failed for task / && line ~ /:compile[A-Za-z0-9]+[\047"][.]$/) {
compile_task_failure++
next
}
if (line == "Searched in the following locations:" || line ~ /^https?:\/\// || line ~ /^- https?:\/\// ||
line == "Required by:" || line ~ /^project / ||
line ~ /^> Got socket exception during request\./ ||
line ~ /^> Connection (reset|timed out)$/ ||
line ~ /^> SocketTimeoutException/ ||
line ~ /^Received status code (429|5[0-9][0-9]) from server/ ||
line ~ /^Retry-After: .+$/ ||
line ~ /^(> )?There are [0-9]+ more failures with identical causes\.$/) {
if (line ~ /^Received status code /) {
transient++
}
if (line ~ /^> Connection / || line ~ /^> SocketTimeoutException/ || line ~ /^> Got socket exception/) {
transient++
}
if (line ~ /^Searched in the following locations:/) {
searched++
}
if (line ~ /^https?:\/\// || line ~ /^- https?:\/\//) {
repository_urls++
}
next
}

# Every other line inside the fatal cause body is an additional
# or unknown cause. Do not let matching dependency text elsewhere mask it.
invalid++
}
END {
if (invalid || resolver_roots == 0 || coordinates == 0 ||
(cache_summary && (cache_cause == 0 || cache_cause > 2)) ||
(compile_task_failure && compile_classpath_roots == 0) ||
!((transient && repository_requests) || (searched && repository_urls))) {
exit 1
}
exit 0
}
' "$log_path"
}

is_dependency_resolution_failure() {
local log_path="$1"
local body_path
local substantive_status=0

body_path="$(mktemp "${TEMP_DIR%/}/failure-body.XXXXXX")" || return 1
if ! failure_body "$log_path" > "$body_path"; then
rm -f -- "$body_path"
return 1
fi
if ! classify_failure_body "$body_path"; then
rm -f -- "$body_path"
return 1
fi

has_substantive_failure "$log_path" || substantive_status=$?
rm -f -- "$body_path"
case "$substantive_status" in
0) return 1 ;;
1|2) return 0 ;;
*) return 1 ;;
esac
}

retry_delay_seconds() {
local log_path="$1"
local retry_after
local delay

retry_after="$(failure_body "$log_path" | sed -nE 's/^.*[Rr]etry-[Aa]fter:[[:space:]]*(.*)$/\1/p')" || return 1
if [[ -z "$retry_after" ]]; then
if failure_body "$log_path" | grep -Eq 'Connection reset|Connection timed out|SocketTimeoutException|Received status code 429 from server|Received status code 5[0-9][0-9] from server'; then
printf '2\n'
else
printf '0\n'
fi
return 0
fi

# Reject date and malformed values; cap raw decimal length before arithmetic,
# strip leading zeroes, and force base ten so values such as 08 stay safe.
[[ "$retry_after" =~ ^[0-9]+$ ]] || return 1
(( ${#retry_after} <= 16 )) || return 1
local canonical="${retry_after#"${retry_after%%[!0]*}"}"
[[ -n "$canonical" ]] || canonical=0
(( ${#canonical} <= 2 )) || return 1
delay=$((10#$canonical))

if (( delay > 30 )); then
echo "Retry-After exceeds the bounded 30-second retry window; preserving original failure" >&2
return 1
fi
printf '%s\n' "$delay"
}

run_gradle_check false "$NORMAL_LOG"
if [[ "$GRADLE_EXIT" -eq 0 ]]; then
exit 0
fi

if [[ "$GRADLE_EXIT" -ne 1 ]]; then
exit "$GRADLE_EXIT"
fi

if ! is_dependency_resolution_failure "$NORMAL_LOG"; then
exit "$GRADLE_EXIT"
fi

if ! RETRY_DELAY="$(retry_delay_seconds "$NORMAL_LOG")"; then
exit "$GRADLE_EXIT"
fi

echo "Recognized Gradle dependency-resolution failure before compile/test execution; retrying the complete module check once with dependency metadata refresh after ${RETRY_DELAY}s."
sleep "$RETRY_DELAY"
run_gradle_check true "$REFRESH_LOG"
exit "$GRADLE_EXIT"
3 changes: 3 additions & 0 deletions .github/workflows/runtime-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ on:
- 'config/python/smoke-requirements.txt'
- 'config/python/smoke-requirements.in'
- 'dev-tools/build-compose-service-jars.sh'
- 'dev-tools/validation/run-gradle-with-dependency-recovery.sh'
- 'dev-tools/validation/run-locked-gradle.sh'
- 'dev-tools/validation/gradle-run-supervisor.py'
- 'dev-tools/build-local-smoke-images.sh'
Expand Down Expand Up @@ -360,6 +361,7 @@ jobs:
"config/python/smoke-requirements.txt",
"config/python/smoke-requirements.in",
"dev-tools/build-compose-service-jars.sh",
"dev-tools/validation/run-gradle-with-dependency-recovery.sh",
"dev-tools/validation/run-locked-gradle.sh",
"dev-tools/validation/gradle-run-supervisor.py",
"dev-tools/build-local-smoke-images.sh",
Expand Down Expand Up @@ -468,6 +470,7 @@ jobs:
"config/python/smoke-requirements.txt",
"config/python/smoke-requirements.in",
"dev-tools/build-compose-service-jars.sh",
"dev-tools/validation/run-gradle-with-dependency-recovery.sh",
"dev-tools/validation/run-locked-gradle.sh",
"dev-tools/validation/gradle-run-supervisor.py",
"dev-tools/build-local-smoke-images.sh",
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ jobs:
"config/python/smoke-requirements.txt",
"config/python/smoke-requirements.in",
"dev-tools/build-compose-service-jars.sh",
"dev-tools/validation/run-gradle-with-dependency-recovery.sh",
"dev-tools/validation/run-locked-gradle.sh",
"dev-tools/validation/gradle-run-supervisor.py",
"dev-tools/build-local-smoke-images.sh",
Expand Down Expand Up @@ -599,7 +600,7 @@ jobs:
}

// One canonical producer definition; the contract test reports fingerprint upkeep.
const canonicalRuntimeWorkflowSha256 = "c4bd569e46902970ce1844a68b127dfcc5f78f22648028799f8297e113d8ce7b";
const canonicalRuntimeWorkflowSha256 = "8b49b5e26ac37a1b6c1d098ee0d8c9716d850eb0ea7e43491b6c6b6f191fca1a";
const canonicalSmokeJobName = "PR Full-Stack Smoke (runtime-required=true)";
const workflowPath = ".github/workflows/runtime-images.yml";
const repositoryName = `${owner}/${repo}`;
Expand Down
2 changes: 1 addition & 1 deletion design/architecture/system-architecture-cicd.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ The main [`ci.yml`](../../.github/workflows/ci.yml) workflow:
- Generates protobuf outputs to keep generated stubs aligned with the checked-in schemas.
- Runs formatting and lint steps (Spotless, markdownlint, link checks).
- On the complete CI path, executes a matrix of Gradle `check` tasks (one per microservice) with SpotBugs, Checkstyle, and tests enabled; lightweight documentation-only PR validation does not run these service checks.
- Each affected-module check first uses Gradle's restored dependency metadata without a forced refresh. Only a recognized repository-resolution failure before substantive module compilation or test execution receives one retry of the same full check with `--refresh-dependencies`; this preserves recovery from cached negative metadata without revalidating every dependency on every successful matrix job. Compiler and test failures, unrelated configuration errors, interrupted runs, and failures that cannot be classified retain their original failure.
- Affected-module checks and the source-built Compose boot-jar command first use Gradle's restored dependency metadata without a forced refresh. The shared runner gives a fully recognized repository-resolution failure one retry of the same complete Gradle command with `--refresh-dependencies`; successful commands do not revalidate every dependency. The existing pre-substantive compile/test boundary remains. jOOQ also permits only the exact matching `jooqCodegen` classpath-resolution failure, including Gradle's `generateJooq FAILED` task wrapper when the failure prevents the JavaExec generator from launching. The configuration-cache wrapper remains retryable only before `generateJooq` starts. Genuine JavaExec, code-generation, SQL, compiler, test, mixed, unknown, interrupted, or unrelated configuration failures retain their original failure.
- On the complete CI path, generates one per-service JaCoCo report from unit and every available categorized integration/cross-service test execution, uploads that combined XML to Codecov using GitHub OIDC, and runs the Trivy scans. Modules without categorized tests retain their unit-only report; production classes remain in the report rather than being excluded to improve percentages. Lightweight documentation-only PR validation does not run these Trivy jobs.
- Retains the Gradle JUnit XML results from each affected-module `check` run, including unit and integration outcomes, in an artifact named with the module, workflow SHA, and run attempt for 14 days. Including the attempt keeps partial workflow reruns from colliding with earlier artifacts. The load-testing matrix entry uses its `dev-tools/load-testing` output; missing XML is reported as a warning so artifact retention does not change the test gate.
- Uses Node 24 to lint OpenAPI specs, run React linters, and execute an accessibility audit using headless Chrome.
Expand Down
1 change: 1 addition & 0 deletions dev-tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Keep the root of `dev-tools/` small. Only canonical human-facing entrypoints and
- `build-local-smoke-images.sh` – builds the pinned local base and service images for a 40-character commit tag after rebuilding the service boot jars.
- `verify-compose-health.sh` – shared health gate used by the smoke entrypoints.
- `validation/run-locked-gradle.sh` – canonical local Gradle wrapper that serializes heavy builds across worktrees, protects shared output trees, and bounds lock acquisition and cancellation start. Use it for local proof and service boot-jar builds; [Local Gradle execution](../design/developer-workflows/validation-and-runtime-proof.md#local-gradle-execution) owns configuration and cancellation limits. For example: `bash dev-tools/validation/run-locked-gradle.sh :account-service:test`.
- `validation/run-gradle-with-dependency-recovery.sh` – shared one-retry runner for the complete affected-module check and source-built boot-jar commands. It refreshes dependency metadata only after a recognized repository-resolution failure; each caller supplies its complete Gradle command and runner.
- `validation/inspect-test-results.sh` – read-only JUnit XML summary helper for diagnosing quiet post-suite Gradle tails without guessing at process state. For example: `bash dev-tools/validation/inspect-test-results.sh account-service`. This is diagnostic evidence only and does not prove that the Gradle invocation completed cleanly.
- `pr-review` – the sole review controller. Use `dev-tools/pr-review stack set <pr>...` and `stack show` for the repository review stack, `status [--pr <pr>]` for fail-closed live state, `run hosted|cli [--expect-pr <pr>] [--force [--reason <context>]]` for a complete checkpoint, `evidence [<pr>]` for anchored evidence, and `decide ...` for explicit judgments. `--force` records acknowledgment of a known candidate-quality warning with the attempt; it does not bypass PR/candidate identity or admission-time rechecks, provider ceilings or quota, active-request exclusion, channel caps, stopped/completed channels, or accepted-finding obligations. A completed result counts normally for its PR and channel. The complete review, status, checkpoint, and disposition policy is owned by [PR lifecycle: Review and Status](../design/developer-workflows/pr-lifecycle.md#review-and-status). Until an explicitly validated JSON-to-SQLite cutover, controller decisions remain in the locked private common-directory JSON state file; do not assume cutover has occurred. Live shared cutover waits until the controller change is merged and its version-matched tooling is installed. Select the trusted promoted `dev-tools/pr-review` entrypoint and inspect `dev-tools/pr-review --version` before migration or shared writes. Follow [PR-review SQLite operations](pr_review/README.md) for the atomic JSON migration and old-writer fence, separate records bootstrap, provider-checkpoint imports, curated manual/subagent batch imports, and read-only history/route queries. Existing controller-era routes remain available through `routes` and `status`; full provider captures remain separate audit evidence outside SQLite. Provider imports and independent records do not affect CodeRabbit taper. Live PR, CI, checkpoint, and review evidence is derived when requested. For hands-on acceptance, pass the paired global options `--acceptance-fixture <json>` and `--state-path <isolated-file>`; these use synthetic fixture adapters in a dedicated private directory and never contact GitHub or consume review quota. The implementation and focused contracts live in `pr_review/` and `tests/pr-review-controller-contract.sh`.

Expand Down
Loading
Loading