From b4a6ac59f1bba09548642fa3dd4cf1b307df963c Mon Sep 17 00:00:00 2001 From: Tomasz Janiszewski Date: Fri, 3 Apr 2026 10:24:10 +0200 Subject: [PATCH] chore(ci): skip CLI build on pull requests to reduce build time User request: Speed up build.yaml by skipping CLI builds on PRs. Problem: The pre-build-cli job compiles roxctl and roxagent for 11 platform/architecture combinations, taking 5-10 minutes per PR build. These binaries are rarely needed for PR testing. Solution: Always create stub text files (fast ~2s), then conditionally build real CLI binaries that overwrite stubs. Go cache is skipped when CLI won't be built. This preserves artifact structure without requiring Dockerfile or Makefile changes. Stub creation is unconditional (fast) for simplicity. Build CLI step overwrites stubs when needed. Build conditions (CLI compilation runs when): - GOTAGS=release: Tagged releases - master branch: Nightly builds - workflow_call: Release-ci.yaml calls - ci-build-cli label: Developer explicitly requests Impact: - PRs without label: ~5-10 min savings (stubs used, cache skipped) - Master/releases: No change (real binaries built) - Developers needing CLI: Add ci-build-cli label to PR Co-Authored-By: Claude Sonnet 4.5 --- .github/workflows/build.yaml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a7ae4388c4e1d..5e0937227ccaf 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -194,10 +194,45 @@ jobs: with: gcp-account: ${{ secrets.GCP_SERVICE_ACCOUNT_STACKROX_CI }} + - name: Create CLI stub files + run: | + cat > stub.txt << 'EOF' + This is a placeholder file. CLI binaries were not built for this PR build. + + To build CLI binaries in PR builds: + - Add the "ci-build-cli" label to your pull request + - Re-push to trigger a new build + + To download the latest roxctl binary: + - Visit https://mirror.openshift.com/pub/rhacs/assets/latest/bin/ + + EOF + + mkdir -p bin/{linux_{amd64,arm64,ppc64le,s390x},darwin_{amd64,arm64},windows_amd64} + + for arch in linux_amd64 linux_arm64 linux_ppc64le linux_s390x darwin_amd64 darwin_arm64; do + cp stub.txt bin/${arch}/roxctl + cp stub.txt bin/${arch}/roxagent + done + cp stub.txt bin/windows_amd64/roxctl.exe + + - name: PR labels + uses: joerick/pr-labels-action@v1.0.9 + - name: Cache Go dependencies + if: | + needs.define-job-matrix.outputs.gotags == 'release' + || github.ref_name == 'master' + || github.event_name == 'workflow_call' + || contains(github.event.pull_request.labels.*.name, 'ci-build-cli') uses: ./.github/actions/cache-go-dependencies - name: Build CLI + if: | + needs.define-job-matrix.outputs.gotags == 'release' + || github.ref_name == 'master' + || github.event_name == 'workflow_call' + || contains(github.event.pull_request.labels.*.name, 'ci-build-cli') run: make cli - name: Bundle build to preserve permissions