Re-vendor the shared files from sneak/prompts at dd4027b (closes #113)
check / check (push) Waiting to run
check / check (push) Waiting to run
The shared files are the sneak/prompts copies at dd4027b, plus this repository's own entries. make lint and make test each build one Dockerfile phase without the cache, both covering the frontend; the builder stage waits on both and takes its version from git describe unless VERSION is given. The test phase keeps Go's module and build caches in memory, out of the image make test tags. golangci-lint moves to v2.14.0 with the new .golangci.yml; one test spells X-Request-ID as canonicalheader asks. prettier formats only JavaScript, CSS, HTML and Markdown, so .golangci.yml stays as fetched. script/fmt and script/fmt-check put ~/.local/bin on PATH. script/bootstrap keeps a Go only if it is exactly GO_VERSION, and re-checks the go on PATH after installing. Model: opus-5-5
This commit was merged in pull request #115.
This commit is contained in:
+31
-15
@@ -6,17 +6,16 @@
|
||||
# used directly if it is at least NODE_MIN_VERSION; otherwise it is
|
||||
# installed at a pinned version via nvm (installing nvm itself first,
|
||||
# from a hash-verified release archive, never curl | sh). Go, with its
|
||||
# gofmt, is used directly if it is at least the version backend/go.mod
|
||||
# asks for; otherwise the pinned Go release is installed from its
|
||||
# hash-verified archive.
|
||||
# gofmt, is used directly only if it is exactly GO_VERSION; otherwise
|
||||
# that release is installed from its hash-verified archive.
|
||||
#
|
||||
# What this script installs outside the system package manager lives
|
||||
# under $HOME and is linked into ~/.local/bin, where make and the git
|
||||
# hook find it once that directory is on PATH. Nothing in ~/.local/bin
|
||||
# that this script did not create is ever replaced.
|
||||
#
|
||||
# golangci-lint is not installed: make lint runs it in Docker, which
|
||||
# this script does not install either.
|
||||
# golangci-lint is not installed: make lint runs it in Docker, as make
|
||||
# test runs the tests, and this script does not install Docker either.
|
||||
#
|
||||
# Unlike the org model: Go and gcc for backend/, a newer node for eslint.
|
||||
set -eu
|
||||
@@ -186,20 +185,30 @@ ensure_yarn() {
|
||||
}
|
||||
|
||||
# go_ok: the go on PATH has its gofmt beside it (a Go release ships the
|
||||
# two together) and is at least the version backend/go.mod asks for.
|
||||
# GOTOOLCHAIN=local makes an older go fail here instead of fetching a
|
||||
# newer toolchain for itself.
|
||||
# two together) and go version reports exactly GO_VERSION, compared over
|
||||
# the whole version, not a prefix of it. A go that fails or prints
|
||||
# anything else does not pass. GOTOOLCHAIN=local makes go report itself
|
||||
# rather than a toolchain it would fetch.
|
||||
go_ok() {
|
||||
if missing go; then return 1; fi
|
||||
[ -x "$(dirname "$(command -v go)")/gofmt" ] || return 1
|
||||
(cd "$ROOT/backend" && GOTOOLCHAIN=local go list -m >/dev/null 2>&1)
|
||||
version="$(GOTOOLCHAIN=local go version 2>/dev/null)" || return 1
|
||||
case "$version" in
|
||||
"go version go$GO_VERSION "*) return 0 ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# ensure_go: unless go_ok, install GO_VERSION and link its go and gofmt.
|
||||
# They are linked on every run that needs them, so a deleted link is put
|
||||
# back, and the archive is unpacked again if either binary is missing.
|
||||
# Afterwards go is looked up through PATH again and must pass go_ok, so
|
||||
# another go that hides the link stops bootstrap.
|
||||
ensure_go() {
|
||||
if go_ok; then return 0; fi
|
||||
if go_ok; then
|
||||
echo "bootstrap: using $(GOTOOLCHAIN=local go version)"
|
||||
return 0
|
||||
fi
|
||||
go_dir="$TOOLCHAIN/go-$GO_VERSION"
|
||||
if [ ! -x "$go_dir/bin/go" ] || [ ! -x "$go_dir/bin/gofmt" ]; then
|
||||
# sha256 of each archive, from https://go.dev/dl/?mode=json
|
||||
@@ -240,6 +249,13 @@ ensure_go() {
|
||||
fi
|
||||
link_bin "$go_dir/bin/go" go
|
||||
link_bin "$go_dir/bin/gofmt" gofmt
|
||||
hash -r
|
||||
if ! go_ok; then
|
||||
echo "bootstrap: after installing go $GO_VERSION in $go_dir," >&2
|
||||
echo " the go on PATH, $(command -v go), is not it or has no gofmt" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "bootstrap: installed $(GOTOOLCHAIN=local go version)"
|
||||
}
|
||||
|
||||
main() {
|
||||
@@ -256,9 +272,9 @@ main() {
|
||||
|
||||
if missing make; then pkg_install gnumake make make make; fi
|
||||
if missing git; then pkg_install git git git git; fi
|
||||
# The race detector in make test needs cgo, which Go turns on only
|
||||
# when it finds its C compiler, gcc on Linux. apt and apk ship the C
|
||||
# library headers apart from gcc.
|
||||
# The race detector in backend/'s make test needs cgo, which Go turns
|
||||
# on only when it finds its C compiler, gcc on Linux. apt and apk
|
||||
# ship the C library headers apart from gcc.
|
||||
if missing gcc; then
|
||||
pkg_install gcc "gcc libc6-dev" gcc "gcc musl-dev"
|
||||
fi
|
||||
@@ -271,8 +287,8 @@ main() {
|
||||
(cd "$ROOT/backend" && go mod download)
|
||||
|
||||
if missing docker; then
|
||||
echo "bootstrap: docker not found; make lint, and so make check" >&2
|
||||
echo " and the pre-commit hook, need it to run the linters" >&2
|
||||
echo "bootstrap: docker not found; make test and make lint, and so" >&2
|
||||
echo " make check and the pre-commit hook, need it" >&2
|
||||
fi
|
||||
if [ -n "$path_hint" ] && [ -d "$BIN_DIR" ]; then
|
||||
echo "bootstrap: add $BIN_DIR to the front of your PATH, e.g." >&2
|
||||
|
||||
Reference in New Issue
Block a user