# This workflow runs Go unit tests across multiple OS and Go versions # Triggers: # - Push/PR with Go file changes (*.go, go.mod, go.sum) # - Skips when only web/ directory changes # Test Matrix: # - PRs: Latest Go on Ubuntu only (fast feedback) # - Develop/Main: Full matrix (ensure cross-platform compatibility) name: Go Tests on: push: paths-ignore: - 'web/**' pull_request: paths-ignore: - 'web/**' jobs: test: strategy: matrix: go-version: ${{ github.event_name == 'pull_request' && fromJSON('["1.24.x"]') || fromJSON('["1.23.x", "1.24.x"]') }} os: ${{ github.event_name == 'pull_request' && fromJSON('["ubuntu-latest"]') || fromJSON('["ubuntu-latest", "macos-latest", "windows-latest", "ubuntu-24.04-arm"]') }} runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v6 - name: Get changed files id: changed-files-yaml uses: tj-actions/changed-files@v47 with: files_yaml: | src: - '**/*.{go,mod,sum}' - uses: actions/cache@v5 if: steps.changed-files-yaml.outputs.src_any_changed == 'true' with: path: | ~/.cache/go-build ~/go/pkg/mod key: go-test-${{ github.sha }} restore-keys: | go-test- - name: Install go if: steps.changed-files-yaml.outputs.src_any_changed == 'true' uses: actions/setup-go@v6 with: go-version: '^1' cache: true - name: Run tests if: steps.changed-files-yaml.outputs.src_any_changed == 'true' run: go test ./... test-bsds: # Only run BSD tests on push events (not PRs) for efficiency if: github.event_name == 'push' runs-on: macos-latest strategy: matrix: os: - name: freebsd version: 12.2 - name: openbsd version: 6.8 steps: - uses: actions/checkout@v6 - name: Get changed files id: changed-files-yaml uses: tj-actions/changed-files@v47 with: files_yaml: | src: - '**/*.{go,mod,sum}' - uses: actions/cache@v5 with: path: | ~/.cache/go-build ~/go/pkg/mod key: go-test-${{ github.sha }} restore-keys: | go-test- - name: Install go if: steps.changed-files-yaml.outputs.src_any_changed == 'true' uses: actions/setup-go@v6 with: go-version: '^1' cache: true - name: Run tests if: steps.changed-files-yaml.outputs.src_any_changed == 'true' run: go test ./...