Skip to content
Latchkey

Coveralls Code Coverage workflow (badges/shields)

The Coveralls Code Coverage workflow from badges/shields, explained and optimized by Latchkey.

B

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.

Grade your own workflow free or run it on Latchkey →
Source: badges/shields.github/workflows/coveralls-code-coverage.ymlLicense Apache-2.0View source

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

workflow (.yml)
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

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.

Actions used in this workflow