Skip to content
Latchkey

go-ci workflow (nyu-mlab/iot-inspector-client)

The go-ci workflow from nyu-mlab/iot-inspector-client, explained and optimized by Latchkey.

C

CI health: C - fair

Run this on Latchkey for self-healing, caching, and up to 58% lower cost.

Grade your own workflow free or run it on Latchkey →
Source: nyu-mlab/iot-inspector-client.github/workflows/go-ci.ymlLicense Apache-2.0View source

What it does

This is the go-ci workflow from the nyu-mlab/iot-inspector-client repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
name: go-ci

on:
  push:
    branches: [go-rewrite]
    paths: ['go/**', '.github/workflows/go-ci.yml']
  pull_request:
    paths: ['go/**', '.github/workflows/go-ci.yml']

defaults:
  run:
    working-directory: go

jobs:
  test:
    name: ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    env:
      CGO_ENABLED: "1"
    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-go@v5
        with:
          go-version: stable
          cache-dependency-path: go/go.sum

      - name: Install libpcap (Linux)
        if: runner.os == 'Linux'
        run: sudo apt-get update && sudo apt-get install -y libpcap-dev

      - name: Install Npcap SDK (Windows)
        if: runner.os == 'Windows'
        shell: pwsh
        run: |
          Invoke-WebRequest -Uri https://npcap.com/dist/npcap-sdk-1.13.zip -OutFile npcap-sdk.zip
          Expand-Archive npcap-sdk.zip -DestinationPath "$env:GITHUB_WORKSPACE\npcap-sdk"
          "CGO_CFLAGS=-I$env:GITHUB_WORKSPACE\npcap-sdk\Include"  | Out-File -FilePath $env:GITHUB_ENV -Append
          "CGO_LDFLAGS=-L$env:GITHUB_WORKSPACE\npcap-sdk\Lib\x64" | Out-File -FilePath $env:GITHUB_ENV -Append

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

      - name: Vet
        run: go vet ./...

      - name: Test
        run: go test ./...

The same workflow, on Latchkey

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

name: go-ci
 
on:
  push:
    branches: [go-rewrite]
    paths: ['go/**', '.github/workflows/go-ci.yml']
  pull_request:
    paths: ['go/**', '.github/workflows/go-ci.yml']
 
defaults:
  run:
    working-directory: go
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  test:
    timeout-minutes: 30
    name: ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    env:
      CGO_ENABLED: "1"
    steps:
      - uses: actions/checkout@v4
 
      - uses: actions/setup-go@v5
        with:
          go-version: stable
          cache-dependency-path: go/go.sum
 
      - name: Install libpcap (Linux)
        if: runner.os == 'Linux'
        run: sudo apt-get update && sudo apt-get install -y libpcap-dev
 
      - name: Install Npcap SDK (Windows)
        if: runner.os == 'Windows'
        shell: pwsh
        run: |
          Invoke-WebRequest -Uri https://npcap.com/dist/npcap-sdk-1.13.zip -OutFile npcap-sdk.zip
          Expand-Archive npcap-sdk.zip -DestinationPath "$env:GITHUB_WORKSPACE\npcap-sdk"
          "CGO_CFLAGS=-I$env:GITHUB_WORKSPACE\npcap-sdk\Include"  | Out-File -FilePath $env:GITHUB_ENV -Append
          "CGO_LDFLAGS=-L$env:GITHUB_WORKSPACE\npcap-sdk\Lib\x64" | Out-File -FilePath $env:GITHUB_ENV -Append
 
      - name: Build
        run: go build ./...
 
      - name: Vet
        run: go vet ./...
 
      - name: Test
        run: go test ./...
 

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 1 job (3 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow