[object Object]

← back to Cli Printing Press

ci(ci): improve workflow coverage and guards (#346)

4c64ffe6666b421bdfec40d02c4f40aa5bdf7f6f · 2026-04-27 11:08:39 -0700 · Trevin Chow

* ci(ci): improve workflow coverage and guards

* ci(ci): key Go cache from module sums

Files touched

Diff

commit 4c64ffe6666b421bdfec40d02c4f40aa5bdf7f6f
Author: Trevin Chow <trevin@trevinchow.com>
Date:   Mon Apr 27 11:08:39 2026 -0700

    ci(ci): improve workflow coverage and guards (#346)
    
    * ci(ci): improve workflow coverage and guards
    
    * ci(ci): key Go cache from module sums
---
 .github/workflows/golden.yml           |  6 ++++++
 .github/workflows/lint.yml             | 23 ++++++++++++++++++++++-
 .github/workflows/pr-title.yml         |  5 +++++
 .github/workflows/release.yml          |  7 +++++++
 .github/workflows/validate-catalog.yml | 18 ++++++++++++++----
 5 files changed, 54 insertions(+), 5 deletions(-)

diff --git a/.github/workflows/golden.yml b/.github/workflows/golden.yml
index 785e5195..4669d1e1 100644
--- a/.github/workflows/golden.yml
+++ b/.github/workflows/golden.yml
@@ -3,12 +3,17 @@ name: Golden
 on:
   pull_request:
 
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: true
+
 permissions:
   contents: read
 
 jobs:
   golden:
     runs-on: ubuntu-latest
+    timeout-minutes: 15
     steps:
       - uses: actions/checkout@v6
 
@@ -16,6 +21,7 @@ jobs:
         with:
           go-version-file: go.mod
           cache: true
+          cache-dependency-path: go.sum
 
       - name: Verify golden outputs
         run: scripts/golden.sh verify
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index cc85a205..5cfebac4 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -3,12 +3,17 @@ name: Lint
 on:
   pull_request:
 
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: true
+
 permissions:
   contents: read
 
 jobs:
   lint:
     runs-on: ubuntu-latest
+    timeout-minutes: 15
     steps:
       - uses: actions/checkout@v6
 
@@ -16,7 +21,23 @@ jobs:
         with:
           go-version-file: go.mod
           cache: true
+          cache-dependency-path: go.sum
 
       - uses: golangci/golangci-lint-action@v9
         with:
-          version: latest
+          version: v2.11.4
+
+  test:
+    runs-on: ubuntu-latest
+    timeout-minutes: 15
+    steps:
+      - uses: actions/checkout@v6
+
+      - uses: actions/setup-go@v6
+        with:
+          go-version-file: go.mod
+          cache: true
+          cache-dependency-path: go.sum
+
+      - name: Run Go tests
+        run: go test ./...
diff --git a/.github/workflows/pr-title.yml b/.github/workflows/pr-title.yml
index c8e26dab..b84337b6 100644
--- a/.github/workflows/pr-title.yml
+++ b/.github/workflows/pr-title.yml
@@ -4,12 +4,17 @@ on:
   pull_request:
     types: [opened, edited, synchronize, reopened]
 
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: true
+
 permissions:
   pull-requests: read
 
 jobs:
   lint:
     runs-on: ubuntu-latest
+    timeout-minutes: 5
     steps:
       - uses: amannn/action-semantic-pull-request@v6
         with:
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index c3d1e693..b8f27c42 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -5,6 +5,10 @@ on:
     branches:
       - main
 
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: false
+
 permissions:
   contents: write
   issues: write
@@ -13,6 +17,7 @@ permissions:
 jobs:
   release-please:
     runs-on: ubuntu-latest
+    timeout-minutes: 10
     outputs:
       release_created: ${{ steps.release.outputs.release_created }}
       tag_name: ${{ steps.release.outputs.tag_name }}
@@ -24,6 +29,7 @@ jobs:
     needs: release-please
     if: ${{ needs.release-please.outputs.release_created }}
     runs-on: ubuntu-latest
+    timeout-minutes: 30
     permissions:
       contents: write
     steps:
@@ -35,6 +41,7 @@ jobs:
         with:
           go-version-file: go.mod
           cache: true
+          cache-dependency-path: go.sum
 
       - uses: goreleaser/goreleaser-action@v7
         with:
diff --git a/.github/workflows/validate-catalog.yml b/.github/workflows/validate-catalog.yml
index f73326f4..ae9ab8db 100644
--- a/.github/workflows/validate-catalog.yml
+++ b/.github/workflows/validate-catalog.yml
@@ -5,9 +5,17 @@ on:
     paths:
       - 'catalog/**'
 
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: true
+
+permissions:
+  contents: read
+
 jobs:
   validate:
     runs-on: ubuntu-latest
+    timeout-minutes: 20
     steps:
       - uses: actions/checkout@v6
         with:
@@ -17,6 +25,7 @@ jobs:
         with:
           go-version-file: go.mod
           cache: true
+          cache-dependency-path: go.sum
 
       - name: Build printing-press
         run: go build -o ./printing-press ./cmd/printing-press
@@ -35,7 +44,7 @@ jobs:
 
           mapfile -t CHANGED < <(git diff --name-only --diff-filter=ACMR "origin/${{ github.base_ref }}...HEAD" -- 'catalog/*.yaml')
 
-          if [ ${#CHANGED[@]} -eq 0 ]; then
+          if [ "${#CHANGED[@]}" -eq 0 ]; then
             echo "FAIL: workflow triggered on catalog/** changes but git diff found no changed catalog/*.yaml files."
             echo "This usually means the base ref was not fetched. Check actions/checkout fetch-depth."
             exit 1
@@ -63,7 +72,7 @@ jobs:
               exit 1
             fi
 
-            SPEC_FILE=/tmp/spec-validate.yaml
+            SPEC_FILE="$(mktemp "${RUNNER_TEMP:-/tmp}/spec-validate.XXXXXX.yaml")"
             RAW_PREFIX="https://raw.githubusercontent.com/mvanhorn/cli-printing-press/main/"
             if [[ "$SPEC_URL" == "$RAW_PREFIX"* ]]; then
               LOCAL_SPEC="${SPEC_URL#"$RAW_PREFIX"}"
@@ -87,12 +96,13 @@ jobs:
 
             # Generate from the resolved spec.
             NAME=$(grep '^name:' "$file" | head -1 | sed 's/name: *//')
+            OUT_DIR="${RUNNER_TEMP:-/tmp}/${NAME}-cli"
 
             ./printing-press generate \
               --spec "$SPEC_FILE" \
-              --output /tmp/${NAME}-cli \
+              --output "$OUT_DIR" \
               --validate
 
             echo "PASS: Generated CLI compiles"
-            rm -rf /tmp/${NAME}-cli "$SPEC_FILE"
+            rm -rf "$OUT_DIR" "$SPEC_FILE"
           done

← 8617e06d test(cli): add golden coverage for generated artifacts (#345  ·  back to Cli Printing Press  ·  ci(ci): guard low-risk checks and setup docs (#347) 3f7410de →