CI workflow (livebud/bud)
The CI workflow from livebud/bud, explained and optimized by Latchkey.
CI health: C - fair
Run this on Latchkey for self-healing, caching, and up to 58% lower cost.
Grade your own workflow free or run it on Latchkey →What it does
This is the CI workflow from the livebud/bud repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
name: 'Test'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ 'ubuntu-latest', 'macos-latest' ]
go: [ '1.17', '1.18', '1.19', '1.20' ]
node: [ '16' ]
include:
- os: ubuntu-latest
go: '1.18'
node: 18
- os: macos-latest
go: '1.18'
node: 18
- os: macos-latest
go: '1.19'
node: 18
- os: macos-latest
go: '1.20'
node: 18
steps:
- name: Check out bud
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
id: go
with:
go-version: ${{ matrix.go }}
cache: true
cache-dependency-path: go.sum
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: 'npm'
cache-dependency-path: |
livebud/package-lock.json
package-lock.json
- name: Install bud node_modules
run: npm ci
- name: Install livebud node_modules
run: npm ci
working-directory: ./livebud
- name: Install Go modules
run: go mod download
- name: Cached testdir snapshots
uses: actions/cache@v3
with:
path: $TMPDIR/bud/snapshot
key: ${{ runner.os }}
- name: Run Go Format on Go 1.19
if: matrix.go == '1.19'
run: make go.fmt
- name: Run CI (Ubuntu Linux)
if: matrix.os == 'ubuntu-latest'
run: make ci.ubuntu
- name: Run CI (macOS)
if: matrix.os == 'macos-latest'
run: make ci.macos
staticcheck:
name: 'Run staticcheck'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ 'ubuntu-latest', 'macOS-latest' ]
go: [ '1.17', '1.18', '1.19', '1.20' ]
dir: [ 'internal', 'package', 'framework' ]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: WillAbides/setup-go-faster@v1.8.0
with:
go-version: ${{ matrix.go }}
- uses: dominikh/staticcheck-action@v1.3.0
if: contains(fromJSON('["1.19", "1.20"]'), matrix.go)
with:
version: '2023.1'
install-go: false
min-go-version: ${{ matrix.go }}
cache-key: ${{ matrix.go }}
working-directory: ${{ matrix.dir }}
- uses: dominikh/staticcheck-action@v1.3.0
if: contains(fromJSON('["1.17", "1.18"]'), matrix.go)
with:
version: '2022.1'
install-go: false
min-go-version: ${{ matrix.go }}
cache-key: ${{ matrix.go }}
working-directory: ${{ matrix.dir }}
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: CI on: push: branches: [ main ] pull_request: branches: [ main ] concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: test: timeout-minutes: 30 name: 'Test' runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ 'ubuntu-latest', 'macos-latest' ] go: [ '1.17', '1.18', '1.19', '1.20' ] node: [ '16' ] include: - os: ubuntu-latest go: '1.18' node: 18 - os: macos-latest go: '1.18' node: 18 - os: macos-latest go: '1.19' node: 18 - os: macos-latest go: '1.20' node: 18 steps: - name: Check out bud uses: actions/checkout@v3 - name: Set up Go uses: actions/setup-go@v3 id: go with: go-version: ${{ matrix.go }} cache: true cache-dependency-path: go.sum - name: Setup Node.js uses: actions/setup-node@v3 with: node-version: ${{ matrix.node }} cache: 'npm' cache-dependency-path: | livebud/package-lock.json package-lock.json - name: Install bud node_modules run: npm ci - name: Install livebud node_modules run: npm ci working-directory: ./livebud - name: Install Go modules run: go mod download - name: Cached testdir snapshots uses: actions/cache@v3 with: path: $TMPDIR/bud/snapshot key: ${{ runner.os }} - name: Run Go Format on Go 1.19 if: matrix.go == '1.19' run: make go.fmt - name: Run CI (Ubuntu Linux) if: matrix.os == 'ubuntu-latest' run: make ci.ubuntu - name: Run CI (macOS) if: matrix.os == 'macos-latest' run: make ci.macos staticcheck: timeout-minutes: 30 name: 'Run staticcheck' runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ 'ubuntu-latest', 'macOS-latest' ] go: [ '1.17', '1.18', '1.19', '1.20' ] dir: [ 'internal', 'package', 'framework' ] steps: - uses: actions/checkout@v3 with: fetch-depth: 1 - uses: WillAbides/setup-go-faster@v1.8.0 with: go-version: ${{ matrix.go }} - uses: dominikh/staticcheck-action@v1.3.0 if: contains(fromJSON('["1.19", "1.20"]'), matrix.go) with: version: '2023.1' install-go: false min-go-version: ${{ matrix.go }} cache-key: ${{ matrix.go }} working-directory: ${{ matrix.dir }} - uses: dominikh/staticcheck-action@v1.3.0 if: contains(fromJSON('["1.17", "1.18"]'), matrix.go) with: version: '2022.1' install-go: false min-go-version: ${{ matrix.go }} cache-key: ${{ matrix.go }} working-directory: ${{ matrix.dir }}
What changed
- Cancel superseded runs when a branch or PR gets a newer push.
- Add a job timeout so a hung step cannot burn hours of runner time.
2 third-party actions are referenced by a movable tag. Pin them to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.
What Latchkey heals here
This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:
- Dependency installs
This workflow runs 2 jobs (32 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.