From 9a70a92261bd89dd001939bba8d06c7aeac030e7 Mon Sep 17 00:00:00 2001 From: Ivan Date: Sat, 27 Sep 2025 05:43:54 -0500 Subject: [PATCH] Add support for multi-platform testing --- .github/workflows/go-test.yml | 57 ++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 5 deletions(-) diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml index e6791e7..1b6147e 100644 --- a/.github/workflows/go-test.yml +++ b/.github/workflows/go-test.yml @@ -1,4 +1,4 @@ -name: Go Test +name: Go Test Multi-Platform on: push: @@ -13,15 +13,62 @@ permissions: jobs: test: - runs-on: ubuntu-latest + name: Test (${{ matrix.os }}, ${{ matrix.goarch }}) + strategy: + matrix: + include: + # AMD64 testing across major platforms + - os: ubuntu-latest + goarch: amd64 + - os: windows-latest + goarch: amd64 + - os: macos-latest + goarch: amd64 + # ARM64 testing on supported platforms + - os: ubuntu-latest + goarch: arm64 + - os: macos-latest + goarch: arm64 + + runs-on: ${{ matrix.os }} + steps: - name: Checkout Source - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + uses: actions/checkout@v4 - name: Set up Go 1.25 - uses: actions/setup-go@19bb51245e9c80abacb2e91cc42b33fa478b8639 + uses: actions/setup-go@v4 with: go-version: '1.25' + - name: Cache Go modules + uses: actions/cache@v3 + with: + path: | + ~/go/pkg/mod + ~/.cache/go-build + key: ${{ runner.os }}-go-${{ matrix.goarch }}-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go-${{ matrix.goarch }}- + - name: Run Go tests - run: go test ./... + run: go test -v ./... + + - name: Run Go tests with race detector (Linux AMD64 only) + if: matrix.os == 'ubuntu-latest' && matrix.goarch == 'amd64' + run: go test -race -v ./... + + - name: Test build (ensure compilation works) + run: | + # Test that we can build for the current platform + echo "Testing build for current platform (${{ matrix.os }}, ${{ matrix.goarch }})..." + go build -v ./cmd/reticulum-go + + - name: Test cross-compilation (AMD64 runners only) + if: matrix.goarch == 'amd64' + run: | + echo "Testing ARM64 cross-compilation from AMD64..." + GOOS=linux GOARCH=arm64 go build -v ./cmd/reticulum-go + + echo "Testing ARMv6 cross-compilation from AMD64..." + GOOS=linux GOARCH=arm GOARM=6 go build -v ./cmd/reticulum-go