Bazel Build System Implementation Plan¶
For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (
- [ ]) syntax for tracking.
Goal: Give the repo a single-command, hermetic, incrementally-cached polyglot build/deploy by putting the Go services + container images under Bazel and fronting everything with a thin Makefile that also bootstraps its own toolchain.
Architecture: Bazel (bzlmod, via bazelisk pinned in .bazelversion) owns the hermetic core — Go binaries via rules_go+gazelle, container images via rules_oci. The Vite/TanStack Start frontend stays on pnpm, wrapped as one coarse non-hermetic Bazel leaf. A root Makefile is the ergonomic face (make bootstrap/build/images/push/prod) and orchestrates the edges (frontend leaf, Helm deploy). Backend source of truth is Go; the JS server/* services leave the default build path.
Tech Stack: Bazel 7.x (bzlmod) + bazelisk, rules_go 0.50.x, gazelle 0.39.x, rules_oci 2.x, rules_pkg 1.x, aspect_bazel_lib 2.x; Go 1.23 (hermetic SDK, no local install); pnpm + Vite (frontend leaf); Helm (deploy); GNU Make + bash (orchestration/bootstrap).
Global Constraints¶
Backend source of truth is Go (
go-services/, modulegithub.com/rmhstudios/rmh-go, go 1.23). JSserver/*services are NOT a build target.Services (9):
gateway gamehub rmhmusic rmhtube rmhbox recap doctrine-worker vibe-worker discord-bot.Image naming MUST match existing convention:
rmhstudios-go-<svc>:<SHA>, optional<REGISTRY>/prefix;SHA=git rev-parse --short HEAD(fallbackdev).Helm release
rmhstudios-go, chartdeploy/helm/rmhstudios-go, prod valuesvalues-prod.yaml, deployed with--set image.tag=<SHA> --set image.registry=<REGISTRY> --atomic --wait.Special runtime deps:
vibe-worker→ chromium (+ nss freetype harfbuzz ttf-freefont);discord-bot→ git + openssh-client.gois NOT a required local install.node/pnpmrequired for the frontend leaf only.Bazel is invoked through bazelisk; never call a system
bazeldirectly. Version pinned in.bazelversion.Frontend leaf is deliberately non-hermetic (reuses repo
node_modules); tag its actionlocal.Commit after every task. Never commit a broken
bazel build //go-services/....
File Structure¶
Created:
.bazelversion— pinned Bazel version (bazelisk reads this)..bazeliskrc— bazelisk config (optional mirror/format).MODULE.bazel— bzlmod deps + Go SDK + go_deps + oci.pull bases..bazelrc— build flags, disk cache, platform config,linuxconfig group.BUILD.bazel(root) — gazelle target,//:frontendleaf, top-level aliases.bazel/defs.bzl—go_service_imagemacro (DRY image/load/push across 9 services).bazel/BUILD.bazel— exportsdefs.bzl.go-services/BUILD.bazel— gazelle prefix directive (generated/augmented).go-services/**/BUILD.bazel— generated by gazelle (libraries, binaries, tests).scripts/preflight.sh— bootstrap + dependency self-install + guard.deploy/docker/base-chromium.Dockerfile,deploy/docker/base-git.Dockerfile— special runtime bases.Makefile(root) — ergonomic targets.
Modified:
package.json— addbuild:frontendscript (Vite only)..gitignore— ignorebazel-*symlinks..github/workflows/go-microservices.yml— switch to Bazel + bootstrap.
Task 1: Pin Bazel + scaffold bzlmod with the Go SDK¶
Files:
Create:
.bazelversion,.bazeliskrc,MODULE.bazel,.bazelrc,BUILD.bazel,.gitignore(modify)
Interfaces:
Produces: a working Bazel workspace where
bazelisk info workspacesucceeds and the hermetic Go SDK (1.23) is registered. No targets yet.Step 1: Install bazelisk (the only prereq Bazel needs)
Run: brew install bazelisk
Expected: bazelisk on PATH; which bazelisk prints a path. (bazelisk transparently downloads the pinned Bazel.)
Step 2: Pin the Bazel version
Create .bazelversion:
7.4.1
Create .bazeliskrc:
USE_BAZEL_VERSION=7.4.1
Step 3: Write MODULE.bazel
Create MODULE.bazel:
module(name = "rmhstudios", version = "0.1.0")
bazel_dep(name = "rules_go", version = "0.50.1")
bazel_dep(name = "gazelle", version = "0.39.1")
bazel_dep(name = "rules_oci", version = "2.0.0")
bazel_dep(name = "rules_pkg", version = "1.0.1")
bazel_dep(name = "aspect_bazel_lib", version = "2.8.1")
bazel_dep(name = "platforms", version = "0.0.10")
go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(version = "1.23.0")
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//go-services:go.mod")
# use_repo(go_deps, ...) is populated by `bazel mod tidy` in Task 2.
oci = use_extension("@rules_oci//oci:extensions.bzl", "oci")
oci.pull(
name = "distroless_base",
image = "gcr.io/distroless/static-debian12",
platforms = ["linux/amd64", "linux/arm64"],
tag = "nonroot",
)
use_repo(oci, "distroless_base", "distroless_base_linux_amd64", "distroless_base_linux_arm64")
Step 4: Write .bazelrc
Create .bazelrc:
common --enable_bzlmod
build --disk_cache=~/.cache/bazel-disk
build --incompatible_strict_action_env
test --test_output=errors
# Cross-compile Go services for Linux containers.
build:linux_amd64 --platforms=@rules_go//go/toolchain:linux_amd64
build:linux_arm64 --platforms=@rules_go//go/toolchain:linux_arm64
# Frontend leaf reuses repo node_modules → must not sandbox.
build --strategy=GenRule=local
Step 5: Write the root BUILD.bazel with the gazelle target
Create BUILD.bazel:
load("@gazelle//:def.bzl", "gazelle")
# gazelle:prefix github.com/rmhstudios/rmh-go
gazelle(name = "gazelle")
Step 6: Ignore Bazel symlinks
Add to .gitignore:
# Bazel
/bazel-*
Step 7: Verify the workspace loads
Run: bazelisk info workspace
Expected: prints the repo root path, exit 0. (First run downloads Bazel 7.4.1 + Go SDK — may take a minute.)
Step 8: Commit
git add .bazelversion .bazeliskrc MODULE.bazel .bazelrc BUILD.bazel .gitignore
git commit -m "build(bazel): scaffold bzlmod workspace with hermetic Go SDK"
Task 2: Generate Go BUILD files with gazelle and build all 9 binaries¶
Files:
Create:
go-services/**/BUILD.bazel(generated)Modify:
MODULE.bazel(use_repo populated bybazel mod tidy)
Interfaces:
Produces:
//go-services/cmd/<svc>:<svc>go_binary targets for all 9 services;//go-services/...builds clean. Later tasks reference these binary labels.Step 1: Resolve external Go deps into the module graph
Run: bazelisk mod tidy
Expected: MODULE.bazel gains a use_repo(go_deps, ...) block listing com_github_* repos (discordgo, pgx, go-redis, chromedp, prometheus, etc.). Exit 0.
Step 2: Generate BUILD files
Run: bazelisk run //:gazelle
Expected: creates BUILD.bazel under go-services/cmd/*, go-services/internal/*, go-services/pkg/*. git status shows new generated files.
Step 3: Build everything Go (verify it FAILS first if deps unresolved, else passes)
Run: bazelisk build //go-services/...
Expected: PASS — all 9 binaries compile. If it fails on a missing repo, re-run bazelisk mod tidy then bazelisk run //:gazelle and retry (gazelle sometimes needs a second pass to wire importpath deps).
Step 4: Verify all 9 binary targets exist
Run: bazelisk query 'kind("go_binary", //go-services/cmd/...)'
Expected: 9 labels — //go-services/cmd/gateway:gateway … //go-services/cmd/discord-bot:discord-bot.
Step 5: Sanity-run one binary built by Bazel (host platform)
Run: bazelisk run //go-services/cmd/gateway:gateway -- --help 2>&1 | head -5 || true
Expected: the gateway binary executes (help text or a startup/config error — proves it links and runs). No Bazel build error.
Step 6: Commit
git add MODULE.bazel go-services
git commit -m "build(bazel): gazelle-generated BUILD files; all 9 Go services build hermetically"
Task 3: Verify Go tests run under Bazel¶
Files:
Uses gazelle-generated
go_testtargets under//go-services/....
Interfaces:
Produces:
bazelisk test //go-services/...as the canonical Go test command (wired intomake testin Task 8).Step 1: Enumerate the generated test targets
Run: bazelisk query 'kind("go_test", //go-services/...)'
Expected: a list of *_test targets (one per package with *_test.go). If empty, gazelle found no Go tests — note that and skip to Step 3.
Step 2: Run the Go test suite via Bazel
Run: bazelisk test //go-services/...
Expected: PASS (or “no test targets found” if none exist). No build errors. Cached results show (cached) on re-run.
Step 3: Confirm cross-compile config builds for Linux
Run: bazelisk build --config=linux_arm64 //go-services/cmd/gateway:gateway
Expected: PASS — proves the Linux platform transition works (needed for images in Task 5).
Step 4: Commit
No file changes expected; if gazelle adjusted any BUILD on this pass:
git add -A && git commit -m "build(bazel): confirm go test + linux cross-compile under Bazel" || echo "nothing to commit"
Task 4: Add the frontend leaf and split the Vite-only build script¶
Files:
Modify:
package.jsonModify:
BUILD.bazel(add//:frontend)
Interfaces:
Consumes: pnpm + the repo’s existing
node_modules.Produces:
//:frontendfilegroup whose output is the built web app (.output/), consumed by the frontend image in Task 6. New npm scriptbuild:frontend.Step 1: Add a Vite-only build script
In package.json scripts, add (next to the existing build):
"build:frontend": "cross-env NODE_OPTIONS=--max-old-space-size=8192 pnpm run build-vibe-packages && vite build",
(Leaves out the esbuild backend step — Go is the backend now. The old build stays for transition.)
Step 2: Verify the script produces output
Run: pnpm run build:frontend
Expected: Vite build completes; .output/ directory is created. (This also warms node_modules for the Bazel leaf.)
Step 3: Add the coarse Bazel leaf
Append to BUILD.bazel:
load("@aspect_bazel_lib//lib:run_binary.bzl", "run_binary")
# Coarse, deliberately non-hermetic frontend build: shells out to pnpm,
# reusing the repo's node_modules. Tagged local/no-sandbox by design.
genrule(
name = "frontend",
srcs = glob(
["app/**", "components/**", "lib/**", "stores/**", "public/**"],
allow_empty = True,
) + [
"package.json",
"pnpm-lock.yaml",
"vite.config.ts",
"tsconfig.json",
],
outs = ["frontend_dist.tar"],
cmd = "pnpm run build:frontend >/dev/null && tar -cf $(location frontend_dist.tar) .output",
local = True,
tags = ["no-sandbox", "requires-network"],
)
Step 4: Build the leaf through Bazel
Run: bazelisk build //:frontend
Expected: PASS — produces bazel-bin/frontend_dist.tar. (Runs locally, uses node_modules.)
Step 5: Commit
git add package.json BUILD.bazel
git commit -m "build(bazel): add coarse frontend leaf + build:frontend script"
Task 6: Wire OCI images for the 7 standard services + frontend image¶
Files:
Modify:
go-services/cmd/<svc>/BUILD.bazelfor the 7 standard services (appendgo_service_image).Modify:
BUILD.bazel(frontend image).
Interfaces:
Consumes:
//go-services/cmd/<svc>:<svc>(Task 2),go_service_image(Task 5),//:frontend(Task 4).Produces:
<svc>_image/<svc>_loadtargets for the 7 standard services + afrontend_image/frontend_load. (vibe-worker, discord-bot handled in Task 7.)Step 1: Add an image to one standard service first (gateway)
Append to go-services/cmd/gateway/BUILD.bazel:
load("//bazel:defs.bzl", "go_service_image")
go_service_image(
name = "gateway", # NOTE: rename to avoid clashing with the go_binary target name
binary = "//go-services/cmd/gateway:gateway_bin",
platform = "@rules_go//go/toolchain:linux_arm64",
)
Then rename the gazelle-generated go_binary target in that file from name = "gateway" to name = "gateway_bin" (and update its embed/visibility references). Re-run bazelisk run //:gazelle is NOT needed — edit by hand to keep the binary label :gateway_bin.
Step 2: Build + load the gateway image into Docker
Run: bazelisk run //go-services/cmd/gateway:gateway_load
Expected: image rmhstudios-go-gateway:dev loaded. Verify: docker image inspect rmhstudios-go-gateway:dev >/dev/null && echo OK.
Step 3: Run the loaded image
Run: docker run --rm rmhstudios-go-gateway:dev --help 2>&1 | head -3 || true
Expected: the gateway binary runs inside the container (help text or config error — not an exec-format/arch error).
Step 4: Repeat for the other 6 standard services
For each of gamehub rmhmusic rmhtube rmhbox recap doctrine-worker: append the same go_service_image block (with the service name) to its go-services/cmd/<svc>/BUILD.bazel, renaming the go_binary to <svc>_bin. Use platform = "@rules_go//go/toolchain:linux_arm64".
Then run: bazelisk build $(bazelisk query 'attr(name, ".*_image", //go-services/cmd/...)' 2>/dev/null)
Expected: all standard _image targets build.
Step 5: Add the frontend image
Append to BUILD.bazel:
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_load")
oci_image(
name = "frontend_image",
base = "@distroless_base",
tars = ["//:frontend"], # frontend_dist.tar
)
oci_load(
name = "frontend_load",
image = ":frontend_image",
repo_tags = ["rmhstudios-frontend:dev"],
)
Step 6: Build the frontend image
Run: bazelisk build //:frontend_image
Expected: PASS.
Step 7: Commit
git add go-services BUILD.bazel
git commit -m "build(bazel): OCI images for the 7 standard services + frontend"
Task 7: Special-base images for vibe-worker + discord-bot¶
Files:
Create:
deploy/docker/base-chromium.Dockerfile,deploy/docker/base-git.DockerfileModify:
MODULE.bazel(oci.pull the two bases),go-services/cmd/vibe-worker/BUILD.bazel,go-services/cmd/discord-bot/BUILD.bazel
Interfaces:
Consumes:
go_service_image(Task 5).Produces:
vibe-worker_image/discord-bot_imageon chromium/git bases.Step 1: Author the chromium base Dockerfile
Create deploy/docker/base-chromium.Dockerfile:
# Runtime base for vibe-worker: Alpine + headless Chromium.
FROM alpine:3.20
RUN apk add --no-cache ca-certificates tzdata chromium nss freetype harfbuzz ttf-freefont \
&& addgroup -S app && adduser -S app -G app
ENV PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=/usr/bin/chromium-browser
Step 2: Author the git base Dockerfile
Create deploy/docker/base-git.Dockerfile:
# Runtime base for discord-bot: Alpine + git/ssh for RMHBot.
FROM alpine:3.20
RUN apk add --no-cache ca-certificates tzdata git openssh-client \
&& addgroup -S app && adduser -S app -G app
Step 3: Build + push the base images (or load locally for dev)
Run (local-dev path, no registry):
docker build -f deploy/docker/base-chromium.Dockerfile -t rmhstudios-go-base-chromium:dev deploy/docker
docker build -f deploy/docker/base-git.Dockerfile -t rmhstudios-go-base-git:dev deploy/docker
Expected: two base images built. For multi-node, push them to $REGISTRY and reference by digest in Step 4.
Step 4: Pull the bases into Bazel
Append to MODULE.bazel (after the existing oci.pull), using a registry-hosted ref + digest in CI, or a local daemon ref for dev:
oci.pull(
name = "base_chromium",
image = "ghcr.io/rmhstudios/rmhstudios-go-base-chromium",
platforms = ["linux/arm64", "linux/amd64"],
tag = "dev",
)
oci.pull(
name = "base_git",
image = "ghcr.io/rmhstudios/rmhstudios-go-base-git",
platforms = ["linux/arm64", "linux/amd64"],
tag = "dev",
)
use_repo(oci, "base_chromium", "base_git")
Step 5: Wire the two special images
Append to go-services/cmd/vibe-worker/BUILD.bazel (rename go_binary to vibe-worker_bin):
load("//bazel:defs.bzl", "go_service_image")
go_service_image(
name = "vibe-worker",
binary = "//go-services/cmd/vibe-worker:vibe-worker_bin",
base = "@base_chromium",
platform = "@rules_go//go/toolchain:linux_arm64",
)
Append to go-services/cmd/discord-bot/BUILD.bazel (rename go_binary to discord-bot_bin):
load("//bazel:defs.bzl", "go_service_image")
go_service_image(
name = "discord-bot",
binary = "//go-services/cmd/discord-bot:discord-bot_bin",
base = "@base_git",
platform = "@rules_go//go/toolchain:linux_arm64",
)
Step 6: Build both special images
Run: bazelisk build //go-services/cmd/vibe-worker:vibe-worker_image //go-services/cmd/discord-bot:discord-bot_image
Expected: PASS (requires the bases to be pullable — local daemon or registry).
Step 7: Commit
git add deploy/docker MODULE.bazel go-services/cmd/vibe-worker go-services/cmd/discord-bot
git commit -m "build(bazel): chromium/git base images for vibe-worker + discord-bot"
Task 8: Bootstrap script (dependency self-install + guard)¶
Files:
Create:
scripts/preflight.sh
Interfaces:
Produces:
scripts/preflight.sh [--guard]—make bootstrapruns full install;--guardis the fast check run before build targets.Step 1: Write preflight.sh
Create scripts/preflight.sh:
#!/usr/bin/env bash
# Toolchain bootstrap + guard for the Bazel build system.
# scripts/preflight.sh # full bootstrap (install missing)
# scripts/preflight.sh --guard # fast check; install cheap, hard-fail on heavy
set -euo pipefail
GUARD=0; [ "${1:-}" = "--guard" ] && GUARD=1
OS="$(uname -s)"
have() { command -v "$1" >/dev/null 2>&1; }
say() { printf '\033[1;36m[preflight]\033[0m %s\n' "$*"; }
die() { printf '\033[1;31m[preflight]\033[0m %s\n' "$*" >&2; exit 1; }
pkg_install() {
case "$OS" in
Darwin) have brew || die "Homebrew required: https://brew.sh"; brew install "$1" ;;
Linux)
if have apt-get; then sudo apt-get update -y && sudo apt-get install -y "$1";
elif have apk; then sudo apk add --no-cache "$1";
else die "No supported package manager (apt/apk) found"; fi ;;
*) die "Unsupported OS: $OS" ;;
esac
}
# bazelisk — the one true entrypoint.
if ! have bazelisk && ! have bazel; then
say "installing bazelisk"
case "$OS" in Darwin) pkg_install bazelisk ;; Linux) pkg_install bazelisk || pkg_install bazel ;; esac
fi
# node — required for the frontend leaf. Heavy runtime: install on bootstrap, guide on guard.
if ! have node; then
if [ "$GUARD" = 1 ]; then die "node missing — install Node 20+ then re-run (e.g. 'brew install node')"; fi
pkg_install node
fi
# pnpm via corepack (ships with node).
if ! have pnpm; then say "enabling pnpm via corepack"; corepack enable pnpm || die "corepack enable failed"; fi
# helm — only needed at deploy.
if ! have helm; then
if [ "$GUARD" = 1 ]; then say "helm missing (only needed for 'make prod')"; else pkg_install helm; fi
fi
# docker — daemon cannot be auto-provisioned; hard-fail with guidance.
if ! have docker; then die "docker missing — install Docker Desktop / Engine, then re-run"; fi
if ! docker info >/dev/null 2>&1; then die "docker daemon not running — start Docker, then re-run"; fi
say "toolchain OK"
Step 2: Make it executable + run the guard
Run: chmod +x scripts/preflight.sh && ./scripts/preflight.sh --guard
Expected: [preflight] toolchain OK (bazelisk/node/pnpm/docker all present in this env; helm present).
Step 3: Commit
git add scripts/preflight.sh
git commit -m "build: add preflight bootstrap + guard script"
Task 9: The root Makefile (single-command entrypoint)¶
Files:
Create:
Makefile
Interfaces:
Consumes: all Bazel targets above,
scripts/preflight.sh, existingdeploy/helm/rmhstudios-go.Produces:
make bootstrap/dev/gazelle/build/images/push/prod/test/clean.Step 1: Write the Makefile
Create Makefile:
# rmhstudios.com — single-command build/deploy entrypoint.
# Bazel (via bazelisk) owns the hermetic core; this Makefile is the ergonomic face.
BAZEL ?= bazelisk
SERVICES := gateway gamehub rmhmusic rmhtube rmhbox recap doctrine-worker vibe-worker discord-bot
SHA := $(shell git rev-parse --short HEAD 2>/dev/null || echo dev)
REGISTRY ?=
RELEASE ?= rmhstudios-go
CHART := deploy/helm/rmhstudios-go
GUARD := ./scripts/preflight.sh --guard
.PHONY: bootstrap dev gazelle build images push prod test test-e2e clean help
help: ## list targets
@grep -hE '^[a-z-]+:.*?## ' $(MAKEFILE_LIST) | awk -F':.*?## ' '{printf " \033[36m%-12s\033[0m %s\n",$$1,$$2}'
bootstrap: ## install/verify all toolchain prerequisites
./scripts/preflight.sh
dev: ## run the existing pnpm dev loop (Bazel not involved)
pnpm run dev
gazelle: ## regenerate Go BUILD.bazel files
$(BAZEL) run //:gazelle
build: ## build artifacts: all Go binaries + frontend bundle
@$(GUARD)
$(BAZEL) build //go-services/... //:frontend
images: ## build + load every service image into Docker
@$(GUARD)
@for svc in $(SERVICES); do \
echo "==> loading rmhstudios-go-$$svc"; \
$(BAZEL) run //go-services/cmd/$$svc:$${svc}_load || exit 1; \
done
$(BAZEL) run //:frontend_load
push: ## push every service image to $REGISTRY (REGISTRY must be set)
@test -n "$(REGISTRY)" || { echo "REGISTRY is required for push"; exit 1; }
@$(GUARD)
@for svc in $(SERVICES); do \
echo "==> pushing $(REGISTRY)/rmhstudios-go-$$svc:$(SHA)"; \
$(BAZEL) run //go-services/cmd/$$svc:$${svc}_push -- \
--repository=$(REGISTRY)/rmhstudios-go-$$svc --tag=$(SHA) || exit 1; \
done
prod: images ## build images, push, and deploy to the cluster via Helm
@$(GUARD)
@if [ -n "$(REGISTRY)" ]; then $(MAKE) push REGISTRY=$(REGISTRY); fi
helm upgrade --install $(RELEASE) $(CHART) \
-f $(CHART)/values-prod.yaml \
--set image.tag=$(SHA) --set image.registry=$(REGISTRY) \
--atomic --wait --timeout 5m
test: ## run Go tests (Bazel) + frontend tests (vitest)
@$(GUARD)
$(BAZEL) test //go-services/...
pnpm test
test-e2e: ## run the Go end-to-end suite
cd go-services && bash scripts/e2e/run.sh
clean: ## remove Bazel outputs
$(BAZEL) clean
Step 2: Verify help + a real target
Run: make help && make build
Expected: target list prints; make build runs the guard then builds //go-services/... and //:frontend (PASS).
Step 3: Verify deploy config renders (no live cluster needed)
Run: helm template $(RELEASE) $(CHART) -f $(CHART)/values-prod.yaml --set image.tag=$(SHA) >/dev/null && echo "helm OK"
Expected: helm OK — proves make prod’s Helm invocation is well-formed. (Actual helm upgrade requires a cluster.)
Step 4: Commit
git add Makefile
git commit -m "build: add root Makefile single-command entrypoint (build/images/prod)"
Task 10: Switch CI to Bazel + bootstrap¶
Files:
Modify:
.github/workflows/go-microservices.yml
Interfaces:
Consumes:
make bootstrap,bazelisk test //go-services/....Produces: a CI job that bootstraps then runs the Bazel test graph with caching.
Step 1: Replace the build-test job body
Edit .github/workflows/go-microservices.yml — replace the build-test job’s steps (the setup-go + raw go build/vet/test/gofmt steps) with:
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.cache/bazel-disk
key: bazel-disk-${{ runner.os }}-${{ hashFiles('go-services/go.sum', 'MODULE.bazel') }}
restore-keys: bazel-disk-${{ runner.os }}-
- name: bootstrap toolchain
run: make bootstrap
- name: build + test (bazel)
run: bazelisk test //go-services/...
Remove the defaults.run.working-directory: go-services for this job (Bazel runs from repo root); keep it for the e2e job.
Step 2: Validate the workflow YAML
Run: python3 -c "import yaml,sys; yaml.safe_load(open('.github/workflows/go-microservices.yml')); print('yaml OK')"
Expected: yaml OK.
Step 3: Commit
git add .github/workflows/go-microservices.yml
git commit -m "ci: run Go services via Bazel test graph with disk cache"
Self-Review¶
Spec coverage:
Single command → Task 9 (
make build/prod). ✓Hermetic Go (no local go) → Tasks 1–2 (hermetic SDK;
goconfirmed absent). ✓Unified polyglot graph →
bazel build //...spans Go + images + frontend leaf (Tasks 2,4,6). ✓Incremental + caching → disk cache in
.bazelrc(Task 1) + CI cache (Task 10). ✓Coarse Vite leaf → Task 4. ✓
Build depth to deploy → Task 9
make prod. ✓Bootstrap/self-install → Tasks 8–9. ✓
Go source of truth; JS server/* excluded → Task 4 split; no server/* targets. ✓
Image naming/Helm conventions → Task 9 matches
deploy-go.sh. ✓Special bases (chromium/git) → Task 7. ✓
Known environment limits (verify-where-possible): live helm upgrade (Task 9) and registry push/CI run (Tasks 7,10) need a cluster/registry/CI not present locally; those steps are config-complete and verified by helm template / YAML lint / local image load instead.
Type/label consistency: go_binary targets renamed to <svc>_bin (Tasks 6–7) so go_service_image(name="<svc>") can own the <svc> namespace; macro emits <svc>_image/_load/_push; Makefile calls <svc>_load/<svc>_push. Consistent across Tasks 5,6,7,9.