Skip to content
Latchkey

Go workflow (go-gorp/gorp)

The Go workflow from go-gorp/gorp, 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: go-gorp/gorp.github/workflows/go.ymlLicense MITView source

What it does

This is the Go workflow from the go-gorp/gorp 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
      - v3
  pull_request:
    branches:
      - main
      - v3

jobs:

  integration-tests:
    runs-on: ubuntu-latest
    container: golang:1.18

    services:
      postgres:
        image: postgres
        env:
          POSTGRES_DB: gorptest
          POSTGRES_USER: gorptest
          POSTGRES_PASSWORD: gorptest
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 10

      mysql:
        image: mysql:5.7
        env:
          MYSQL_DATABASE: gorptest
          MYSQL_USER: gorptest
          MYSQL_PASSWORD: gorptest
          MYSQL_RANDOM_ROOT_PASSWORD: true
        options: >-
          --health-cmd "mysqladmin ping"
          --health-interval 10s
          --health-timeout 5s
          --health-retries 10

    steps:
      - uses: actions/checkout@v3

      - name: Integration Tests
        run: ./test_all.sh

  quick-tests:
    runs-on: ubuntu-latest
    container: golang:1.18
    steps:
    - uses: actions/checkout@v3

    - name: Go Build
      run: go build -v ./...

    - name: Unit Tests
      run: go test -v ./...

The same workflow, on Latchkey

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

name: Go
 
on:
  push:
    branches:
      - main
      - v3
  pull_request:
    branches:
      - main
      - v3
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
 
  integration-tests:
    timeout-minutes: 30
    runs-on: latchkey-small
    container: golang:1.18
 
    services:
      postgres:
        image: postgres
        env:
          POSTGRES_DB: gorptest
          POSTGRES_USER: gorptest
          POSTGRES_PASSWORD: gorptest
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 10
 
      mysql:
        image: mysql:5.7
        env:
          MYSQL_DATABASE: gorptest
          MYSQL_USER: gorptest
          MYSQL_PASSWORD: gorptest
          MYSQL_RANDOM_ROOT_PASSWORD: true
        options: >-
          --health-cmd "mysqladmin ping"
          --health-interval 10s
          --health-timeout 5s
          --health-retries 10
 
    steps:
      - uses: actions/checkout@v3
 
      - name: Integration Tests
        run: ./test_all.sh
 
  quick-tests:
    timeout-minutes: 30
    runs-on: latchkey-small
    container: golang:1.18
    steps:
    - uses: actions/checkout@v3
 
    - name: Go Build
      run: go build -v ./...
 
    - name: Unit Tests
      run: go test -v ./...
 

What changed

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