ci workflow (nutsdb/nutsdb)
The ci workflow from nutsdb/nutsdb, explained and optimized by Latchkey.
C
CI health: C - fair
Point runs-on at Latchkey and get run de-duplication, job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the ci workflow from the nutsdb/nutsdb repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
workflow (.yml)
name: ci
on:
pull_request:
push:
branches:
- master
workflow_dispatch:
jobs:
unit-test-linux:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.24.x'
- name: Cache Go modules
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Clean test directories
run: |
sudo rm -rf /tmp/nutsdb* || true
sudo rm -rf /tmp/test-hintfile* || true
- name: Build project
run: go build -v ./...
- name: Run unit tests with timeout and retries
run: |
# Set test timeout and retry logic for flaky tests
for i in {1..3}; do
echo "Test attempt $i/3"
if timeout 20m go test -v -race -timeout 15m ./...; then
echo "Tests passed on attempt $i"
break
elif [ $i -eq 3 ]; then
echo "Tests failed after 3 attempts"
exit 1
else
echo "Tests failed on attempt $i, retrying..."
sleep 5
# Clean any remaining test files
sudo rm -rf /tmp/nutsdb* || true
sudo rm -rf /tmp/test-hintfile* || true
fi
done
unit-test-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24.x'
- name: Test
run: go test -v -race -timeout 30m ./...
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: ci on: pull_request: push: branches: - master workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: unit-test-linux: runs-on: latchkey-small timeout-minutes: 30 steps: - uses: actions/checkout@v3 - name: Set up Go uses: actions/setup-go@v4 with: go-version: '1.24.x' - name: Cache Go modules uses: actions/cache@v3 with: path: | ~/.cache/go-build ~/go/pkg/mod key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go- - name: Clean test directories run: | sudo rm -rf /tmp/nutsdb* || true sudo rm -rf /tmp/test-hintfile* || true - name: Build project run: go build -v ./... - name: Run unit tests with timeout and retries run: | # Set test timeout and retry logic for flaky tests for i in {1..3}; do echo "Test attempt $i/3" if timeout 20m go test -v -race -timeout 15m ./...; then echo "Tests passed on attempt $i" break elif [ $i -eq 3 ]; then echo "Tests failed after 3 attempts" exit 1 else echo "Tests failed on attempt $i, retrying..." sleep 5 # Clean any remaining test files sudo rm -rf /tmp/nutsdb* || true sudo rm -rf /tmp/test-hintfile* || true fi done unit-test-windows: timeout-minutes: 30 runs-on: windows-latest steps: - uses: actions/checkout@v4 - name: set up Go uses: actions/setup-go@v5 with: go-version: '1.24.x' - name: Test run: go test -v -race -timeout 30m ./...
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.
This workflow runs 2 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.