fix(make): use built candidate path in smoke targets (#6363)
* fix(make): quote build output paths (#5620) Agent-Signature: codex-gpt-5-unknown-reasoning on behalf of Ewen Cuthiell * test(make): scope fake Go PATH to the native build proof Restore the prior PATH in finally so later install scenarios do not inherit the fake compiler. Check that the YAML-extracted here-string begins with its shebang at byte zero; YAML's common block indentation is already removed. Refs gastownhall/beads#5667 Agent: unknown-model/unknown-reasoning * test(make): confine fake compiler environment to the build proof (saa-cgh.80) Agent-Signature: unknown-model/unknown-reasoning on behalf of Ewen Cuthiell * fix(make): use built candidate path in smoke targets (saa-cgh.97) Reported by bee-ghosttrack in gastownhall/beads#6340. Agent-Signature: unknown-model/unknown-reasoning on behalf of Ewen Cuthiell * fix(make): use shared build output for install (saa-cgh.97) Agent-Signature: unknown-model/unknown-reasoning on behalf of Ewen Cuthiell --------- Co-authored-by: Bee <bee@ghosttrack.com>
This commit is contained in:
parent
fc2351a51c
commit
8c889c1f23
2 changed files with 65 additions and 15 deletions
53
.github/workflows/pr.yml
vendored
53
.github/workflows/pr.yml
vendored
|
|
@ -1216,14 +1216,63 @@ jobs:
|
|||
$proofRoot = Join-Path $env:RUNNER_TEMP ("make install proof " + [guid]::NewGuid().ToString('N'))
|
||||
$fixtureRepo = Join-Path $proofRoot 'fixture repo'
|
||||
$buildDir = Join-Path $fixtureRepo 'build output'
|
||||
$fakeGoDir = Join-Path $proofRoot 'fake go bin'
|
||||
$installRoot = Join-Path $proofRoot 'install sandbox'
|
||||
$installProfile = Join-Path $installRoot 'profile with spaces'
|
||||
New-Item -ItemType Directory -Force -Path $buildDir, $installProfile | Out-Null
|
||||
New-Item -ItemType Directory -Force -Path $buildDir, $fakeGoDir, $installProfile | Out-Null
|
||||
Copy-Item -LiteralPath (Join-Path $env:GITHUB_WORKSPACE 'Makefile') -Destination $fixtureRepo
|
||||
Copy-Item -LiteralPath (Join-Path $env:GITHUB_WORKSPACE 'go.mod') -Destination $fixtureRepo
|
||||
|
||||
$sentinel = Join-Path $buildDir 'bd.exe'
|
||||
Set-Content -LiteralPath $sentinel -Encoding ascii -NoNewline -Value 'native-install-sentinel'
|
||||
$fakeGo = Join-Path $fakeGoDir 'go'
|
||||
$fakeGoScript = @'
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
[[ "${1-}" == build ]] || exit 91
|
||||
shift
|
||||
output=
|
||||
while (($#)); do
|
||||
case "$1" in
|
||||
-o)
|
||||
[[ $# -ge 2 ]] || exit 92
|
||||
output=$2
|
||||
shift 2
|
||||
;;
|
||||
*) shift ;;
|
||||
esac
|
||||
done
|
||||
[[ "$(cygpath -aw "$output")" == "$(cygpath -aw "$BEADS_FAKE_GO_EXPECTED_OUTPUT")" ]] || {
|
||||
printf 'fake go received output %q, expected %q\n' "$output" "$BEADS_FAKE_GO_EXPECTED_OUTPUT" >&2
|
||||
exit 93
|
||||
}
|
||||
printf native-build-sentinel > "$(cygpath -u "$output")"
|
||||
'@
|
||||
if (-not $fakeGoScript.StartsWith('#!', [StringComparison]::Ordinal)) {
|
||||
throw 'Fake Go shebang must start at byte zero after YAML extraction'
|
||||
}
|
||||
[IO.File]::WriteAllText(
|
||||
$fakeGo,
|
||||
($fakeGoScript -replace "`r`n", "`n"),
|
||||
[Text.UTF8Encoding]::new($false)
|
||||
)
|
||||
$priorPath = $env:PATH
|
||||
Push-Location $fixtureRepo
|
||||
try {
|
||||
$env:BEADS_FAKE_GO_EXPECTED_OUTPUT = $sentinel
|
||||
$env:PATH = "$fakeGoDir;$priorPath"
|
||||
& $make --no-print-directory "BUILD_DIR=$buildDir" GIT_BUILD=build-proof CC=proof build
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw 'Native Make build failed for a spaced BUILD_DIR'
|
||||
}
|
||||
} finally {
|
||||
$env:PATH = $priorPath
|
||||
Remove-Item -LiteralPath Env:BEADS_FAKE_GO_EXPECTED_OUTPUT
|
||||
Pop-Location
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath $sentinel -PathType Leaf)) {
|
||||
throw "Native Make did not build bd.exe at the exact spaced destination '$sentinel'"
|
||||
}
|
||||
$sentinelHash = (Get-FileHash -LiteralPath $sentinel -Algorithm SHA256).Hash
|
||||
|
||||
& $git -C $fixtureRepo init --quiet
|
||||
|
|
|
|||
27
Makefile
27
Makefile
|
|
@ -52,6 +52,7 @@ endif
|
|||
all: build
|
||||
|
||||
BUILD_DIR := .
|
||||
BD_BUILD_OUTPUT := $(BUILD_DIR)/bd$(if $(filter Windows_NT,$(OS)),.exe)
|
||||
GIT_BUILD := $(shell git rev-parse --short HEAD)
|
||||
ifeq ($(OS),Windows_NT)
|
||||
INSTALL_DIR := $(USERPROFILE)/.local/bin
|
||||
|
|
@ -104,21 +105,21 @@ build:
|
|||
ifeq ($(OS),Windows_NT)
|
||||
@if [ -n "$$CC" ]; then \
|
||||
echo "Using CC=$$CC"; \
|
||||
go build -tags "$(BUILD_TAGS)" -ldflags="-X main.Build=$(GIT_BUILD)" -o $(BUILD_DIR)/bd.exe ./cmd/bd; \
|
||||
go build -tags "$(BUILD_TAGS)" -ldflags="-X main.Build=$(GIT_BUILD)" -o "$(BD_BUILD_OUTPUT)" ./cmd/bd; \
|
||||
elif command -v gcc >/dev/null 2>&1; then \
|
||||
CC=gcc go build -tags "$(BUILD_TAGS)" -ldflags="-X main.Build=$(GIT_BUILD)" -o $(BUILD_DIR)/bd.exe ./cmd/bd; \
|
||||
CC=gcc go build -tags "$(BUILD_TAGS)" -ldflags="-X main.Build=$(GIT_BUILD)" -o "$(BD_BUILD_OUTPUT)" ./cmd/bd; \
|
||||
elif command -v clang >/dev/null 2>&1 && clang -dumpmachine 2>/dev/null | grep -qi 'windows.*gnu'; then \
|
||||
CC=clang go build -tags "$(BUILD_TAGS)" -ldflags="-X main.Build=$(GIT_BUILD)" -o $(BUILD_DIR)/bd.exe ./cmd/bd; \
|
||||
CC=clang go build -tags "$(BUILD_TAGS)" -ldflags="-X main.Build=$(GIT_BUILD)" -o "$(BD_BUILD_OUTPUT)" ./cmd/bd; \
|
||||
else \
|
||||
for bin in $(WINDOWS_CGO_BINS); do \
|
||||
if [ -x "$$bin/gcc.exe" ]; then \
|
||||
echo "Using Windows CGO gcc from $$bin"; \
|
||||
PATH="$$bin:$$PATH" CC=gcc go build -tags "$(BUILD_TAGS)" -ldflags="-X main.Build=$(GIT_BUILD)" -o $(BUILD_DIR)/bd.exe ./cmd/bd; \
|
||||
PATH="$$bin:$$PATH" CC=gcc go build -tags "$(BUILD_TAGS)" -ldflags="-X main.Build=$(GIT_BUILD)" -o "$(BD_BUILD_OUTPUT)" ./cmd/bd; \
|
||||
exit $$?; \
|
||||
fi; \
|
||||
if [ -x "$$bin/clang.exe" ] && "$$bin/clang.exe" -dumpmachine 2>/dev/null | grep -qi 'windows.*gnu'; then \
|
||||
echo "Using Windows CGO clang from $$bin"; \
|
||||
PATH="$$bin:$$PATH" CC=clang go build -tags "$(BUILD_TAGS)" -ldflags="-X main.Build=$(GIT_BUILD)" -o $(BUILD_DIR)/bd.exe ./cmd/bd; \
|
||||
PATH="$$bin:$$PATH" CC=clang go build -tags "$(BUILD_TAGS)" -ldflags="-X main.Build=$(GIT_BUILD)" -o "$(BD_BUILD_OUTPUT)" ./cmd/bd; \
|
||||
exit $$?; \
|
||||
fi; \
|
||||
done; \
|
||||
|
|
@ -128,9 +129,9 @@ ifeq ($(OS),Windows_NT)
|
|||
exit 1; \
|
||||
fi
|
||||
else
|
||||
go build -tags "$(BUILD_TAGS)" -ldflags="-X main.Build=$(GIT_BUILD)" -o $(BUILD_DIR)/bd ./cmd/bd
|
||||
go build -tags "$(BUILD_TAGS)" -ldflags="-X main.Build=$(GIT_BUILD)" -o "$(BD_BUILD_OUTPUT)" ./cmd/bd
|
||||
ifeq ($(shell uname),Darwin)
|
||||
@codesign -s - -f $(BUILD_DIR)/bd 2>/dev/null || true
|
||||
@codesign -s - -f "$(BD_BUILD_OUTPUT)" 2>/dev/null || true
|
||||
@echo "Signed bd for macOS"
|
||||
endif
|
||||
endif
|
||||
|
|
@ -264,7 +265,7 @@ test-regression:
|
|||
# Override version: ./scripts/upgrade-smoke-test.sh v0.62.0
|
||||
test-upgrade: build
|
||||
@echo "Running upgrade smoke tests..."
|
||||
@CANDIDATE_BIN=./bd ./scripts/upgrade-smoke-test.sh
|
||||
@CANDIDATE_BIN="$(BD_BUILD_OUTPUT)" ./scripts/upgrade-smoke-test.sh
|
||||
|
||||
|
||||
# Run cross-version smoke tests (last 30 tags → candidate).
|
||||
|
|
@ -273,14 +274,14 @@ test-upgrade: build
|
|||
# All from v0.30.0: ./scripts/cross-version-smoke-test.sh --from v0.30.0
|
||||
test-cross-version: build
|
||||
@echo "Running cross-version smoke tests..."
|
||||
@CANDIDATE_BIN=./bd ./scripts/cross-version-smoke-test.sh
|
||||
@CANDIDATE_BIN="$(BD_BUILD_OUTPUT)" ./scripts/cross-version-smoke-test.sh
|
||||
|
||||
# Run the authenticated historical upgrade corpus with strict fidelity checks.
|
||||
# All qualified versions: ./scripts/migration-test/run.sh
|
||||
# Single version: ./scripts/migration-test/run.sh --version v0.49.6
|
||||
test-migration: build
|
||||
@echo "Running migration test harness..."
|
||||
@CANDIDATE_BIN=./bd ./scripts/migration-test/run.sh
|
||||
@CANDIDATE_BIN="$(BD_BUILD_OUTPUT)" ./scripts/migration-test/run.sh
|
||||
|
||||
# Regenerate the golden-JSON contract corpus (cmd/bd/protocol/testdata/corpus/).
|
||||
# Run after any deliberate bd --json wire change; review the diff, then commit.
|
||||
|
|
@ -351,10 +352,10 @@ install install-force: build
|
|||
@mkdir -p "$(INSTALL_DIR)"
|
||||
ifeq ($(OS),Windows_NT)
|
||||
@rm -f "$(INSTALL_DIR)/bd" "$(INSTALL_DIR)/bd.exe"
|
||||
@cp "$(BUILD_DIR)/bd.exe" "$(INSTALL_DIR)/bd.exe"
|
||||
@cp "$(BD_BUILD_OUTPUT)" "$(INSTALL_DIR)/bd.exe"
|
||||
@echo "Installed bd.exe to $(INSTALL_DIR)/bd.exe"
|
||||
else
|
||||
@cp "$(BUILD_DIR)/bd" "$(INSTALL_DIR)/.bd.install.tmp.$$$$" && mv -f "$(INSTALL_DIR)/.bd.install.tmp.$$$$" "$(INSTALL_DIR)/bd"
|
||||
@cp "$(BD_BUILD_OUTPUT)" "$(INSTALL_DIR)/.bd.install.tmp.$$$$" && mv -f "$(INSTALL_DIR)/.bd.install.tmp.$$$$" "$(INSTALL_DIR)/bd"
|
||||
@echo "Installed bd to $(INSTALL_DIR)/bd"
|
||||
@ln -sfn bd "$(INSTALL_DIR)/.beads.install.tmp.$$$$" && mv -f "$(INSTALL_DIR)/.beads.install.tmp.$$$$" "$(INSTALL_DIR)/beads"
|
||||
@echo "Created 'beads' alias -> bd"
|
||||
|
|
@ -376,7 +377,7 @@ fmt-check:
|
|||
# Validate documentation references against actual CLI flags
|
||||
check-docs:
|
||||
@echo "Building bd for docs checks..."
|
||||
@CGO_ENABLED=0 go build -tags "$(BUILD_TAGS)" -ldflags="-X main.Build=$(GIT_BUILD)" -o $(BUILD_DIR)/bd ./cmd/bd
|
||||
@CGO_ENABLED=0 go build -tags "$(BUILD_TAGS)" -ldflags="-X main.Build=$(GIT_BUILD)" -o "$(BUILD_DIR)/bd" ./cmd/bd
|
||||
@./scripts/check-doc-flags.sh ./bd
|
||||
@./scripts/check-doc-freshness.sh
|
||||
@go test -tags=gms_pure_go ./test/docsync
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue