From 0fac3b5c81216f5d063c0b03395d17f99bced3a7 Mon Sep 17 00:00:00 2001 From: Brian Love Date: Wed, 27 May 2026 21:18:37 -0700 Subject: [PATCH] ci(perf): cockpit-examples-build only builds affected caps on PR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `cockpit-examples-build` ran `nx run-many --projects='cockpit-*-angular'` on every PR — building all 32 cockpit angular projects (~5m28s) regardless of what changed. Now: - PR: build only the cockpit-*-angular projects nx considers affected (base..head). A 1-cap PR builds 1 cap; a libs/chat fanout builds all. Empty affected set → fast no-op. - push to main: unchanged full build of all 32 (pre-deploy safety net). This is a production `nx build`, distinct from cockpit-e2e's `nx serve` (dev-server) — not redundant, so the job stays; it just scopes its work. Adds fetch-depth: 0 to checkout (required for nx affected base..head). --- .github/workflows/ci.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2602a928..26dcb938 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -153,12 +153,29 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6.0.2 + with: + fetch-depth: 0 - uses: actions/setup-node@v6.3.0 with: node-version: 22 cache: npm - run: npm ci - - run: npx nx run-many -t build --projects='cockpit-*-angular' --skip-nx-cache + - name: Build cockpit examples (affected on PR, all on push) + run: | + if [ "${{ github.event_name }}" = "push" ]; then + npx nx run-many -t build --projects='cockpit-*-angular' --skip-nx-cache + else + BASE="${{ github.event.pull_request.base.sha }}" + HEAD="${{ github.event.pull_request.head.sha }}" + AFFECTED=$(npx nx show projects --affected --base="$BASE" --head="$HEAD" \ + | grep -E '^cockpit-.*-angular$' | paste -sd, - || true) + if [ -z "$AFFECTED" ]; then + echo "No affected cockpit angular projects; nothing to build." + else + echo "Building affected: $AFFECTED" + npx nx run-many -t build --projects="$AFFECTED" --skip-nx-cache + fi + fi cockpit-smoke: name: Cockpit — representative capability smoke