name: CI

on:
  push:
    branches: [main]
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: actions/setup-go@v6.5.0
        with:
          go-version: "1.26"
      - name: Check formatting
        run: |
          unformatted=$(gofmt -l .)
          if [ -n "$unformatted" ]; then
            echo "$unformatted"
            exit 1
          fi
      - run: go vet ./...
      - uses: golangci/golangci-lint-action@v9.3.0
        with:
          version: v2.0.0
      - run: go build ./...
      - run: go test ./...
