name: Go

# Any change in triggers needs to be reflected in the concurrency group.
on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]
  merge_group:

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.after }}
  cancel-in-progress: true

jobs:

  build:
    runs-on: ubuntu-24.04
    steps:
    - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

    - name: Set up Go
      uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
      with:
        # renovate: datasource=golang-version depName=go
        go-version: 1.26.3

    - name: Run static checks
      uses: golangci/golangci-lint-action@82606bf257cbaff209d206a39f5134f0cfbfd2ee # v9.2.1
      with:
        # renovate: datasource=docker depName=golangci/golangci-lint
        version: v2.12.2
        args: --config=.golangci.yml --verbose
        skip-cache: true

    - name: Check module vendoring
      run: |
        go mod tidy
        go mod vendor
        go mod verify
        test -z "$(git status --porcelain)" || (echo "please run 'go mod tidy && go mod vendor', and submit your changes"; exit 1)

    - name: Build
      run: make

    - name: Test
      run: make test
