Tests workflow (mergestat/mergestat-lite)
The Tests workflow from mergestat/mergestat-lite, explained and optimized by Latchkey.
CI health: C - fair
Point runs-on at Latchkey and get run de-duplication, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Tests workflow from the mergestat/mergestat-lite 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: Tests
on: [push, pull_request]
jobs:
build:
name: Build for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
asset_name: mergestat-linux-amd64
- os: macos-latest
asset_name: mergestat-macos-amd64
steps:
- name: Set up Go 1.19
uses: actions/setup-go@v5
with:
go-version: 1.19.4
id: go
- name: Check out source
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install libgit2
run: make libgit2
- name: Vet
run: make vet
- name: Lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.50.0
make lint-ci
- name: Test
run: make test-cover
- name: Upload coverage
uses: codecov/codecov-action@v4
# TODO(patrickdevivo)
# lint:
# name: Lint
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - name: Install libgit2
# run: |
# git clone https://github.com/libgit2/libgit2.git ~/libgit2
# cd ~/libgit2
# git checkout v1.1.0
# mkdir build && cd build
# sudo cmake .. -DBUILD_CLAR=0
# sudo cmake --build . --target install
# - name: golangci-lint
# uses: golangci/golangci-lint-action@v2
# with:
# version: v1.29
# args: --build-tags sqlite_vtable,static,system_libgit2
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Tests on: [push, pull_request] concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: build: timeout-minutes: 30 name: Build for ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: matrix: include: - os: ubuntu-latest asset_name: mergestat-linux-amd64 - os: macos-latest asset_name: mergestat-macos-amd64 steps: - name: Set up Go 1.19 uses: actions/setup-go@v5 with: go-version: 1.19.4 id: go - name: Check out source uses: actions/checkout@v4 with: submodules: recursive - name: Install libgit2 run: make libgit2 - name: Vet run: make vet - name: Lint run: | curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.50.0 make lint-ci - name: Test run: make test-cover - name: Upload coverage uses: codecov/codecov-action@v4 # TODO(patrickdevivo) # lint: # name: Lint # runs-on: latchkey-small # steps: # - uses: actions/checkout@v2 # - name: Install libgit2 # run: | # git clone https://github.com/libgit2/libgit2.git ~/libgit2 # cd ~/libgit2 # git checkout v1.1.0 # mkdir build && cd build # sudo cmake .. -DBUILD_CLAR=0 # sudo cmake --build . --target install # - name: golangci-lint # uses: golangci/golangci-lint-action@v2 # with: # version: v1.29 # args: --build-tags sqlite_vtable,static,system_libgit2
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - 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:
- Network fetches
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.