Skip to content
Latchkey

unit-tests workflow (upper/db)

The unit-tests workflow from upper/db, explained and optimized by Latchkey.

C

CI health: C - fair

Run this on Latchkey for self-healing, caching, and up to 58% lower cost.

Grade your own workflow free or run it on Latchkey →
Source: upper/db.github/workflows/test.ymlLicense MITView source

What it does

This is the unit-tests workflow from the upper/db 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

workflow (.yml)
on:
  push:
    branches:
      - master
  pull_request:

name: unit-tests

jobs:

  test:

    strategy:
      matrix:
        os: [ubuntu-latest]
        go-version: [1.22.x, 1.23.x, 1.24.x]

    runs-on: ${{ matrix.os }}

    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Install Go
        uses: actions/setup-go@v2
        with:
          go-version: ${{ matrix.go-version }}

      - name: Configure environment
        run: |
          echo "GOARCH=amd64" >> $GITHUB_ENV
          echo "DB_HOST=127.0.0.1" >> $GITHUB_ENV
          echo "UPPER_DB_LOG=ERROR" >> $GITHUB_ENV

      - name: Run tests
        run: make test

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

on:
  push:
    branches:
      - master
  pull_request:
 
name: unit-tests
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
 
  test:
    timeout-minutes: 30
 
    strategy:
      matrix:
        os: [ubuntu-latest]
        go-version: [1.22.x, 1.23.x, 1.24.x]
 
    runs-on: ${{ matrix.os }}
 
    steps:
      - name: Checkout
        uses: actions/checkout@v2
 
      - name: Install Go
        uses: actions/setup-go@v2
        with:
          go-version: ${{ matrix.go-version }}
 
      - name: Configure environment
        run: |
          echo "GOARCH=amd64" >> $GITHUB_ENV
          echo "DB_HOST=127.0.0.1" >> $GITHUB_ENV
          echo "UPPER_DB_LOG=ERROR" >> $GITHUB_ENV
 
      - name: Run tests
        run: make test
 

What changed

This workflow runs 1 job (3 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow