Skip to content

[go] pcap-split tool #1981

[go] pcap-split tool

[go] pcap-split tool #1981

Workflow file for this run

name: 🧭 Go CI
on:
# Run on PRs when Go files change
pull_request:
types: [opened, synchronize, reopened]
paths:
- "**/*.go"
- "cmd/**"
- "internal/**"
- ".github/workflows/go-ci.yml"
- "go.mod"
- "go.sum"
# Run on push to main to update coverage badges
push:
branches:
- main
paths:
- "**/*.go"
- "cmd/**"
- "internal/**"
- ".github/workflows/go-ci.yml"
- "go.mod"
- "go.sum"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
jobs:
lint:
name: "🔍 Lint"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version-file: go.mod
cache: false # lint only runs gofmt — no modules needed
- name: Run make lint-go
run: make lint-go
build:
name: "🔨 Build"
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version-file: go.mod
cache: true
- name: Install system dependencies (libpcap)
run: sudo apt-get update && sudo apt-get install -y libpcap-dev
- name: Download Go modules
run: go mod download
- name: Build binary
# Compile check only; skip embedding the ~30 MB typst binary here (the
# release / image workflows build and verify the embedded form).
run: make build-velocity TYPST_EMBED=0
test-core:
name: "🧪 Test Core"
runs-on: ubuntu-latest
needs: build
timeout-minutes: 45
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version-file: go.mod
cache: true
- name: Download Go modules
run: go mod download
- name: Build web stub for embed
run: ./scripts/ensure-web-stub.sh
- name: Build offline docs stub for embed
run: ./scripts/ensure-docs-stub.sh
- name: Run core tests
run: |
go test -race -tags=pcap -coverprofile=coverage-core.out -covermode=atomic \
./internal/db/... \
./internal/radar/... \
./internal/serialmux/... \
./internal/security/... \
./internal/units/... \
./internal/timeutil/... \
./internal/httputil/... \
./internal/testutil/... \
./internal/fsutil/... \
./internal/monitoring/... \
./internal/ctl/... \
./internal/cmd/device/...
- name: Upload core coverage
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: coverage-core
path: coverage-core.out
test-lidar:
name: "🧪 Test LiDAR"
runs-on: ubuntu-latest
needs: build
timeout-minutes: 45
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
lfs: true
- name: Validate LFS files
run: ./scripts/validate-lfs-files.sh
- name: Setup Go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version-file: go.mod
cache: true
- name: Install system dependencies (libpcap)
run: sudo apt-get update && sudo apt-get install -y libpcap-dev
- name: Download Go modules
run: go mod download
- name: Build web stub for embed
run: ./scripts/ensure-web-stub.sh
- name: Build offline docs stub for embed
run: ./scripts/ensure-docs-stub.sh
- name: Run LiDAR tests
run: |
go test -race -tags=pcap -p 2 -coverprofile=coverage-lidar.out -covermode=atomic \
./internal/lidar/... \
./internal/cmd/root/... \
./internal/cmd/server/... \
./internal/cmd/tune/... \
./cmd/velocity/...
- name: Upload LiDAR coverage
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: coverage-lidar
path: coverage-lidar.out
test-integration:
name: "🧪 Integration Tests"
runs-on: ubuntu-latest
needs: [test-core, test-lidar]
timeout-minutes: 45
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
lfs: true
- name: Validate LFS files
run: ./scripts/validate-lfs-files.sh
- name: Setup Go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version-file: go.mod
cache: true
- name: Install system dependencies (libpcap)
run: sudo apt-get update && sudo apt-get install -y libpcap-dev
- name: Setup pnpm and build web
run: |
corepack enable
corepack prepare pnpm@latest --activate
cd web
pnpm install
pnpm run build
- name: Run API tests
run: |
# Keep PR latency reasonable; race coverage for API lives in nightly-full-ci.yml.
go test -tags=pcap -coverprofile=coverage-api.out -covermode=atomic \
./internal/api/...
- name: Download coverage artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
pattern: coverage-*
path: coverage-artifacts
merge-multiple: true
- name: Merge coverage profiles
run: |
# Combine coverage files from artifacts directory
echo "mode: atomic" > coverage.out
find coverage-artifacts -name "*.out" -type f | while read f; do
if [ -f "$f" ]; then
echo "Merging $f"
tail -n +2 "$f" >> coverage.out
fi
done
# Also check current directory for any direct files
for f in coverage-*.out; do
if [ -f "$f" ]; then
echo "Merging $f"
tail -n +2 "$f" >> coverage.out
fi
done
echo "Combined coverage has $(wc -l < coverage.out) lines"
- name: Upload Go coverage to Codecov
uses: codecov/codecov-action@1e68e06f1dbfde0e4cefc87efeba9e4643565303 # v5.3.2
with:
files: ./coverage.out
flags: go
name: go-coverage
token: ${{ secrets.CODECOV_TOKEN }}