NATS Server Code Coverage workflow (nats-io/nats-server)
The NATS Server Code Coverage workflow from nats-io/nats-server, explained and optimized by Latchkey.
A
CI health: A - excellent
Point runs-on at Latchkey and get job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the NATS Server Code Coverage workflow from the nats-io/nats-server 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: NATS Server Code Coverage
on:
workflow_dispatch: {}
schedule:
- cron: "40 4 * * *"
permissions:
contents: read
jobs:
nightly_coverage:
runs-on: ubuntu-latest
env:
GOPATH: /home/runner/work/nats-server
GO111MODULE: "on"
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
path: src/github.com/nats-io/nats-server
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: stable
cache-dependency-path: src/github.com/nats-io/nats-server/go.sum
- name: Run code coverage
shell: bash --noprofile --norc -x -eo pipefail {0}
run: |
set -e
cd src/github.com/nats-io/nats-server
./scripts/cov.sh upload
set +e
- name: Convert coverage.out to coverage.lcov
# Use commit hash here to avoid a re-tagging attack, as this is a third-party action
# Commit e4612787670fc5b5f49026b8c29c5569921de1db = tag v1.2.0
uses: jandelgado/gcov2lcov-action@e4612787670fc5b5f49026b8c29c5569921de1db
with:
infile: acc.out
working-directory: src/github.com/nats-io/nats-server
- name: Coveralls
# Use commit hash here to avoid a re-tagging attack, as this is a third-party action
# Commit 5cbfd81b66ca5d10c19b062c04de0199c215fb6e = tag v2.3.7
uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e
with:
github-token: ${{ secrets.github_token }}
file: src/github.com/nats-io/nats-server/coverage.lcov
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: NATS Server Code Coverage on: workflow_dispatch: {} schedule: - cron: "40 4 * * *" permissions: contents: read jobs: nightly_coverage: timeout-minutes: 30 runs-on: latchkey-small env: GOPATH: /home/runner/work/nats-server GO111MODULE: "on" steps: - name: Checkout code uses: actions/checkout@v6 with: path: src/github.com/nats-io/nats-server - name: Set up Go uses: actions/setup-go@v6 with: go-version: stable cache-dependency-path: src/github.com/nats-io/nats-server/go.sum - name: Run code coverage shell: bash --noprofile --norc -x -eo pipefail {0} run: | set -e cd src/github.com/nats-io/nats-server ./scripts/cov.sh upload set +e - name: Convert coverage.out to coverage.lcov # Use commit hash here to avoid a re-tagging attack, as this is a third-party action # Commit e4612787670fc5b5f49026b8c29c5569921de1db = tag v1.2.0 uses: jandelgado/gcov2lcov-action@e4612787670fc5b5f49026b8c29c5569921de1db with: infile: acc.out working-directory: src/github.com/nats-io/nats-server - name: Coveralls # Use commit hash here to avoid a re-tagging attack, as this is a third-party action # Commit 5cbfd81b66ca5d10c19b062c04de0199c215fb6e = tag v2.3.7 uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e with: github-token: ${{ secrets.github_token }} file: src/github.com/nats-io/nats-server/coverage.lcov
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. - Add a job timeout so a hung step cannot burn hours of runner time.
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.