Skip to content
Latchkey

Linting workflow (prometheus-community/windows_exporter)

The Linting workflow from prometheus-community/windows_exporter, 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: prometheus-community/windows_exporter.github/workflows/lint.ymlLicense MITView source

What it does

This is the Linting workflow from the prometheus-community/windows_exporter 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: Linting

# Trigger on pull requests and pushes to master branch where Go-related files
# have been changed.
on:
  push:
    branches:
      - master
      - next
      - main
      - "0.*"
      - "1.*"
  pull_request:

env:
  VERSION_PROMU: '0.14.0'
  PROMTOOL_VER: '2.43.0'

jobs:
  test:
    runs-on: windows-2025
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
      - uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
        with:
          # renovate: golang=go
          go-version: '1.26.4'

      - name: Test
        run: make test

      - name: Install e2e deps
        run: |
          Invoke-WebRequest -Uri https://github.com/prometheus/promu/releases/download/v$($Env:VERSION_PROMU)/promu-$($Env:VERSION_PROMU).windows-amd64.zip -OutFile promu-$($Env:VERSION_PROMU).windows-amd64.zip
          Expand-Archive -Path promu-$($Env:VERSION_PROMU).windows-amd64.zip -DestinationPath .
          Copy-Item -Path promu-$($Env:VERSION_PROMU).windows-amd64\promu.exe -Destination "$(go env GOPATH)\bin"

          # GOPATH\bin dir must be appended to PATH else the `promu` command won't be found
          echo "$(go env GOPATH)\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

      - name: e2e Test
        run: make e2e-test

  promtool:
    runs-on: windows-2025
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
      - uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
        with:
          # renovate: golang=go
          go-version: '1.26.4'

      - name: Install promtool
        run: |
          Invoke-WebRequest -Uri https://github.com/prometheus/prometheus/releases/download/v$($Env:PROMTOOL_VER)/prometheus-$($Env:PROMTOOL_VER).windows-amd64.zip -OutFile prometheus-$($Env:PROMTOOL_VER).windows-amd64.zip
          Expand-Archive -Path prometheus-$($Env:PROMTOOL_VER).windows-amd64.zip -DestinationPath .
          Copy-Item -Path prometheus-$($Env:PROMTOOL_VER).windows-amd64\promtool.exe -Destination "$(go env GOPATH)\bin"

          Invoke-WebRequest -Uri https://github.com/prometheus/promu/releases/download/v$($Env:VERSION_PROMU)/promu-$($Env:VERSION_PROMU).windows-amd64.zip -OutFile promu-$($Env:VERSION_PROMU).windows-amd64.zip
          Expand-Archive -Path promu-$($Env:VERSION_PROMU).windows-amd64.zip -DestinationPath .
          Copy-Item -Path promu-$($Env:VERSION_PROMU).windows-amd64\promu.exe -Destination "$(go env GOPATH)\bin"

          # GOPATH\bin dir must be appended to PATH else the `promu` command won't be found
          echo "$(go env GOPATH)\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

      - name: Promtool
        run: make promtool

      - name: Upload windows_exporter.exe
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        if: always()
        with:
          name: windows_exporter.amd64.exe
          path: 'windows_exporter.exe'
          retention-days: 7
          if-no-files-found: error

  lint:
    runs-on: windows-2025
    steps:
      # `gofmt` linter run by golangci-lint fails on CRLF line endings (the default for Windows)
      - name: Set git to use LF
        run: |
          git config --global core.autocrlf false
          git config --global core.eol lf

      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
      - uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
        with:
          # renovate: golang=go
          go-version: '1.26.4'

      - name: golangci-lint
        uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
        with:
          # renovate: github=golangci/golangci-lint
          version: v2.12.2
          args: "--max-same-issues=0"

The same workflow, on Latchkey

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

name: Linting
 
# Trigger on pull requests and pushes to master branch where Go-related files
# have been changed.
on:
  push:
    branches:
      - master
      - next
      - main
      - "0.*"
      - "1.*"
  pull_request:
 
env:
  VERSION_PROMU: '0.14.0'
  PROMTOOL_VER: '2.43.0'
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  test:
    timeout-minutes: 30
    runs-on: windows-2025
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
      - uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
        with:
          # renovate: golang=go
          go-version: '1.26.4'
 
      - name: Test
        run: make test
 
      - name: Install e2e deps
        run: |
          Invoke-WebRequest -Uri https://github.com/prometheus/promu/releases/download/v$($Env:VERSION_PROMU)/promu-$($Env:VERSION_PROMU).windows-amd64.zip -OutFile promu-$($Env:VERSION_PROMU).windows-amd64.zip
          Expand-Archive -Path promu-$($Env:VERSION_PROMU).windows-amd64.zip -DestinationPath .
          Copy-Item -Path promu-$($Env:VERSION_PROMU).windows-amd64\promu.exe -Destination "$(go env GOPATH)\bin"
 
          # GOPATH\bin dir must be appended to PATH else the `promu` command won't be found
          echo "$(go env GOPATH)\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
 
      - name: e2e Test
        run: make e2e-test
 
  promtool:
    timeout-minutes: 30
    runs-on: windows-2025
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
      - uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
        with:
          # renovate: golang=go
          go-version: '1.26.4'
 
      - name: Install promtool
        run: |
          Invoke-WebRequest -Uri https://github.com/prometheus/prometheus/releases/download/v$($Env:PROMTOOL_VER)/prometheus-$($Env:PROMTOOL_VER).windows-amd64.zip -OutFile prometheus-$($Env:PROMTOOL_VER).windows-amd64.zip
          Expand-Archive -Path prometheus-$($Env:PROMTOOL_VER).windows-amd64.zip -DestinationPath .
          Copy-Item -Path prometheus-$($Env:PROMTOOL_VER).windows-amd64\promtool.exe -Destination "$(go env GOPATH)\bin"
 
          Invoke-WebRequest -Uri https://github.com/prometheus/promu/releases/download/v$($Env:VERSION_PROMU)/promu-$($Env:VERSION_PROMU).windows-amd64.zip -OutFile promu-$($Env:VERSION_PROMU).windows-amd64.zip
          Expand-Archive -Path promu-$($Env:VERSION_PROMU).windows-amd64.zip -DestinationPath .
          Copy-Item -Path promu-$($Env:VERSION_PROMU).windows-amd64\promu.exe -Destination "$(go env GOPATH)\bin"
 
          # GOPATH\bin dir must be appended to PATH else the `promu` command won't be found
          echo "$(go env GOPATH)\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
 
      - name: Promtool
        run: make promtool
 
      - name: Upload windows_exporter.exe
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        if: always()
        with:
          name: windows_exporter.amd64.exe
          path: 'windows_exporter.exe'
          retention-days: 7
          if-no-files-found: error
 
  lint:
    timeout-minutes: 30
    runs-on: windows-2025
    steps:
      # `gofmt` linter run by golangci-lint fails on CRLF line endings (the default for Windows)
      - name: Set git to use LF
        run: |
          git config --global core.autocrlf false
          git config --global core.eol lf
 
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
      - uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
        with:
          # renovate: golang=go
          go-version: '1.26.4'
 
      - name: golangci-lint
        uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
        with:
          # renovate: github=golangci/golangci-lint
          version: v2.12.2
          args: "--max-same-issues=0"
 

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 3 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