Go workflow (hound-search/hound)
The Go workflow from hound-search/hound, explained and optimized by Latchkey.
CI health: C - fair
Point runs-on at Latchkey and get run de-duplication, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Go workflow from the hound-search/hound 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
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Go
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go: ["1.24", "1.25", "1.26"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22"
cache: npm
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- run: make
docker-build:
name: Create docker image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=ghcr.io/${{ github.repository_owner }}/hound
VERSION=latest
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
fi
echo "tags=${TAGS}" >> "${GITHUB_OUTPUT}"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
golangci:
name: lint
runs-on: ubuntu-latest
permissions:
contents: read
checks: write
strategy:
fail-fast: false
matrix:
go: ["1.24", "1.25", "1.26"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22"
cache: npm
- name: Build UI
shell: bash
run: |
npm ci
mkdir -p ui/.build/ui
cp -r ui/assets/* ui/.build/ui/
npx webpack --mode production
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- name: golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: v2.11.4
test:
strategy:
fail-fast: false
matrix:
go: ["1.24", "1.25", "1.26"]
os: [windows-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22"
cache: npm
- name: Build UI
run: |
npm ci
mkdir -p ui/.build/ui
cp -r ui/assets/* ui/.build/ui/
npx webpack --mode production
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- run: go test -race ./...
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go name: Go on: push: branches: [main] pull_request: branches: [main] workflow_dispatch: permissions: contents: read concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: build: timeout-minutes: 30 runs-on: latchkey-small strategy: fail-fast: false matrix: go: ["1.24", "1.25", "1.26"] steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: "22" cache: npm - uses: actions/setup-go@v5 with: go-version: ${{ matrix.go }} - run: make docker-build: timeout-minutes: 30 name: Create docker image runs-on: latchkey-small permissions: contents: read packages: write steps: - uses: actions/checkout@v4 - name: Prepare id: prep run: | DOCKER_IMAGE=ghcr.io/${{ github.repository_owner }}/hound VERSION=latest if [[ $GITHUB_REF == refs/tags/* ]]; then VERSION=${GITHUB_REF#refs/tags/v} fi TAGS="${DOCKER_IMAGE}:${VERSION}" if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then TAGS="$TAGS,${DOCKER_IMAGE}:latest" fi echo "tags=${TAGS}" >> "${GITHUB_OUTPUT}" - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Log in to GitHub Container Registry if: github.event_name != 'pull_request' uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push uses: docker/build-push-action@v6 with: context: . platforms: linux/amd64,linux/arm64 file: ./Dockerfile push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.prep.outputs.tags }} golangci: timeout-minutes: 30 name: lint runs-on: latchkey-small permissions: contents: read checks: write strategy: fail-fast: false matrix: go: ["1.24", "1.25", "1.26"] steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: "22" cache: npm - name: Build UI shell: bash run: | npm ci mkdir -p ui/.build/ui cp -r ui/assets/* ui/.build/ui/ npx webpack --mode production - uses: actions/setup-go@v5 with: go-version: ${{ matrix.go }} - name: golangci-lint uses: golangci/golangci-lint-action@v8 with: version: v2.11.4 test: timeout-minutes: 30 strategy: fail-fast: false matrix: go: ["1.24", "1.25", "1.26"] os: [windows-latest, ubuntu-latest] runs-on: ${{ matrix.os }} defaults: run: shell: bash steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: "22" cache: npm - name: Build UI run: | npm ci mkdir -p ui/.build/ui cp -r ui/assets/* ui/.build/ui/ npx webpack --mode production - uses: actions/setup-go@v5 with: go-version: ${{ matrix.go }} - run: go test -race ./...
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Cancel superseded runs when a branch or PR gets a newer push.
- Add a job timeout so a hung step cannot burn hours of runner time.
5 third-party actions are referenced by a movable tag. Pin them to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.
What Latchkey heals here
This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:
- Dependency installs
- Container pulls and builds
This workflow runs 4 jobs (13 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.