Skip to content

ci: redesign CI to scope builds/tests/images to changed modules - #626

Open
BjoernKarma wants to merge 2 commits into
mainfrom
ci/redesign
Open

ci: redesign CI to scope builds/tests/images to changed modules#626
BjoernKarma wants to merge 2 commits into
mainfrom
ci/redesign

Conversation

@BjoernKarma

Copy link
Copy Markdown
Contributor

Splits the monolithic per-module reusable workflow into two composable reusable components and adds module-scoped execution to cut CI compute as the monorepo has grown to 20+ modules:

  • .github/ci/modules.yaml: single source of truth for per-module CI config, replacing hardcoded per-module blocks in ci.yaml.
  • .github/ci/module-graph.json + hack/ci/gen-module-graph.sh: dependency graph derived from go.mod replace directives, enabling an "optimized" mode that also runs dependent modules. make ci-graph regenerates it, make ci-graph-check (wired into hack/verify.sh and CI) fails on drift.
  • hack/ci/select-scope.sh: computes run mode (maximum/minimum/optimized/ none) and resulting build/package module lists, with a global-impact safety valve forcing maximum mode for shared tooling/config changes.
  • build-component.yaml / package-component.yaml: reusable workflows replacing reusable-go-ci.yaml, split into build (lint/test/coverage/ govulncheck) and package (ko build/trivy) concerns.
  • codeql.yaml: single repo-wide CodeQL analysis replacing per-module jobs.
  • ci.yaml: rewritten orchestrator: determine-scope -> build (matrix) ->
    collect_build_status (artifact fan-in) -> package (matrix, filtered) -> ci_summary. Mode: pull_request->optimized, workflow_dispatch->choice, tag push->none, main push/schedule->maximum.
  • workflows.md updated to document the new pipeline.

Preserves existing tag-push behavior (near no-op, Helm publish only) per team decision, and fixes the nightly schedule (previously ran almost nothing due to a stale condition) to run full maximum-mode verification.

Splits the monolithic per-module reusable workflow into two composable
reusable components and adds module-scoped execution to cut CI compute
as the monorepo has grown to 20+ modules:

- .github/ci/modules.yaml: single source of truth for per-module CI
  config, replacing hardcoded per-module blocks in ci.yaml.
- .github/ci/module-graph.json + hack/ci/gen-module-graph.sh: dependency
  graph derived from go.mod replace directives, enabling an "optimized"
  mode that also runs dependent modules. make ci-graph regenerates it,
  make ci-graph-check (wired into hack/verify.sh and CI) fails on drift.
- hack/ci/select-scope.sh: computes run mode (maximum/minimum/optimized/
  none) and resulting build/package module lists, with a global-impact
  safety valve forcing maximum mode for shared tooling/config changes.
- build-component.yaml / package-component.yaml: reusable workflows
  replacing reusable-go-ci.yaml, split into build (lint/test/coverage/
  govulncheck) and package (ko build/trivy) concerns.
- codeql.yaml: single repo-wide CodeQL analysis replacing per-module jobs.
- ci.yaml: rewritten orchestrator: determine-scope -> build (matrix) ->
  collect_build_status (artifact fan-in) -> package (matrix, filtered) ->
  ci_summary. Mode: pull_request->optimized, workflow_dispatch->choice,
  tag push->none, main push/schedule->maximum.
- workflows.md updated to document the new pipeline.

Preserves existing tag-push behavior (near no-op, Helm publish only) per
team decision, and fixes the nightly schedule (previously ran almost
nothing due to a stale condition) to run full maximum-mode verification.
Copilot AI lite review requested due to automatic review settings August 25, 2026 12:55
@BjoernKarma BjoernKarma added the github_actions Pull requests that update GitHub Actions code label Aug 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Redesigns the monorepo GitHub Actions CI to dynamically scope build/test/package work to the set of changed modules (and optionally their dependents), using a module config file plus a generated cross-module dependency graph to reduce CI compute as the repo grows.

Changes:

  • Introduces module-scoped CI orchestration in ci.yaml driven by .github/ci/modules.yaml and .github/ci/module-graph.json, computed via .github/scripts/select-scope.sh.
  • Splits the previous reusable per-module CI workflow into two reusable components: build (lint/tests/govulncheck + status marker) and package (ko build + trivy).
  • Adds repo-wide CodeQL workflow and documentation updates, plus make/verify targets to regenerate/check the module graph.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
REUSE.toml Adds REUSE annotation for generated module-graph.json.
Makefile Adds ci-graph / ci-graph-check targets for graph regeneration and drift checks.
hack/verify.sh Enforces make ci-graph-check as part of repo-level verification.
.github/workflows/reusable-go-ci.yaml Removes the previous monolithic reusable per-module CI workflow.
.github/workflows/component-build.yaml New reusable build workflow (lint/tests/coverage/govulncheck + per-module status marker artifact).
.github/workflows/component-package-build.yaml New reusable packaging workflow (ko image build + trivy scan).
.github/workflows/codeql.yaml Adds repo-wide CodeQL analysis workflow building all configured modules.
.github/workflows/ci.yaml Rewrites CI orchestrator to determine scope → build matrix → fan-in status → package matrix → summary, plus existing rover-ctl and helm jobs.
.github/workflows.md Updates workflow documentation to describe the new scoped pipeline and CodeQL strategy.
.github/scripts/select-scope.sh New scoping script computing build/package module lists from mode + changed files + module graph.
.github/scripts/gen-module-graph.sh New generator for module-graph.json derived from go.mod replace directives.
.github/ci/modules.yaml New single source of truth for per-module CI configuration.
.github/ci/module-graph.json New committed generated dependency graph used for optimized scoping.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/workflows/codeql.yaml Outdated
Comment on lines +64 to +68
modules=$(yq -o=json '.modules[].path' .github/ci/modules.yaml | jq -r .)
while IFS= read -r module; do
[ -z "$module" ] && continue
echo "Building $module for CodeQL..."
(cd "$module" && go build ./...)
Comment thread .github/workflows/ci.yaml
Comment on lines +119 to +127
check-module-graph:
name: Check Module Dependency Graph
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Verify .github/ci/module-graph.json is up to date
# yq and jq are preinstalled on GitHub-hosted ubuntu runners.
run: make ci-graph-check
Comment on lines +76 to +80
if [ -n "$dep_name" ] && [ "$dep_name" != "$name" ]; then
deps+=("$dep_name")
fi
done < <(grep -oP "$GO_MODULE_PREFIX/\S+\s*=>\s*\K\.\.?/\S+" "$gomod" || true)
fi
Comment thread .github/workflows.md Outdated
Comment on lines +39 to +50
- `push` of a version tag (`v*`) → **none**: tags are created by the
separately, manually-triggered `release.yaml` workflow, which already
builds/tests/publishes everything via goreleaser+ko; re-running the
same work here would just duplicate it.
- `workflow_dispatch` → user-selectable mode (`maximum` by default).
- Regardless of mode, any change to shared tooling (`Makefile`,
`.golangci.yml`, `.ko.yaml`, `hack/**`, `.github/workflows/**`,
`.github/scripts/**`, `.github/ci/**`) forces **maximum**, since a
path-based diff can't safely reason about the blast radius of a
tooling change.
2. **Check Module Dependency Graph** - fails if `.github/ci/module-graph.json`
is stale relative to the modules' `go.mod` files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

github_actions Pull requests that update GitHub Actions code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants