Coveralls Code Coverage workflow (badges/shields)
The Coveralls Code Coverage workflow from badges/shields, explained and optimized by Latchkey.
CI health: B - good
Point runs-on at Latchkey and get job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Coveralls Code Coverage workflow from the badges/shields 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
name: Coveralls Code Coverage
on:
schedule:
- cron: '10 7 * * *'
# At 07:10, daily
workflow_dispatch:
jobs:
coveralls-code-coverage:
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: ci_test
options: >-
--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup
uses: ./.github/actions/setup
env:
NPM_CONFIG_ENGINE_STRICT: 'false'
- name: Migrate DB
run: npm run migrate up
env:
POSTGRES_URL: postgresql://postgres:postgres@localhost:5432/ci_test
shell: bash
- name: Coverage for Main Tests
run: npm run coverage:test
env:
GH_TOKEN: '${{ secrets.GH_PAT }}'
POSTGRES_URL: postgresql://postgres:postgres@localhost:5432/ci_test
shell: bash
- name: Coverage for Service Tests
run: npm run coverage:test:services
continue-on-error: true
env:
RETRY_COUNT: 3
GH_TOKEN: '${{ secrets.GH_PAT }}'
CURSEFORGE_API_KEY: '${{ secrets.SERVICETESTS_CURSEFORGE_API_KEY }}'
LIBRARIESIO_TOKENS: '${{ secrets.SERVICETESTS_LIBRARIESIO_TOKENS }}'
OBS_USER: '${{ secrets.SERVICETESTS_OBS_USER }}'
OBS_PASS: '${{ secrets.SERVICETESTS_OBS_PASS }}'
PEPY_KEY: '${{ secrets.SERVICETESTS_PEPY_KEY }}'
REDDIT_CLIENT_ID: '${{ secrets.SERVICETESTS_REDDIT_CLIENT_ID }}'
REDDIT_CLIENT_SECRET: '${{ secrets.SERVICETESTS_REDDIT_CLIENT_SECRET }}'
SL_INSIGHT_USER_UUID: '${{ secrets.SERVICETESTS_SL_INSIGHT_USER_UUID }}'
SL_INSIGHT_API_TOKEN: '${{ secrets.SERVICETESTS_SL_INSIGHT_API_TOKEN }}'
TWITCH_CLIENT_ID: '${{ secrets.SERVICETESTS_TWITCH_CLIENT_ID }}'
TWITCH_CLIENT_SECRET: '${{ secrets.SERVICETESTS_TWITCH_CLIENT_SECRET }}'
WEBLATE_API_KEY: '${{ secrets.SERVICETESTS_WEBLATE_API_KEY }}'
YOUTUBE_API_KEY: '${{ secrets.SERVICETESTS_YOUTUBE_API_KEY }}'
shell: bash
- name: Coveralls GitHub Action
uses: coverallsapp/github-action@v2
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Coveralls Code Coverage on: schedule: - cron: '10 7 * * *' # At 07:10, daily workflow_dispatch: jobs: coveralls-code-coverage: timeout-minutes: 30 runs-on: latchkey-small services: postgres: image: postgres env: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres POSTGRES_DB: ci_test options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 ports: - 5432:5432 steps: - name: Checkout uses: actions/checkout@v7 - name: Setup uses: ./.github/actions/setup env: NPM_CONFIG_ENGINE_STRICT: 'false' - name: Migrate DB run: npm run migrate up env: POSTGRES_URL: postgresql://postgres:postgres@localhost:5432/ci_test shell: bash - name: Coverage for Main Tests run: npm run coverage:test env: GH_TOKEN: '${{ secrets.GH_PAT }}' POSTGRES_URL: postgresql://postgres:postgres@localhost:5432/ci_test shell: bash - name: Coverage for Service Tests run: npm run coverage:test:services continue-on-error: true env: RETRY_COUNT: 3 GH_TOKEN: '${{ secrets.GH_PAT }}' CURSEFORGE_API_KEY: '${{ secrets.SERVICETESTS_CURSEFORGE_API_KEY }}' LIBRARIESIO_TOKENS: '${{ secrets.SERVICETESTS_LIBRARIESIO_TOKENS }}' OBS_USER: '${{ secrets.SERVICETESTS_OBS_USER }}' OBS_PASS: '${{ secrets.SERVICETESTS_OBS_PASS }}' PEPY_KEY: '${{ secrets.SERVICETESTS_PEPY_KEY }}' REDDIT_CLIENT_ID: '${{ secrets.SERVICETESTS_REDDIT_CLIENT_ID }}' REDDIT_CLIENT_SECRET: '${{ secrets.SERVICETESTS_REDDIT_CLIENT_SECRET }}' SL_INSIGHT_USER_UUID: '${{ secrets.SERVICETESTS_SL_INSIGHT_USER_UUID }}' SL_INSIGHT_API_TOKEN: '${{ secrets.SERVICETESTS_SL_INSIGHT_API_TOKEN }}' TWITCH_CLIENT_ID: '${{ secrets.SERVICETESTS_TWITCH_CLIENT_ID }}' TWITCH_CLIENT_SECRET: '${{ secrets.SERVICETESTS_TWITCH_CLIENT_SECRET }}' WEBLATE_API_KEY: '${{ secrets.SERVICETESTS_WEBLATE_API_KEY }}' YOUTUBE_API_KEY: '${{ secrets.SERVICETESTS_YOUTUBE_API_KEY }}' shell: bash - name: Coveralls GitHub Action uses: coverallsapp/github-action@v2
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.
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.
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.