Run build, tests, and static checks in CI for PRs - #170
Conversation
Adds .github/workflows/ci.yml, triggered on pull_request into main, that runs the build, tests, and static checks for both toolchains in the monorepo. Resolves #151. Three parallel jobs, one per toolchain, so a failure names the thing that broke and they run concurrently: - node: npm ci, then the root workspace fan-out scripts (build / typecheck / test) across every Node workspace. - go (matrix): the two dependency-free Go modules (sidecars/localtool-executor, tools-local/http-get-go) -- gofmt check, go build, go vet, go test. - core-controller: reuses the kubebuilder Makefile targets (make lint / test / build) so CI runs exactly what developers run locally; lint is golangci-lint (static analysis + gofmt/goimports) and test is the envtest-backed suite. All jobs run on GitHub-hosted ubuntu-latest runners -- never the self-hosted arc-runner-set used by release.yml -- since PRs (forks included) are untrusted, matching the existing validate-crds.yml. Runs are skipped only for pure-Markdown PRs (paths-ignore), and concurrency cancels superseded runs on the same PR branch. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012e6RfDGj5Xr9xhwHn33pRh
|
🤖 Starting work on this now. Watch live or take over the session here: https://claude.ai/code/session_01Ev6J4rJzJ1ghKd5nxqFAkm |
| # Workspace fan-out scripts (see root package.json): each runs the | ||
| # matching script in every workspace that defines it. | ||
| - name: Build | ||
| run: npm run build |
There was a problem hiding this comment.
Blocking: this Build step fails on a clean checkout. npm run build --workspaces --if-present runs workspaces in discovery order, not topological order. packages/agent-runtime builds before packages/messaging, but it depends on @controller-agent/messaging whose types resolve to dist/index.d.ts — which doesn't exist yet on a fresh checkout (no tsconfig project references to build it on demand). Result: Cannot find module '@controller-agent/messaging' (see run #30285125563). The description's "Node … all green" only held locally because a stale dist/ was present. Fix in the root build script — build leaf packages first (topo order / tsc references / a -w @controller-agent/messaging prestep) — before this check can pass.
| # server test binaries via setup-envtest). | ||
| # `make build` -> compiles the manager binary. | ||
| - name: Lint | ||
| run: make lint |
There was a problem hiding this comment.
Blocking: make lint fails on pre-existing code. This runs the full .golangci.yml including the logcheck custom linter, which the current tree doesn't satisfy (multiple "accept either a context or a logger, but not both" violations in run #30285125563). The PR honestly notes make lint/make test weren't run locally. Because lint is the first step, test and build never run. Either fix the violations or narrow the linter set before this becomes a required check, otherwise the job is red on arrival.
| jobs: | ||
| node: | ||
| name: Node (build, typecheck, test) | ||
| runs-on: ubuntu-latest |
There was a problem hiding this comment.
Correct call using ubuntu-latest here — verified release.yml runs on the self-hosted arc-runner-set-agent-controller (lines 172/273), so keeping untrusted PR content off that infra (as validate-crds.yml already documents) is the right security posture. contents: read + pull_request (not pull_request_target) reinforce it.
| # Skip pure-docs PRs: `paths-ignore` only skips a run when EVERY changed | ||
| # file matches, so a PR that touches both Markdown and code still runs. | ||
| paths-ignore: | ||
| - "**/*.md" |
There was a problem hiding this comment.
paths-ignore: "**/*.md" semantics are correct (skips only when every changed file matches). One risk if these jobs become required status checks: a docs-only PR skips the whole workflow, the required contexts never report, and the PR hangs on "Expected — Waiting for status." If you intend them required, add a companion always-runs gate job (or make them required-if-run).
Review — Add PR CI (
|
|
Review posted. Here's my summary. What I didReviewed PR #170 — "Run build, tests, and static checks in CI for PRs" (adds Key findingsThe workflow's structure and security posture are sound, but its own first run (#30285125563) is red on 2 of 4 jobs — the CI correctly surfaces two pre-existing problems, but they block it from going green:
I verified and cre… ✅ Opened pull request: imaustink/agent-controller#170 |
|
|
Closes #151.
What
Adds
.github/workflows/ci.yml— a CI pipeline that runs the build, tests, and static checks for every pull request intomain. Until now there was no PR-time CI;release.ymlonly runs on push tomain, andvalidate-crds.ymlonly covers CRD samples.How it works
Three parallel jobs, one per toolchain in the monorepo, so a failure names the thing that broke instead of one opaque red X:
packages/*,apps/*,tools/*,tools-local/http-get-node,e2e)npm ci→npm run build→npm run typecheck→npm run test(the root workspace fan-out scripts)sidecars/localtool-executor,tools-local/http-get-gogofmt -lcheck →go build ./...→go vet ./...→go test ./...controllers/core-controller(kubebuilder)make lint(golangci-lint: static analysis + gofmt/goimports) →make test(envtest-backed suite) →make buildThe
core-controllerjob reuses the project's existing Makefile targets so CI runs exactly what a developer runs locally, rather than a second, drifting definition of "the checks". Each target self-installs its pinned tool (golangci-lint, controller-gen, setup-envtest) on first use.Design notes
ubuntu-latest— never the self-hostedarc-runner-set-agent-controllerused byrelease.yml— because PRs (fork PRs included) are untrusted content that must not reach the internal cluster/registry. This mirrors the same rationale already documented invalidate-crds.yml.contents: readonly.paths-ignore: "**/*.md"skips pure-docs PRs. Becausepaths-ignoreonly skips when every changed file matches, a PR touching both Markdown and code still runs.Verification
Ran the pipeline's commands locally against this branch's tree:
npm ci+build+typecheck+test— all green (19 tests across the workspaces that define them).sidecars/localtool-executorandtools-local/http-get-go:gofmtclean,go build,go vet,go test— all green.controllers/core-controller:go build ./...andgo vet ./...green under Go 1.25.7;gofmtclean. (The fullmake test/make lint— which download envtest binaries and the custom golangci-lint — are exercised by this PR's own CI run.)Opening this PR triggers the new workflow, so its own checks are the first live run.
Maintainers: apply the ai-review label to this PR to request an automated code review, or the ai-triage label to have review feedback addressed and the branch brought back in sync with its base. (The automation can't apply either label to its own PR, so a human needs to.)