chore(tools): add Claude cloud environment setup script

This commit is contained in:
sam committed 2026-10-12 00:12:18 +11:00
1 parent f4fb14d286
commit db51dbf463
1 file changed
+80
+80
View File
@@ -0,0 +1,80 @@
#!/usr/bin/env bash
# Claude Code cloud environment setup for archie-core. Standalone: runs before
# or without a checkout, so pins mirror go.mod, .golangci-version,
# tools/proto.sh and .github/workflows/quality.yml. Bump them together.
set -euo pipefail
GO_VERSION=1.27.2
NODE_MAJOR=24
TASK_VERSION=v3.48.0
GOLANGCI_VERSION=v2.14.0
GOFUMPT_VERSION=v0.11.0
BUF_VERSION=v1.71.0
PROTOC_GEN_GO_VERSION=v1.36.11
PROTOC_GEN_GO_GRPC_VERSION=v1.6.2
# bd must be the CGO build of the github-relationship-sync fork (beads PR 5971).
BEADS_REF=refs/pull/5971/head
SUDO=
[ "$(id -u)" -eq 0 ] || SUDO=sudo
export DEBIAN_FRONTEND=noninteractive
$SUDO apt-get update
$SUDO apt-get install -y --no-install-recommends \
ca-certificates curl git build-essential ripgrep gnupg lsb-release
if ! go version 2>/dev/null | grep -q "go$GO_VERSION "; then
arch=$(dpkg --print-architecture)
curl -fsSL "https://go.dev/dl/go$GO_VERSION.linux-$arch.tar.gz" -o /tmp/go.tgz
$SUDO rm -rf /usr/local/go
$SUDO tar -C /usr/local -xzf /tmp/go.tgz
rm /tmp/go.tgz
fi
export PATH="/usr/local/go/bin:$HOME/go/bin:$PATH"
GOBIN="$(go env GOPATH)/bin"
export GOBIN
if ! node --version 2>/dev/null | grep -q "^v$NODE_MAJOR\."; then
curl -fsSL "https://deb.nodesource.com/setup_$NODE_MAJOR.x" | $SUDO bash -
$SUDO apt-get install -y nodejs
fi
# pg_dump/pg_restore 18 are used by the gate.
$SUDO install -d /usr/share/postgresql-common/pgdg
$SUDO curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc \
-o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc
echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" \
| $SUDO tee /etc/apt/sources.list.d/pgdg.list >/dev/null
$SUDO apt-get update
$SUDO apt-get install -y --no-install-recommends postgresql-client-18
go install "github.com/go-task/task/v3/cmd/task@$TASK_VERSION"
go install "github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$GOLANGCI_VERSION"
go install "mvdan.cc/gofumpt@$GOFUMPT_VERSION"
go install "github.com/bufbuild/buf/cmd/buf@$BUF_VERSION"
go install "google.golang.org/protobuf/cmd/protoc-gen-go@$PROTOC_GEN_GO_VERSION"
go install "google.golang.org/grpc/cmd/protoc-gen-go-grpc@$PROTOC_GEN_GO_GRPC_VERSION"
src=$(mktemp -d)
git -C "$src" init -q
git -C "$src" fetch -q --depth 1 https://github.com/gastownhall/beads "$BEADS_REF"
git -C "$src" checkout -q FETCH_HEAD
(cd "$src" && CGO_ENABLED=1 go build -tags gms_pure_go \
-ldflags="-X main.Build=$(git rev-parse --short HEAD)" -o "$GOBIN/bd" ./cmd/bd)
rm -rf "$src"
profile=/etc/profile.d/archie-go.sh
echo 'export PATH="/usr/local/go/bin:$HOME/go/bin:$PATH"' | $SUDO tee "$profile" >/dev/null
# Warm module and npm caches when the checkout is already present.
repo=${CLAUDE_PROJECT_DIR:-$PWD}
if [ -f "$repo/go.mod" ] && grep -q archie-core "$repo/go.mod"; then
(cd "$repo" && go mod download && go -C tools mod download)
(cd "$repo/ui" && npm ci --no-audit --no-fund)
fi
go version
node --version
task --version
golangci-lint --version
bd --version