0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-04-27 14:16:20 +00:00

Add cross-architecture build tests for Go code. ()

This commit is contained in:
Austin S. Hemmelgarn 2024-12-12 09:57:29 -05:00 committed by GitHub
parent 33633ba176
commit 50429e8bb5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 49 additions and 3 deletions
.github

View file

@ -32,8 +32,8 @@ for modfile in GO_SRC.glob('**/go.mod'):
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')

View file

@ -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
@ -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 }}