Skip to content

Commit 6ccb0a6

Browse files
committed
fix(live-proof): preserve automatic Go fallback
1 parent 7a8b6c0 commit 6ccb0a6

3 files changed

Lines changed: 315 additions & 84 deletions

File tree

‎.github/workflows/sweep.yml‎

Lines changed: 63 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,27 +1364,49 @@ jobs:
13641364
set -euo pipefail
13651365
versions_file="$(mktemp)"
13661366
trap 'rm -f "$versions_file"' EXIT
1367+
requires_automatic_toolchain=false
13671368
while read -r item; do
13681369
record="$RECORDS_DIR/$item.md"
13691370
head_sha="$(sed -n 's/^pull_head_sha:[[:space:]]*//p' "$record" | head -n 1)"
13701371
printf '%s' "$head_sha" | grep -Eq '^[0-9a-f]{40}$'
13711372
if ! go_mod="$(git -C "$TARGET_CHECKOUT" show "$head_sha:go.mod" 2>/dev/null)"; then
1373+
requires_automatic_toolchain=true
13721374
continue
13731375
fi
1374-
go_version="$(awk '$1 == "go" { print $2; exit }' <<< "$go_mod")"
1375-
toolchain_version="$(awk '$1 == "toolchain" && $2 ~ /^go/ { sub(/^go/, "", $2); print $2; exit }' <<< "$go_mod")"
1376-
printf '%s\n' "${go_version:-1.16}" >> "$versions_file"
1376+
if go_work="$(git -C "$TARGET_CHECKOUT" show "$head_sha:go.work" 2>/dev/null)"; then
1377+
go_config="$go_work"
1378+
default_go_version=1.18
1379+
else
1380+
go_config="$go_mod"
1381+
default_go_version=1.16
1382+
fi
1383+
while IFS= read -r -d '' path; do
1384+
case "$path" in
1385+
*/go.mod | */go.work)
1386+
requires_automatic_toolchain=true
1387+
;;
1388+
esac
1389+
done < <(git -C "$TARGET_CHECKOUT" ls-tree -rz --name-only "$head_sha")
1390+
go_version="$(awk '$1 == "go" { print $2; exit }' <<< "$go_config")"
1391+
toolchain_version="$(awk '$1 == "toolchain" && $2 ~ /^go/ { sub(/^go/, "", $2); print $2; exit }' <<< "$go_config")"
1392+
printf '%s\n' "${go_version:-$default_go_version}" >> "$versions_file"
13771393
if [ -n "$toolchain_version" ]; then
13781394
printf '%s\n' "$toolchain_version" >> "$versions_file"
13791395
fi
13801396
done < <(jq -r '.[]' <<< "$CANDIDATES")
1397+
echo "automatic=$requires_automatic_toolchain" >> "$GITHUB_OUTPUT"
13811398
if [ ! -s "$versions_file" ]; then
13821399
echo "available=false" >> "$GITHUB_OUTPUT"
13831400
exit 0
13841401
fi
1385-
version="$(node - "$versions_file" <<'NODE'
1402+
minimum_go_version=1.14.0
1403+
if [ "$requires_automatic_toolchain" = "true" ]; then
1404+
minimum_go_version=1.21.0
1405+
fi
1406+
version="$(node - "$versions_file" "$minimum_go_version" <<'NODE'
13861407
const fs = require("node:fs");
13871408
const path = process.argv[2];
1409+
const minimum = process.argv[3];
13881410
const versions = fs
13891411
.readFileSync(path, "utf8")
13901412
.trim()
@@ -1405,7 +1427,7 @@ jobs:
14051427
return a[0] - b[0] || a[1] - b[1] || a[2] - b[2];
14061428
};
14071429
versions.sort(compare);
1408-
process.stdout.write(compare(versions.at(-1), "1.14.0") < 0 ? "1.14.0" : versions.at(-1));
1430+
process.stdout.write(compare(versions.at(-1), minimum) < 0 ? minimum : versions.at(-1));
14091431
NODE
14101432
)"
14111433
mkdir -p "$(dirname "$VERSION_FILE")"
@@ -1423,6 +1445,10 @@ jobs:
14231445
go-version-file: ${{ steps.resolve-exact-live-proof-go.outputs.path }}
14241446
cache: "false"
14251447

1448+
- name: Enable exact live-proof automatic Go fallback
1449+
if: ${{ steps.claim-exact-review-queue.outputs.claimed == 'true' && steps.resolve-exact-live-proof-go.outputs.automatic == 'true' }}
1450+
run: echo "GOTOOLCHAIN=auto" >> "$GITHUB_ENV"
1451+
14261452
- name: Install exact live-proof terminal tools
14271453
if: ${{ steps.claim-exact-review-queue.outputs.claimed == 'true' && steps.inspect-exact-live-proof.outputs.requires_terminal == 'true' }}
14281454
run: |
@@ -4600,33 +4626,53 @@ jobs:
46004626
trap 'rm -f "$versions_file"' EXIT
46014627
candidate_count="$(jq -r 'length' <<< "$CANDIDATES")"
46024628
root_module_count=0
4629+
requires_automatic_toolchain=false
46034630
while read -r item; do
46044631
record="$RECORDS_DIR/$item.md"
46054632
head_sha="$(sed -n 's/^pull_head_sha:[[:space:]]*//p' "$record" | head -n 1)"
46064633
printf '%s' "$head_sha" | grep -Eq '^[0-9a-f]{40}$'
46074634
if ! go_mod="$(git -C "$TARGET_CHECKOUT" show "$head_sha:go.mod" 2>/dev/null)"; then
4635+
requires_automatic_toolchain=true
46084636
continue
46094637
fi
46104638
root_module_count=$((root_module_count + 1))
4611-
go_version="$(awk '$1 == "go" { print $2; exit }' <<< "$go_mod")"
4612-
toolchain_version="$(awk '$1 == "toolchain" && $2 ~ /^go/ { sub(/^go/, "", $2); print $2; exit }' <<< "$go_mod")"
4613-
printf '%s\n' "${go_version:-1.16}" >> "$versions_file"
4639+
if go_work="$(git -C "$TARGET_CHECKOUT" show "$head_sha:go.work" 2>/dev/null)"; then
4640+
go_config="$go_work"
4641+
default_go_version=1.18
4642+
else
4643+
go_config="$go_mod"
4644+
default_go_version=1.16
4645+
fi
4646+
while IFS= read -r -d '' path; do
4647+
case "$path" in
4648+
*/go.mod | */go.work)
4649+
requires_automatic_toolchain=true
4650+
;;
4651+
esac
4652+
done < <(git -C "$TARGET_CHECKOUT" ls-tree -rz --name-only "$head_sha")
4653+
go_version="$(awk '$1 == "go" { print $2; exit }' <<< "$go_config")"
4654+
toolchain_version="$(awk '$1 == "toolchain" && $2 ~ /^go/ { sub(/^go/, "", $2); print $2; exit }' <<< "$go_config")"
4655+
printf '%s\n' "${go_version:-$default_go_version}" >> "$versions_file"
46144656
if [ -n "$toolchain_version" ]; then
46154657
printf '%s\n' "$toolchain_version" >> "$versions_file"
46164658
fi
46174659
done < <(jq -r '.[]' <<< "$CANDIDATES")
46184660
if [ "$root_module_count" -ne "$candidate_count" ]; then
4619-
echo "::notice::Skipping job-wide Go setup because some candidates have no root go.mod; retaining automatic toolchain fallback."
4620-
echo "available=false" >> "$GITHUB_OUTPUT"
4621-
exit 0
4661+
requires_automatic_toolchain=true
46224662
fi
4663+
echo "automatic=$requires_automatic_toolchain" >> "$GITHUB_OUTPUT"
46234664
if [ ! -s "$versions_file" ]; then
46244665
echo "available=false" >> "$GITHUB_OUTPUT"
46254666
exit 0
46264667
fi
4627-
version="$(node - "$versions_file" <<'NODE'
4668+
minimum_go_version=1.14.0
4669+
if [ "$requires_automatic_toolchain" = "true" ]; then
4670+
minimum_go_version=1.21.0
4671+
fi
4672+
version="$(node - "$versions_file" "$minimum_go_version" <<'NODE'
46284673
const fs = require("node:fs");
46294674
const path = process.argv[2];
4675+
const minimum = process.argv[3];
46304676
const versions = fs
46314677
.readFileSync(path, "utf8")
46324678
.trim()
@@ -4647,7 +4693,7 @@ jobs:
46474693
return a[0] - b[0] || a[1] - b[1] || a[2] - b[2];
46484694
};
46494695
versions.sort(compare);
4650-
process.stdout.write(compare(versions.at(-1), "1.14.0") < 0 ? "1.14.0" : versions.at(-1));
4696+
process.stdout.write(compare(versions.at(-1), minimum) < 0 ? minimum : versions.at(-1));
46514697
NODE
46524698
)"
46534699
mkdir -p "$(dirname "$VERSION_FILE")"
@@ -4665,6 +4711,10 @@ jobs:
46654711
go-version-file: ${{ steps.resolve-shard-live-proof-go.outputs.path }}
46664712
cache: "false"
46674713

4714+
- name: Enable review-shard live-proof automatic Go fallback
4715+
if: ${{ steps.resolve-shard-live-proof-go.outputs.automatic == 'true' }}
4716+
run: echo "GOTOOLCHAIN=auto" >> "$GITHUB_ENV"
4717+
46684718
- name: Install review-shard terminal tools
46694719
if: ${{ steps.inspect-shard-live-proofs.outputs.requires_terminal == 'true' }}
46704720
run: |

‎docs/live-proof.md‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,18 @@ After the review command returns, the job inspects the produced reports before
3838
installing tools. tmux is installed only when a terminal candidate exists. The
3939
recording toolchain (`ffmpeg`, Xvfb, xterm, and related X11 tools) is installed
4040
only when at least one recommended plan has a non-`static_text` payoff. Review
41-
jobs also read each candidate's exact reviewed-head root `go.mod` and provision
42-
the highest required Go version before execution. Targets without a root
43-
`go.mod`, mixed review shards where any candidate lacks a root `go.mod`, and
44-
reviews without a live-proof candidate do not run Go setup. Mixed shards retain
45-
the existing automatic toolchain fallback for every candidate. When setup runs,
46-
the action disables shared Go caching and exports `GOTOOLCHAIN=local`; the
47-
sanitized child keeps that setting while using its private writable module
48-
cache. Review job timeouts include the target installation and deterministic
49-
drive. Review jobs default to `ubuntu-latest`; `CLAWSWEEPER_REVIEW_RUNNER`
50-
remains an optional runner override.
41+
jobs use each candidate's exact reviewed-head root `go.mod` as the setup gate,
42+
then use a root `go.work` instead when present and provision the highest
43+
candidate baseline. A directive-less root workspace requires Go 1.18. Nested Go
44+
configuration and mixed shards with rootless candidates enable
45+
`GOTOOLCHAIN=auto` after setup so each proof can select a newer toolchain without
46+
letting nested fixtures choose the shared baseline. Automatic fallback baselines
47+
are floored at Go 1.21, the first release with toolchain switching. Root-only
48+
candidates retain the setup action's `GOTOOLCHAIN=local`; the sanitized child
49+
keeps the selected setting while using its private writable module cache. Review
50+
job timeouts include the target installation and deterministic drive. Review
51+
jobs default to `ubuntu-latest`; `CLAWSWEEPER_REVIEW_RUNNER` remains an optional
52+
runner override.
5153

5254
For every candidate, trusted ClawSweeper code materializes the report's exact
5355
head SHA into a scratch worktree, then invokes the existing `live-proof`

0 commit comments

Comments
 (0)