Skip to content
Latchkey

CI workflow (loov/lensm)

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

What it does

This is the CI workflow from the loov/lensm 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: CI

on:
  push:
    branches: [main]
    tags: ["v*"]
  pull_request:
  workflow_dispatch:

permissions:
  contents: read

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-go@v6
        with:
          go-version-file: go.mod
          cache: true
      - run: sudo apt-get update && sudo apt-get install -y gcc pkg-config libwayland-dev libx11-dev libx11-xcb-dev libxkbcommon-x11-dev libgles2-mesa-dev libegl1-mesa-dev libffi-dev libxcursor-dev libvulkan-dev
      - run: go test ./...

  build-macos:
    if: github.event_name == 'workflow_dispatch' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v'))
    needs: test
    name: macOS ${{ matrix.goarch }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - runner: macos-15
            goarch: arm64
          - runner: macos-15-intel
            goarch: amd64
    runs-on: ${{ matrix.runner }}
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-go@v6
        with:
          go-version-file: go.mod
          cache: true
      - name: Build application DMG
        shell: bash
        run: |
          if [[ "$GITHUB_REF_TYPE" == "tag" && "$GITHUB_REF_NAME" == v* ]]; then
            # CFBundleShortVersionString accepts only digits and dots;
            # strip any pre-release/build suffix (v1.2.3-rc1 -> 1.2.3).
            version="${GITHUB_REF_NAME#v}"
            version="${version%%-*}"
            version="${version%%+*}"
          else
            version="0.0.${GITHUB_RUN_NUMBER}"
          fi
          ./scripts/build-macos-dmg.sh "$version" "$GITHUB_RUN_NUMBER" "${{ matrix.goarch }}"
      - name: Upload DMG
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
        with:
          # Artifact names are immutable in upload-artifact v4+; without a
          # per-arch name both matrix jobs upload to "artifact" and the
          # second one fails.
          name: lensm-dmg-${{ matrix.goarch }}
          path: dist/*.dmg
          archive: false
          if-no-files-found: error

The same workflow, on Latchkey

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

name: CI
 
on:
  push:
    branches: [main]
    tags: ["v*"]
  pull_request:
  workflow_dispatch:
 
permissions:
  contents: read
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  test:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-go@v6
        with:
          go-version-file: go.mod
          cache: true
      - run: sudo apt-get update && sudo apt-get install -y gcc pkg-config libwayland-dev libx11-dev libx11-xcb-dev libxkbcommon-x11-dev libgles2-mesa-dev libegl1-mesa-dev libffi-dev libxcursor-dev libvulkan-dev
      - run: go test ./...
 
  build-macos:
    timeout-minutes: 30
    if: github.event_name == 'workflow_dispatch' || (github.ref_type == 'tag' && startsWith(github.ref_name, 'v'))
    needs: test
    name: macOS ${{ matrix.goarch }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - runner: macos-15
            goarch: arm64
          - runner: macos-15-intel
            goarch: amd64
    runs-on: ${{ matrix.runner }}
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-go@v6
        with:
          go-version-file: go.mod
          cache: true
      - name: Build application DMG
        shell: bash
        run: |
          if [[ "$GITHUB_REF_TYPE" == "tag" && "$GITHUB_REF_NAME" == v* ]]; then
            # CFBundleShortVersionString accepts only digits and dots;
            # strip any pre-release/build suffix (v1.2.3-rc1 -> 1.2.3).
            version="${GITHUB_REF_NAME#v}"
            version="${version%%-*}"
            version="${version%%+*}"
          else
            version="0.0.${GITHUB_RUN_NUMBER}"
          fi
          ./scripts/build-macos-dmg.sh "$version" "$GITHUB_RUN_NUMBER" "${{ matrix.goarch }}"
      - name: Upload DMG
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
        with:
          # Artifact names are immutable in upload-artifact v4+; without a
          # per-arch name both matrix jobs upload to "artifact" and the
          # second one fails.
          name: lensm-dmg-${{ matrix.goarch }}
          path: dist/*.dmg
          archive: false
          if-no-files-found: error
 

What changed

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