91 lines
3.3 KiB
Bash
Executable File
91 lines
3.3 KiB
Bash
Executable File
#!/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.3
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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"
|
|
|
|
# PostgreSQL 18 for e2e/stack.sh, which runs its own cluster. Never for
|
|
# tests: they use fakes.
|
|
if [ ! -x /usr/lib/postgresql/18/bin/postgres ]; then
|
|
$SUDO apt-get install -y --no-install-recommends postgresql-common
|
|
$SUDO /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y
|
|
$SUDO apt-get install -y --no-install-recommends postgresql-18
|
|
fi
|
|
|
|
# Commit and PR attribution stays off, matching local settings.
|
|
mkdir -p "$HOME/.claude"
|
|
settings="$HOME/.claude/settings.json"
|
|
[ -s "$settings" ] || echo '{}' >"$settings"
|
|
node -e '
|
|
const fs = require("fs"), p = process.argv[1];
|
|
const s = JSON.parse(fs.readFileSync(p, "utf8"));
|
|
s.attribution = { ...s.attribution, commit: "", pr: "", sessionUrl: false };
|
|
fs.writeFileSync(p, JSON.stringify(s, null, 2) + "\n");
|
|
' "$settings"
|
|
|
|
# Sign commits with the environment's own SSH key so Gitea and GitHub show
|
|
# them as verified.
|
|
mkdir -p "$HOME/.ssh"
|
|
echo "$SIGNING_KEY_B64" | base64 -d >"$HOME/.ssh/signing"
|
|
chmod 600 "$HOME/.ssh/signing"
|
|
git config --global gpg.format ssh
|
|
git config --global user.signingkey "$HOME/.ssh/signing"
|
|
git config --global commit.gpgsign true
|
|
git config --global user.email sam@catlow.tech
|
|
|
|
# The session shell is not a login shell, so profile.d is never read. Link the
|
|
# tools onto the default PATH instead.
|
|
$SUDO ln -sf /usr/local/go/bin/* "$GOBIN"/* /usr/local/bin/
|
|
|
|
# Warm module and pnpm 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" && corepack enable pnpm && pnpm install --frozen-lockfile)
|
|
fi
|
|
|
|
go version
|
|
node --version
|
|
task --version
|
|
golangci-lint --version
|