name: Audit

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  audit:
    name: audit
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5

      - name: Set up Go
        uses: actions/setup-go@v6
        with:
          go-version: 1.22

      - name: Verify Dependencies
        run: go mod verify

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

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

      - name: Install staticcheck
        run: go install honnef.co/go/tools/cmd/staticcheck@v0.5.1

      - name: Run staticcheck
        run: staticcheck ./...

      - name: Run Unit tests
        run: |
          go test  -covermode atomic -coverprofile=covprofile ./...

      - name: Run Unit tests (race)
        run: |
          go test -race -count=1 -p 1 ./...

      - name: Install goveralls
        run: go install github.com/mattn/goveralls@latest

      - name: Send coverage (only on push to main)
        if: github.event_name == 'push' && github.ref == 'refs/heads/main'
        env:
          COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
        run: goveralls -coverprofile=covprofile -service=github
