name: go

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

permissions:
  contents: read

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - name: set up go
        uses: actions/setup-go@v7
        with:
          go-version: "1.25"
      - name: golangci-lint
        uses: golangci/golangci-lint-action@v8
        with:
          version: v2.11.4

  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        go-version: ["1.25"]
    steps:
      - uses: actions/checkout@v7
      - name: set up go
        uses: actions/setup-go@v7
        with:
          go-version: ${{ matrix.go-version }}
      - name: build
        run: make
      - name: run tests with coverage
        run: go test -race -coverprofile=coverage.out -covermode=atomic ./...
      - name: upload coverage to codecov
        uses: codecov/codecov-action@v7
        with:
          files: ./coverage.out
          fail_ci_if_error: false
      - name: run integration tests
        run: go test -tags=integration -race ./internal/scan/...
