Skip to content
Latchkey

go workflow (spegel-org/spegel)

The go workflow from spegel-org/spegel, 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: spegel-org/spegel.github/workflows/go.yamlLicense MITView source

What it does

This is the go workflow from the spegel-org/spegel 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)
name: go
on:
  pull_request:
permissions:
  contents: read
defaults:
  run:
    shell: bash
jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 #v6.0.3
      - name: Setup Go
        uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c #v6.4.0
        with:
          go-version-file: go.mod
      - name: Setup golangci-lint
        uses: golangci/golangci-lint-action@82606bf257cbaff209d206a39f5134f0cfbfd2ee #v9.2.1
  unit:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 #v6.0.3
      - name: Setup Go
        uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c #v6.4.0
        with:
          go-version-file: go.mod
      - name: Run tests
        run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...
      - name: Upload coverage reports to Codecov
        uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f #v7.0.0
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          flags: unit
  integration-containerd:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 #v6.0.3
      - name: Setup Go
        uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c #v6.4.0
        with:
          go-version-file: ./test/integration/containerd/go.mod
          cache-dependency-path: ./test/integration/containerd/go.sum
      - name: Run tests
        run: INTEGRATION_TEST_STRATEGY="fast" go test -v -race -coverprofile=coverage.txt -coverpkg=github.com/spegel-org/spegel/... -covermode=atomic -count 1 -failfast ./...
        working-directory: ./test/integration/containerd
      - name: Upload coverage reports to Codecov
        uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f #v7.0.0
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          flags: integration-containerd
          directory: ./test/integration/containerd
  integration-kubernetes:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 #v6.0.3
      - name: Setup Go
        uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c #v6.4.0
        with:
          go-version-file: ./test/integration/kubernetes/go.mod
          cache-dependency-path: ./test/integration/kubernetes/go.sum
      - name: Install GoReleaser
        uses: goreleaser/goreleaser-action@5daf1e915a5f0af01ddbcd89a43b8061ff4f1a89 #v7.2.2
        with:
          install-only: true
      - name: Build image
        id: build
        run: |
          IMG_REF=$(make build-image)
          echo "IMG_REF=${IMG_REF}" >> $GITHUB_OUTPUT
      - name: Run tests
        run: INTEGRATION_TEST_STRATEGY="fast" IMG_REF=${{ steps.build.outputs.IMG_REF }} go test -v -race -count 1 -failfast ./...
        working-directory: ./test/integration/kubernetes

The same workflow, on Latchkey

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

name: go
on:
  pull_request:
permissions:
  contents: read
defaults:
  run:
    shell: bash
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  lint:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - name: Checkout
        uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 #v6.0.3
      - name: Setup Go
        uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c #v6.4.0
        with:
          go-version-file: go.mod
      - name: Setup golangci-lint
        uses: golangci/golangci-lint-action@82606bf257cbaff209d206a39f5134f0cfbfd2ee #v9.2.1
  unit:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - name: Checkout
        uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 #v6.0.3
      - name: Setup Go
        uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c #v6.4.0
        with:
          go-version-file: go.mod
      - name: Run tests
        run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...
      - name: Upload coverage reports to Codecov
        uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f #v7.0.0
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          flags: unit
  integration-containerd:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - name: Checkout
        uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 #v6.0.3
      - name: Setup Go
        uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c #v6.4.0
        with:
          go-version-file: ./test/integration/containerd/go.mod
          cache-dependency-path: ./test/integration/containerd/go.sum
      - name: Run tests
        run: INTEGRATION_TEST_STRATEGY="fast" go test -v -race -coverprofile=coverage.txt -coverpkg=github.com/spegel-org/spegel/... -covermode=atomic -count 1 -failfast ./...
        working-directory: ./test/integration/containerd
      - name: Upload coverage reports to Codecov
        uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f #v7.0.0
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          flags: integration-containerd
          directory: ./test/integration/containerd
  integration-kubernetes:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - name: Checkout
        uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 #v6.0.3
      - name: Setup Go
        uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c #v6.4.0
        with:
          go-version-file: ./test/integration/kubernetes/go.mod
          cache-dependency-path: ./test/integration/kubernetes/go.sum
      - name: Install GoReleaser
        uses: goreleaser/goreleaser-action@5daf1e915a5f0af01ddbcd89a43b8061ff4f1a89 #v7.2.2
        with:
          install-only: true
      - name: Build image
        id: build
        run: |
          IMG_REF=$(make build-image)
          echo "IMG_REF=${IMG_REF}" >> $GITHUB_OUTPUT
      - name: Run tests
        run: INTEGRATION_TEST_STRATEGY="fast" IMG_REF=${{ steps.build.outputs.IMG_REF }} go test -v -race -count 1 -failfast ./...
        working-directory: ./test/integration/kubernetes
 

What changed

This workflow runs 4 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow