Go workflow (heyangxu/Re-movery)
The Go workflow from heyangxu/Re-movery, 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 heyangxu/Re-movery 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
name: Go
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
cache: true
- name: Install dependencies
run: cd go && go mod download
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
working-directory: go
args: --timeout=5m
- name: Run tests
run: cd go && go test -v ./... -coverprofile=coverage.txt -covermode=atomic
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./go/coverage.txt
flags: unittests
- name: Build
run: cd go && go build -v ./cmd/movery
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Build for multiple platforms
run: |
cd go
GOOS=linux GOARCH=amd64 go build -o movery-linux-amd64 ./cmd/movery
GOOS=windows GOARCH=amd64 go build -o movery-windows-amd64.exe ./cmd/movery
GOOS=darwin GOARCH=amd64 go build -o movery-darwin-amd64 ./cmd/movery
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
go/movery-linux-amd64
go/movery-windows-amd64.exe
go/movery-darwin-amd64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Go on: push: branches: [ main ] pull_request: branches: [ main ] concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: build: timeout-minutes: 30 name: Build and Test runs-on: latchkey-small steps: - uses: actions/checkout@v3 - name: Set up Go uses: actions/setup-go@v4 with: go-version: '1.21' cache: true - name: Install dependencies run: cd go && go mod download - name: Run golangci-lint uses: golangci/golangci-lint-action@v3 with: version: latest working-directory: go args: --timeout=5m - name: Run tests run: cd go && go test -v ./... -coverprofile=coverage.txt -covermode=atomic - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: file: ./go/coverage.txt flags: unittests - name: Build run: cd go && go build -v ./cmd/movery release: timeout-minutes: 30 name: Create Release needs: build runs-on: latchkey-small if: startsWith(github.ref, 'refs/tags/') steps: - uses: actions/checkout@v3 - name: Set up Go uses: actions/setup-go@v4 with: go-version: '1.21' - name: Build for multiple platforms run: | cd go GOOS=linux GOARCH=amd64 go build -o movery-linux-amd64 ./cmd/movery GOOS=windows GOARCH=amd64 go build -o movery-windows-amd64.exe ./cmd/movery GOOS=darwin GOARCH=amd64 go build -o movery-darwin-amd64 ./cmd/movery - name: Create Release uses: softprops/action-gh-release@v1 with: files: | go/movery-linux-amd64 go/movery-windows-amd64.exe go/movery-darwin-amd64 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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.
3 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
This workflow runs 2 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.