mirror of
https://github.com/netdata/netdata.git
synced 2025-05-01 07:59:52 +00:00
Add cross-architecture build tests for Go code. (#19195)
This commit is contained in:
parent
33633ba176
commit
50429e8bb5
2 changed files with 49 additions and 3 deletions
.github
4
.github/scripts/get-go-version.py
vendored
4
.github/scripts/get-go-version.py
vendored
|
@ -32,8 +32,8 @@ for modfile in GO_SRC.glob('**/go.mod'):
|
||||||
modules.append({
|
modules.append({
|
||||||
'module': str(modfile.parent),
|
'module': str(modfile.parent),
|
||||||
'version': str(version),
|
'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:
|
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
.github/workflows/go-tests.yml
vendored
48
.github/workflows/go-tests.yml
vendored
|
@ -78,7 +78,8 @@ jobs:
|
||||||
- matrix
|
- matrix
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
|
matrix:
|
||||||
|
include: ${{ fromJson(needs.matrix.outputs.matrix) }}
|
||||||
steps:
|
steps:
|
||||||
- name: Skip Check
|
- name: Skip Check
|
||||||
id: skip
|
id: skip
|
||||||
|
@ -125,3 +126,48 @@ jobs:
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
go test -json ./... -race -count=1 2>&1 | gotestfmt -hide all
|
go test -json ./... -race -count=1 2>&1 | gotestfmt -hide all
|
||||||
working-directory: ${{ matrix.module }}
|
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 }}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue