Skip to content
Latchkey

tests workflow (aws/aws-lambda-go)

The tests workflow from aws/aws-lambda-go, 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.

Grade your own workflow free or run it on Latchkey →
Source: aws/aws-lambda-go.github/workflows/tests.ymlLicense Apache-2.0View source

What it does

This is the tests workflow from the aws/aws-lambda-go 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: tests
on:
  push:
  pull_request:

jobs:
  test:
    name: run tests
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        go:
          - "1.26"
          - "1.25"
          - "1.24"
          - "1.23"
          - "1.22"
          - "1.21"
          - "1.20"
          - "1.19"
          - "1.18"
          - "1.17"
          - "1.16"
          - "1.15"
          - "1.14"
          - "1.13"

    steps:
      - name: Set up Go ${{ matrix.go }}
        uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
        with:
          go-version: ${{ matrix.go }}

      - run: go version

      - name: Check out code into the Go module directory
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

      - name: Edit the go.mod file to allow tests to run for versions of go before 1.16
        run: >
          if [[ ${{ matrix.go }} < "1.16" ]]; then 
            sed -i.bak 's/^.*retract.*$//' go.mod
          else
            echo "no edit required"
          fi

      - name: go test
        run: go test -v -race ./...

  coverage:
    name: run tests with coverage
    runs-on: ubuntu-latest
    strategy:
      matrix:
        go:
          - "1.25"
    steps:
      - name: Set up Go ${{ matrix.go }}
        uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
        with:
          go-version: ${{ matrix.go }}

      - name: Check out code into the Go module directory
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

      - name: go test
        run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...

      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@75cd11691c0faa626561e295848008c8a7dddffe # v5
        with:
          files: ./coverage.txt
          env_vars: GO
        env:
          GO: ${{ matrix.go }}
          CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

The same workflow, on Latchkey

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

name: tests
on:
  push:
  pull_request:
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  test:
    timeout-minutes: 30
    name: run tests
    runs-on: latchkey-small
    strategy:
      fail-fast: false
      matrix:
        go:
          - "1.26"
          - "1.25"
          - "1.24"
          - "1.23"
          - "1.22"
          - "1.21"
          - "1.20"
          - "1.19"
          - "1.18"
          - "1.17"
          - "1.16"
          - "1.15"
          - "1.14"
          - "1.13"
 
    steps:
      - name: Set up Go ${{ matrix.go }}
        uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
        with:
          go-version: ${{ matrix.go }}
 
      - run: go version
 
      - name: Check out code into the Go module directory
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
 
      - name: Edit the go.mod file to allow tests to run for versions of go before 1.16
        run: >
          if [[ ${{ matrix.go }} < "1.16" ]]; then 
            sed -i.bak 's/^.*retract.*$//' go.mod
          else
            echo "no edit required"
          fi
 
      - name: go test
        run: go test -v -race ./...
 
  coverage:
    timeout-minutes: 30
    name: run tests with coverage
    runs-on: latchkey-small
    strategy:
      matrix:
        go:
          - "1.25"
    steps:
      - name: Set up Go ${{ matrix.go }}
        uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
        with:
          go-version: ${{ matrix.go }}
 
      - name: Check out code into the Go module directory
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
 
      - name: go test
        run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
 
      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@75cd11691c0faa626561e295848008c8a7dddffe # v5
        with:
          files: ./coverage.txt
          env_vars: GO
        env:
          GO: ${{ matrix.go }}
          CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
 
 

What changed

This workflow runs 2 jobs (15 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