on:
  pull_request:
    paths-ignore:
      - 'README.md'
      - 'CONTRIBUTING.md'
      - 'COPYING'
      - 'website/**'
      - '.github/*.md'
      - '.github/FUNDING.yml'

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

name: Validate Code
jobs:
  test:
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    defaults:
      run:
        working-directory: ${{ github.workspace }}/src
    steps:
    - name: Checkout code
      uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98
    - name: Install Go 🗳
      uses: ./.github/workflows/composite/bootstrap-go
    - name: Golang CI
      uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20
      with:
        working-directory: src
    - name: Fieldalignment
      run: |
        go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@latest
        fieldalignment "./..."
    - name: Modernize
      run: |
        go install golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest
        modernize "./..."
    - name: Unit Tests
      run: go test -v ./...
