ajhahn.de
← eeco
YAML 92 lines
# CI: build, vet, test, eeco's own attribution + workspace-path gates,
# and the golangci-lint quality bar. Runs on every PR and on push to
# main. Read-only token by design.

name: ci

on:
  pull_request:
  push:
    branches: [main]

concurrency:
  group: ci-${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}

permissions:
  contents: read

jobs:
  verify:
    name: verify + gates (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest]
    defaults:
      run:
        # Force Git Bash on windows-latest so the Makefile recipes and
        # the smoke step share one shell with the linux job.
        shell: bash
    steps:
      - name: checkout
        uses: actions/checkout@v5
        with:
          fetch-depth: 0
      - name: setup-go
        uses: actions/setup-go@v6
        with:
          go-version-file: go.mod
          cache: true
      - name: verify
        run: make verify
      - name: coverage
        if: matrix.os == 'ubuntu-latest'
        run: make cover-check
      - name: codecov
        if: matrix.os == 'ubuntu-latest'
        uses: codecov/codecov-action@v5
        with:
          files: coverage.out
          token: ${{ secrets.CODECOV_TOKEN }}
          fail_ci_if_error: false
      - name: gates
        run: make gates
      - name: check version badge
        if: matrix.os == 'ubuntu-latest'
        run: bash scripts/check-version-badge.sh
      - name: windows-smoke
        if: matrix.os == 'windows-latest'
        run: |
          set -eu
          mkdir -p tmp-smoke
          cd tmp-smoke
          git init -q
          git config user.email smoke@local
          git config user.name smoke
          ../eeco.exe init
          ../eeco.exe run leak-guard
          ../eeco.exe hooks pre-commit on
          ../eeco.exe hooks pre-commit off
          ../eeco.exe doctor

  lint:
    name: lint
    runs-on: ubuntu-latest
    steps:
      - name: checkout
        uses: actions/checkout@v5
      - name: setup-go
        uses: actions/setup-go@v6
        with:
          go-version-file: go.mod
          cache: true
      # golangci-lint v2.12.2 needs Go >= 1.25 to build; eeco's go.mod
      # pins an older version and actions/setup-go exports
      # GOTOOLCHAIN=local. Set GOTOOLCHAIN=auto inline so `go run`
      # fetches the newer toolchain only to build the linter — eeco's
      # own build, in the verify job, stays on the go.mod version.
      - name: lint
        run: GOTOOLCHAIN=auto make lint