name: Build

on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
      uses: actions/checkout@v4

    - name: Set up Go
      uses: actions/setup-go@v5
      with:
        go-version: 1.23

    - name: Build
      run: make build

    - name: Run tests
      run: make test

    - name: Format
      run: |
        DIFF="$(gofmt -d .)"
        if [[ -n $DIFF ]]; then
          echo "$DIFF"
          echo "please run gofmt"
          exit 1
        fi

    - name: golangci-lint
      uses: golangci/golangci-lint-action@v6
      with:
        version: v1.60
