name: build-pr

on:
  pull_request:

env:
  GOPROXY: https://proxy.golang.org/

jobs:
  generate-provider-schemas:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # https://github.com/actions/checkout/releases/tag/v4.1.1
      - name: Set up Go
        uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # https://github.com/actions/setup-go/releases/tag/v4.1.0
        with:
          go-version-file: ".go-version"
      - name: Generate provider schemas
        run: |
          go generate ./internal/schemas
          du -h -s ./internal/schemas/data

  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        include:
          - { goos: "linux", goarch: "386" }
          - { goos: "linux", goarch: "amd64" }
          - { goos: "linux", goarch: "arm" }
          - { goos: "linux", goarch: "arm64" }
          - { goos: "freebsd", goarch: "386" }
          - { goos: "freebsd", goarch: "amd64" }
          - { goos: "freebsd", goarch: "arm" }
          - { goos: "openbsd", goarch: "386" }
          - { goos: "openbsd", goarch: "amd64" }
          - { goos: "solaris", goarch: "amd64" }
          - { goos: "windows", goarch: "386" }
          - { goos: "windows", goarch: "amd64" }
          - { goos: "windows", goarch: "arm64" }
          - { goos: "darwin", goarch: "arm64" }
          - { goos: "darwin", goarch: "amd64" }
    timeout-minutes: 25
    steps:
      - name: Checkout
        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # https://github.com/actions/checkout/releases/tag/v4.1.1
      - name: Set up Go
        uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # https://github.com/actions/setup-go/releases/tag/v4.1.0
        with:
          go-version-file: ".go-version"
      - name: ${{ matrix.goos }} ${{ matrix.goarch }} build
        run: |-
          go build \
            -trimpath \
            -buildvcs=false \
            -ldflags "-s -w"
