Skip to content

Commit

Permalink
Add cross-architecture build tests for Go code. (netdata#19195)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferroin authored Dec 12, 2024
1 parent 33633ba commit 50429e8
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/scripts/get-go-version.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
modules.append({
'module': str(modfile.parent),
'version': str(version),
'build_target': f'github.com/netdata/netdata/go/plugins/{ str(mainpath) }/',
'build_target': f'github.com/netdata/netdata/go/plugins/{str(mainpath)}/',
})

with GITHUB_OUTPUT.open('a') as f:
f.write(f'matrix={ json.dumps({"include": modules}) }\n')
f.write(f'matrix={json.dumps(modules)}\n')
48 changes: 47 additions & 1 deletion .github/workflows/go-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ jobs:
- matrix
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
matrix:
include: ${{ fromJson(needs.matrix.outputs.matrix) }}
steps:
- name: Skip Check
id: skip
Expand Down Expand Up @@ -125,3 +126,48 @@ jobs:
set -euo pipefail
go test -json ./... -race -count=1 2>&1 | gotestfmt -hide all
working-directory: ${{ matrix.module }}

build-tests:
name: Go build tests
runs-on: ubuntu-latest
needs:
- file-check
- matrix
strategy:
fail-fast: false
matrix:
platforms:
- linux/386
- linux/amd64
- linux/arm
- linux/arm64
- linux/ppc64le
- windows/amd64
include: ${{ fromJson(needs.matrix.outputs.matrix) }}
steps:
- name: Skip Check
id: skip
if: needs.file-check.outputs.run != 'true'
run: echo "SKIPPED"
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.version }}
- name: Checkout
if: needs.file-check.outputs.run == 'true'
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set GOOS and GOARCH
run: |
echo "GOOS=$(echo "${{ matrix.platform }}" | cut -f 1 -d '/')" >> "${GITHUB_ENV}"
echo "GOARCH=$(echo "${{ matrix.platform }}" | cut -f 2 -d '/')" >> "${GITHUB_ENV}"
- name: Go mod download
if: needs.file-check.outputs.run == 'true'
run: go mod download
working-directory: ${{ matrix.module }}
- name: Compile
if: needs.file-check.outputs.run == 'true'
run: |
CGO_ENABLED=0 go build -o /tmp/go-test-build ${{ matrix.build_target }}
working-directory: ${{ matrix.module }}

0 comments on commit 50429e8

Please sign in to comment.