CI workflow (rogchap/v8go)
The CI workflow from rogchap/v8go, 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 rogchap/v8go repository, a real project running GitHub Actions. It is shown here with attribution under its BSD-3-Clause license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: CI
on:
push:
branches:
- master
pull_request:
workflow_dispatch:
jobs:
test:
name: Tests on ${{ matrix.go-version }} ${{ matrix.platform }}
strategy:
matrix:
go-version: [1.18.10, 1.19.5]
platform: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout
uses: actions/checkout@v2
- name: Go Test
env:
CGO_CXXFLAGS: "-Werror"
run: go test -v -coverprofile c.out ./...
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
env:
OS: ${{ matrix.platform }}
GO: ${{ matrix.go-version }}
with:
files: ./c.out
env_vars: OS,GO
- name: Add GOPATH to GITHUB_ENV
run: echo "GOPATH=$(go env GOPATH)" >>"$GITHUB_ENV"
- name: Scan and upload FOSSA data (Linux/Mac)
if: env.FOSSA_API_KEY != '' && github.ref == 'refs/heads/master'
run: |
curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install.sh | sudo bash
fossa analyze
env:
FOSSA_API_KEY: ${{ secrets.FOSSA_API_KEY }}
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: CI on: push: branches: - master pull_request: workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: test: timeout-minutes: 30 name: Tests on ${{ matrix.go-version }} ${{ matrix.platform }} strategy: matrix: go-version: [1.18.10, 1.19.5] platform: [ubuntu-latest, macos-latest] runs-on: ${{ matrix.platform }} steps: - name: Install Go uses: actions/setup-go@v2 with: go-version: ${{ matrix.go-version }} - name: Checkout uses: actions/checkout@v2 - name: Go Test env: CGO_CXXFLAGS: "-Werror" run: go test -v -coverprofile c.out ./... - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 env: OS: ${{ matrix.platform }} GO: ${{ matrix.go-version }} with: files: ./c.out env_vars: OS,GO - name: Add GOPATH to GITHUB_ENV run: echo "GOPATH=$(go env GOPATH)" >>"$GITHUB_ENV" - name: Scan and upload FOSSA data (Linux/Mac) if: env.FOSSA_API_KEY != '' && github.ref == 'refs/heads/master' run: | curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install.sh | sudo bash fossa analyze env: FOSSA_API_KEY: ${{ secrets.FOSSA_API_KEY }}
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.
1 third-party action is referenced by a movable tag. Pin it 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:
- Network fetches
This workflow runs 1 job (4 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.