mirror of
https://github.com/nxtrace/NTrace-core.git
synced 2026-11-30 08:28:01 +00:00
- 同步模块、CI 和构建工具链版本,按对照提交选择性能测试工具链 - 移除 nojsonv2 发布配置、PGO 专用配置与旧实现测试分支 - 更新 JSON 性能复测证据、发布决策和构建说明
370 lines
12 KiB
YAML
370 lines
12 KiB
YAML
name: Test
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- "**/*.go"
|
|
- "**/testdata/**"
|
|
- ".cross_compile.sh"
|
|
- ".github/ci-paths.json"
|
|
- ".github/workflows/test.yml"
|
|
- "assets/windivert/**"
|
|
- "cmd/cmd*.go"
|
|
- "cmd/dns*.go"
|
|
- "cmd/doctor*.go"
|
|
- "cmd/flavor*.go"
|
|
- "cmd/fwmark*.go"
|
|
- "cmd/mtr*.go"
|
|
- "cmd/mtr_json_run*.go"
|
|
- "cmd/mtr_mode*.go"
|
|
- "cmd/tos*.go"
|
|
- "cmd/trace_mode*.go"
|
|
- "config/**/*.go"
|
|
- "config/**/testdata/**"
|
|
- "default.pgo"
|
|
- "dn42/**/*.go"
|
|
- "dn42/**/testdata/**"
|
|
- "go.mod"
|
|
- "go.sum"
|
|
- "internal/dnsclient/**/*.go"
|
|
- "internal/dnsclient/**/testdata/**"
|
|
- "internal/doctor/**/*.go"
|
|
- "internal/doctor/**/testdata/**"
|
|
- "internal/hoprender/**/*.go"
|
|
- "internal/hoprender/**/testdata/**"
|
|
- "internal/mtrsession/**/*.go"
|
|
- "internal/mtrsession/**/testdata/**"
|
|
- "internal/routeprobe/**/*.go"
|
|
- "internal/routeprobe/**/testdata/**"
|
|
- "ipgeo/**/*.go"
|
|
- "ipgeo/**/testdata/**"
|
|
- "main.go"
|
|
- "nt_install.sh"
|
|
- "pow/**/*.go"
|
|
- "pow/**/testdata/**"
|
|
- "printer/**/*.go"
|
|
- "printer/**/testdata/**"
|
|
- "scripts/ci/**"
|
|
- "scripts/mtr_pty_screen.py"
|
|
- "scripts/perf/*.sh"
|
|
- "scripts/test_mtr*_pty.py"
|
|
- "scripts/test_nt_install.sh"
|
|
- "server/web/**"
|
|
- "trace/**/*.go"
|
|
- "trace/**/testdata/**"
|
|
- "util/**/*.go"
|
|
- "util/**/testdata/**"
|
|
- "wshandle/**/*.go"
|
|
- "wshandle/**/testdata/**"
|
|
pull_request:
|
|
types: [opened, synchronize, reopened]
|
|
paths:
|
|
- "**/*.go"
|
|
- "**/testdata/**"
|
|
- ".cross_compile.sh"
|
|
- ".github/ci-paths.json"
|
|
- ".github/workflows/test.yml"
|
|
- "assets/windivert/**"
|
|
- "cmd/cmd*.go"
|
|
- "cmd/dns*.go"
|
|
- "cmd/doctor*.go"
|
|
- "cmd/flavor*.go"
|
|
- "cmd/fwmark*.go"
|
|
- "cmd/mtr*.go"
|
|
- "cmd/mtr_json_run*.go"
|
|
- "cmd/mtr_mode*.go"
|
|
- "cmd/tos*.go"
|
|
- "cmd/trace_mode*.go"
|
|
- "config/**/*.go"
|
|
- "config/**/testdata/**"
|
|
- "default.pgo"
|
|
- "dn42/**/*.go"
|
|
- "dn42/**/testdata/**"
|
|
- "go.mod"
|
|
- "go.sum"
|
|
- "internal/dnsclient/**/*.go"
|
|
- "internal/dnsclient/**/testdata/**"
|
|
- "internal/doctor/**/*.go"
|
|
- "internal/doctor/**/testdata/**"
|
|
- "internal/hoprender/**/*.go"
|
|
- "internal/hoprender/**/testdata/**"
|
|
- "internal/mtrsession/**/*.go"
|
|
- "internal/mtrsession/**/testdata/**"
|
|
- "internal/routeprobe/**/*.go"
|
|
- "internal/routeprobe/**/testdata/**"
|
|
- "ipgeo/**/*.go"
|
|
- "ipgeo/**/testdata/**"
|
|
- "main.go"
|
|
- "nt_install.sh"
|
|
- "pow/**/*.go"
|
|
- "pow/**/testdata/**"
|
|
- "printer/**/*.go"
|
|
- "printer/**/testdata/**"
|
|
- "scripts/ci/**"
|
|
- "scripts/mtr_pty_screen.py"
|
|
- "scripts/perf/*.sh"
|
|
- "scripts/test_mtr*_pty.py"
|
|
- "scripts/test_nt_install.sh"
|
|
- "server/web/**"
|
|
- "trace/**/*.go"
|
|
- "trace/**/testdata/**"
|
|
- "util/**/*.go"
|
|
- "util/**/testdata/**"
|
|
- "wshandle/**/*.go"
|
|
- "wshandle/**/testdata/**"
|
|
|
|
jobs:
|
|
changes:
|
|
name: Select relevant checks
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
go: ${{ steps.select.outputs.go }}
|
|
pty: ${{ steps.select.outputs.pty }}
|
|
doctor: ${{ steps.select.outputs.doctor }}
|
|
dns: ${{ steps.select.outputs.dns }}
|
|
install: ${{ steps.select.outputs.install }}
|
|
web: ${{ steps.select.outputs.web }}
|
|
shell: ${{ steps.select.outputs.shell }}
|
|
platforms: ${{ steps.select.outputs.platforms }}
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
with:
|
|
fetch-depth: 0
|
|
persist-credentials: false
|
|
- name: Verify CI selection rules
|
|
run: |
|
|
python3 -m unittest discover -s scripts/ci -p 'test_*.py' -v
|
|
python3 scripts/ci/select_checks.py --check-workflows
|
|
- name: Select checks from complete event diff
|
|
id: select
|
|
run: python3 scripts/ci/select_checks.py
|
|
|
|
test:
|
|
needs: changes
|
|
if: >-
|
|
needs.changes.outputs.go == 'true' || needs.changes.outputs.pty == 'true' ||
|
|
needs.changes.outputs.doctor == 'true' || needs.changes.outputs.dns == 'true' ||
|
|
needs.changes.outputs.install == 'true'
|
|
name: Default JSON (${{ matrix.os }})
|
|
runs-on: ${{ matrix.os }}
|
|
env:
|
|
GOTOOLCHAIN: go1.27.3
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: ${{ fromJSON(needs.changes.outputs.platforms) }}
|
|
steps:
|
|
- name: Checkout codebase
|
|
uses: actions/checkout@v7
|
|
with:
|
|
fetch-depth: 0
|
|
fetch-tags: true
|
|
|
|
- name: Set up Go (built-in cache)
|
|
if: ${{ (needs.changes.outputs.go == 'true' || needs.changes.outputs.pty == 'true' || needs.changes.outputs.doctor == 'true' || needs.changes.outputs.dns == 'true') }}
|
|
uses: actions/setup-go@v7
|
|
with:
|
|
go-version: '1.27.3'
|
|
check-latest: true
|
|
cache: true
|
|
|
|
- name: Test with unix
|
|
if: ${{ needs.changes.outputs.go == 'true' && (matrix.os != 'windows-latest') }}
|
|
shell: bash
|
|
run: go test -v -covermode=count -coverprofile='coverage.out' ./...
|
|
|
|
- name: Test alternate flavors with unix
|
|
if: ${{ needs.changes.outputs.go == 'true' && (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
|
|
if: ${{ needs.changes.outputs.doctor == 'true' }}
|
|
env:
|
|
NEXTTRACE_DOCTOR_INTEGRATION: '1'
|
|
run: go test ./internal/doctor -run '^TestNativeLoopbackRoute$' -count=1
|
|
|
|
- name: Doctor privileged backend smoke
|
|
if: ${{ needs.changes.outputs.doctor == 'true' && (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: ${{ needs.changes.outputs.dns == 'true' && (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: ${{ needs.changes.outputs.install == 'true' && (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: ${{ needs.changes.outputs.go == 'true' && (matrix.os == 'ubuntu-latest') }}
|
|
shell: bash
|
|
run: |
|
|
go mod verify
|
|
go mod tidy -diff
|
|
|
|
- name: Run go vet
|
|
if: ${{ needs.changes.outputs.go == 'true' && (matrix.os == 'ubuntu-latest') }}
|
|
run: go vet ./...
|
|
|
|
- name: Build all flavors on Linux
|
|
if: ${{ needs.changes.outputs.go == 'true' && (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: ${{ needs.changes.outputs.pty == 'true' && (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: ${{ needs.changes.outputs.pty == 'true' && (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: ${{ needs.changes.outputs.pty == 'true' && (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}"
|
|
sudo python3 scripts/test_mtr_snapshot_pty.py "${binary}"
|
|
done
|
|
|
|
- name: MTR session recording and replay ConPTY smoke
|
|
if: ${{ needs.changes.outputs.pty == 'true' && (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 }
|
|
python scripts/test_mtr_snapshot_pty.py $binary
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
}
|
|
|
|
- name: Test with windows
|
|
if: ${{ needs.changes.outputs.go == 'true' && (matrix.os == 'windows-latest') }}
|
|
run: go test -v -covermode=count -coverprofile="coverage.out" ./...
|
|
|
|
- name: Test tiny flavor with windows
|
|
if: ${{ needs.changes.outputs.go == 'true' && (matrix.os == 'windows-latest') }}
|
|
run: go test -tags flavor_tiny ./cmd ./server
|
|
|
|
- name: Test ntr flavor with windows
|
|
if: ${{ needs.changes.outputs.go == 'true' && (matrix.os == 'windows-latest') }}
|
|
run: go test -tags flavor_ntr ./cmd ./server
|
|
|
|
test-windows-arm64:
|
|
needs: changes
|
|
if: needs.changes.outputs.go == 'true'
|
|
name: Windows ARM64 IPv6 Traffic Class
|
|
runs-on: windows-11-arm
|
|
env:
|
|
GOTOOLCHAIN: go1.27.3
|
|
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.3'
|
|
check-latest: true
|
|
cache: true
|
|
|
|
- name: Test IPv6 Traffic Class callers
|
|
run: go test -v ./trace/internal -run '^(TestSetIPv6TrafficClassSkipsOnlyZeroOnWindows|TestIPv6SendersSkipZeroTrafficClassOnWindows)$' -count=1
|
|
|
|
race:
|
|
needs: changes
|
|
if: needs.changes.outputs.go == 'true'
|
|
name: Race detector (Ubuntu)
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
GOTOOLCHAIN: go1.27.3
|
|
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.3'
|
|
check-latest: true
|
|
cache: true
|
|
|
|
- name: Run race detector
|
|
run: go test -race -count=1 ./...
|
|
|
|
web:
|
|
name: WebUI assets
|
|
needs: changes
|
|
if: needs.changes.outputs.web == 'true'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
with:
|
|
persist-credentials: false
|
|
- run: node --test server/web/assets/*.test.cjs
|
|
|
|
shell:
|
|
name: Shell syntax
|
|
needs: changes
|
|
if: needs.changes.outputs.shell == 'true'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
with:
|
|
persist-credentials: false
|
|
- name: Check shell syntax
|
|
shell: bash
|
|
run: |
|
|
for script in .cross_compile.sh scripts/perf/*.sh; do
|
|
bash -n "${script}"
|
|
done
|