name: Go cross-architecture checks

on:
  pull_request:
  push:
    branches: [main]

permissions:
  contents: read

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        go-version: ["1.24.x"]
        goarch: [amd64, "386", arm64]
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version: ${{ matrix.go-version }}
          cache: true
      - name: Download modules
        run: go mod download
      - name: Test native architecture
        if: matrix.goarch == 'amd64'
        env:
          CGO_ENABLED: "0"
          GOARCH: ${{ matrix.goarch }}
        run: go test ./...
      - name: Compile packages for non-native architecture
        if: matrix.goarch != 'amd64'
        env:
          CGO_ENABLED: "0"
          GOARCH: ${{ matrix.goarch }}
        run: go build ./...
