Files
NTrace-core/.github/workflows/test.yml
T

238 lines
7.3 KiB
YAML

name: Test
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
on:
push:
branches:
- main
paths:
- "**/*.go"
- "**/testdata/**"
- "go.mod"
- "go.sum"
- "default.pgo"
- "nt_install.sh"
- ".cross_compile.sh"
- "scripts/test_nt_install.sh"
- "scripts/test_mtr_session_pty.py"
- "scripts/perf/**"
- ".github/workflows/*.yml"
pull_request:
types: [opened, synchronize, reopened]
paths:
- "**/*.go"
- "**/testdata/**"
- "go.mod"
- "go.sum"
- "default.pgo"
- "nt_install.sh"
- ".cross_compile.sh"
- "scripts/test_nt_install.sh"
- "scripts/test_mtr_session_pty.py"
- "scripts/perf/**"
- ".github/workflows/*.yml"
workflow_dispatch:
jobs:
test:
name: Default JSON (${{ matrix.os }})
runs-on: ${{ matrix.os }}
env:
GOTOOLCHAIN: go1.27.1
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
steps:
- name: Checkout codebase
uses: actions/checkout@v7
with:
fetch-depth: 0
fetch-tags: true
- name: Set up Go (built-in cache)
uses: actions/setup-go@v7
with:
go-version: '1.27.1'
check-latest: true
cache: true
- name: Test with unix
if: ${{ matrix.os != 'windows-latest' }}
shell: bash
run: go test -v -covermode=count -coverprofile='coverage.out' ./...
- name: Test alternate flavors with unix
if: ${{ matrix.os != 'windows-latest' }}
shell: bash
run: |
go test -tags flavor_tiny ./cmd ./server
go test -tags flavor_ntr ./cmd ./server
- name: Doctor native loopback route smoke
env:
NEXTTRACE_DOCTOR_INTEGRATION: '1'
run: go test ./internal/doctor -run '^TestNativeLoopbackRoute$' -count=1
- name: Doctor privileged backend smoke
if: ${{ matrix.os != 'windows-latest' }}
shell: bash
run: |
go test -c -o "${RUNNER_TEMP}/doctor-backend.test" ./trace/internal
sudo env NEXTTRACE_DOCTOR_BACKEND_INTEGRATION=1 "${RUNNER_TEMP}/doctor-backend.test" -test.run '^TestDoctorNativeBackend$' -test.v
- name: Verify q v0.19.12 adapter parity
if: ${{ matrix.os == 'ubuntu-latest' }}
shell: bash
run: |
go mod download github.com/natesales/q@v0.19.12
Q_SOURCE="$(go env GOMODCACHE)/github.com/natesales/q@v0.19.12"
(cd "${Q_SOURCE}" && go build -trimpath -o "${RUNNER_TEMP}/q-v0.19.12" .)
NEXTTRACE_Q_REFERENCE_BINARY="${RUNNER_TEMP}/q-v0.19.12" \
go test ./internal/dnsclient -run '^TestPinnedQ' -count=1
- name: Smoke test nt_install.sh
if: ${{ matrix.os != 'windows-latest' }}
shell: bash
run: |
bash -n nt_install.sh
sh -n nt_install.sh
bash scripts/test_nt_install.sh
- name: Verify module state
if: ${{ matrix.os == 'ubuntu-latest' }}
shell: bash
run: |
go mod verify
go mod tidy -diff
- name: Run go vet
if: ${{ matrix.os == 'ubuntu-latest' }}
run: go vet ./...
- name: Test WebUI assets
if: ${{ matrix.os == 'ubuntu-latest' }}
shell: bash
run: node --test server/web/assets/*.test.cjs
- name: Check shell syntax
if: ${{ matrix.os == 'ubuntu-latest' }}
shell: bash
run: |
for script in .cross_compile.sh scripts/perf/*.sh; do
bash -n "${script}"
done
- name: Build all flavors on Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
shell: bash
run: |
go build -buildvcs=false -trimpath -o "${RUNNER_TEMP}/nexttrace" .
go build -buildvcs=false -trimpath -tags flavor_tiny -o "${RUNNER_TEMP}/nexttrace-tiny" .
go build -buildvcs=false -trimpath -tags flavor_ntr -o "${RUNNER_TEMP}/ntr" .
- name: MTR column editor PTY smoke
if: ${{ matrix.os != 'windows-latest' }}
shell: bash
run: |
go build -o "${RUNNER_TEMP}/nexttrace-mtr-columns" .
sudo python3 scripts/test_mtr_columns_pty.py "${RUNNER_TEMP}/nexttrace-mtr-columns"
- name: MTR column editor ConPTY smoke
if: ${{ matrix.os == 'windows-latest' }}
shell: pwsh
run: |
python -m pip install pywinpty==3.0.5
go build -o "$env:RUNNER_TEMP/nexttrace-mtr-columns.exe" .
python scripts/test_mtr_columns_pty.py "$env:RUNNER_TEMP/nexttrace-mtr-columns.exe"
- name: MTR session recording and replay PTY smoke
if: ${{ matrix.os != 'windows-latest' }}
shell: bash
run: |
for flavor in full tiny ntr; do
binary="${RUNNER_TEMP}/nexttrace-mtr-session-${flavor}"
tags=()
if [[ "${flavor}" != full ]]; then
tags=(-tags "flavor_${flavor}")
fi
go build -buildvcs=false "${tags[@]}" -o "${binary}" .
sudo python3 scripts/test_mtr_session_pty.py "${binary}"
done
- name: MTR session recording and replay ConPTY smoke
if: ${{ matrix.os == 'windows-latest' }}
shell: pwsh
run: |
foreach ($flavor in @("full", "tiny", "ntr")) {
$binary = "$env:RUNNER_TEMP/nexttrace-mtr-session-$flavor.exe"
$buildArgs = @("build", "-buildvcs=false", "-o", $binary)
if ($flavor -ne "full") {
$buildArgs += @("-tags", "flavor_$flavor")
}
go @buildArgs .
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
python scripts/test_mtr_session_pty.py $binary
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
}
- name: Test with windows
if: ${{ matrix.os == 'windows-latest' }}
run: go test -v -covermode=count -coverprofile="coverage.out" ./...
- name: Test tiny flavor with windows
if: ${{ matrix.os == 'windows-latest' }}
run: go test -tags flavor_tiny ./cmd ./server
- name: Test ntr flavor with windows
if: ${{ matrix.os == 'windows-latest' }}
run: go test -tags flavor_ntr ./cmd ./server
test-nojsonv2:
name: JSON compatibility (nojsonv2)
runs-on: ubuntu-latest
env:
GOTOOLCHAIN: go1.27.1
GOEXPERIMENT: nojsonv2
steps:
- name: Checkout codebase
uses: actions/checkout@v7
- name: Set up Go (built-in cache)
uses: actions/setup-go@v7
with:
go-version: '1.27.1'
check-latest: true
cache: true
- name: Test with legacy JSON implementation
run: |
go test ./...
go test -tags flavor_tiny ./cmd ./server
go test -tags flavor_ntr ./cmd ./server
race:
name: Race detector (Ubuntu)
runs-on: ubuntu-latest
env:
GOTOOLCHAIN: go1.27.1
steps:
- name: Checkout codebase
uses: actions/checkout@v7
- name: Set up Go (built-in cache)
uses: actions/setup-go@v7
with:
go-version: '1.27.1'
check-latest: true
cache: true
- name: Run race detector
run: go test -race -count=1 ./...