Skip to content
Latchkey

Go workflow (heyangxu/Re-movery)

The Go workflow from heyangxu/Re-movery, explained and optimized by Latchkey.

C

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.

Grade your own workflow free or run it on Latchkey →
Source: heyangxu/Re-movery.github/workflows/go.ymlLicense MITView source

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

workflow (.yml)
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

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:

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