Skip to content
Latchkey

tests workflow (willnorris/imageproxy)

The tests workflow from willnorris/imageproxy, 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.

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

What it does

This is the tests workflow from the willnorris/imageproxy 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:
    branches:
      - main
  pull_request:
    branches:
      - "**"
  schedule: # daily at 07:30 UTC
    - cron: "30 7 * * *"
  workflow_dispatch:
permissions:
  contents: read
concurrency:
  group: ${{ github.workflow }}-$${{ github.head_ref || github.run_id }}
  cancel-in-progress: true
jobs:
  test:
    strategy:
      fail-fast: false
      matrix:
        go:
          # test with the two most recent major go versions,
          # as well as the minimum supported from go.mod.
          - { go-version: stable }
          - { go-version: oldstable }
          - { go-version-file: go.mod }
        platform: [ubuntu-latest]
        include:
          # include windows, but only with the latest Go version, since there
          # is very little in the library that is platform specific
          - go: { go-version: stable }
            platform: windows-latest

          # only update test coverage stats with most recent go version on linux
          - go: { go-version: stable }
            platform: ubuntu-latest
            update-coverage: true
    runs-on: ${{ matrix.platform }}
    steps:
      - uses: actions/checkout@v6
        with:
          persist-credentials: false
      - uses: actions/setup-go@v6
        with:
          go-version: ${{ matrix.go.go-version }}
          go-version-file: ${{ matrix.go.go-version-file }}
      - name: Run go test
        run: go test -v -race -coverprofile coverage.txt -covermode atomic ./...
      - name: Upload coverage to Codecov
        if: ${{ matrix.update-coverage }}
        uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2
  test-latest:
    strategy:
      fail-fast: false
      matrix:
        go:
          - { go-version: stable }
          - { go-version-file: go.mod }
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
        with:
          persist-credentials: false
      - uses: actions/setup-go@v6
        with:
          go-version: ${{ matrix.go.go-version }}
          go-version-file: ${{ matrix.go.go-version-file }}
      - uses: geomys/sandboxed-step@7d75eb49d17fdeeb3656b3a57d35932d205bcfb9 # v1.2.1
        with:
          run: |
            go get -u -t ./...
            go test -race ./...
  staticcheck:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
        with:
          persist-credentials: false
      - uses: actions/setup-go@v6
        with:
          go-version: stable
      - uses: geomys/sandboxed-step@7d75eb49d17fdeeb3656b3a57d35932d205bcfb9 # v1.2.1
        with:
          run: go run honnef.co/go/tools/cmd/staticcheck@latest ./...
  govulncheck:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
        with:
          persist-credentials: false
      - uses: actions/setup-go@v6
        with:
          go-version: stable
      - uses: geomys/sandboxed-step@7d75eb49d17fdeeb3656b3a57d35932d205bcfb9 # v1.2.1
        with:
          run: |
            go run golang.org/x/vuln/cmd/govulncheck@latest ./...
            pushd caddy; go run golang.org/x/vuln/cmd/govulncheck@latest ./...; popd

The same workflow, on Latchkey

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

name: tests
on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - "**"
  schedule: # daily at 07:30 UTC
    - cron: "30 7 * * *"
  workflow_dispatch:
permissions:
  contents: read
concurrency:
  group: ${{ github.workflow }}-$${{ github.head_ref || github.run_id }}
  cancel-in-progress: true
jobs:
  test:
    timeout-minutes: 30
    strategy:
      fail-fast: false
      matrix:
        go:
          # test with the two most recent major go versions,
          # as well as the minimum supported from go.mod.
          - { go-version: stable }
          - { go-version: oldstable }
          - { go-version-file: go.mod }
        platform: [ubuntu-latest]
        include:
          # include windows, but only with the latest Go version, since there
          # is very little in the library that is platform specific
          - go: { go-version: stable }
            platform: windows-latest
 
          # only update test coverage stats with most recent go version on linux
          - go: { go-version: stable }
            platform: ubuntu-latest
            update-coverage: true
    runs-on: ${{ matrix.platform }}
    steps:
      - uses: actions/checkout@v6
        with:
          persist-credentials: false
      - uses: actions/setup-go@v6
        with:
          go-version: ${{ matrix.go.go-version }}
          go-version-file: ${{ matrix.go.go-version-file }}
      - name: Run go test
        run: go test -v -race -coverprofile coverage.txt -covermode atomic ./...
      - name: Upload coverage to Codecov
        if: ${{ matrix.update-coverage }}
        uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2
  test-latest:
    timeout-minutes: 30
    strategy:
      fail-fast: false
      matrix:
        go:
          - { go-version: stable }
          - { go-version-file: go.mod }
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v6
        with:
          persist-credentials: false
      - uses: actions/setup-go@v6
        with:
          go-version: ${{ matrix.go.go-version }}
          go-version-file: ${{ matrix.go.go-version-file }}
      - uses: geomys/sandboxed-step@7d75eb49d17fdeeb3656b3a57d35932d205bcfb9 # v1.2.1
        with:
          run: |
            go get -u -t ./...
            go test -race ./...
  staticcheck:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v6
        with:
          persist-credentials: false
      - uses: actions/setup-go@v6
        with:
          go-version: stable
      - uses: geomys/sandboxed-step@7d75eb49d17fdeeb3656b3a57d35932d205bcfb9 # v1.2.1
        with:
          run: go run honnef.co/go/tools/cmd/staticcheck@latest ./...
  govulncheck:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v6
        with:
          persist-credentials: false
      - uses: actions/setup-go@v6
        with:
          go-version: stable
      - uses: geomys/sandboxed-step@7d75eb49d17fdeeb3656b3a57d35932d205bcfb9 # v1.2.1
        with:
          run: |
            go run golang.org/x/vuln/cmd/govulncheck@latest ./...
            pushd caddy; go run golang.org/x/vuln/cmd/govulncheck@latest ./...; popd
 

What changed

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