fix(ci): fix flaky test timeout and remove unsupported windows/386 build #85
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Go Build and Test | |
| on: | |
| push: | |
| branches: [ main ] | |
| paths: | |
| - '**.go' | |
| - 'go.mod' | |
| - 'go.sum' | |
| - 'Makefile' | |
| - '.github/workflows/go_build_test.yml' | |
| - 'examples/scripts/**' | |
| - 'internal/e2e/testdata/scripts/**' | |
| pull_request: | |
| branches: [ main ] | |
| paths: | |
| - '**.go' | |
| - 'go.mod' | |
| - 'go.sum' | |
| - 'Makefile' | |
| - '.github/workflows/go_build_test.yml' | |
| - 'examples/scripts/**' | |
| - 'internal/e2e/testdata/scripts/**' | |
| jobs: | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.22.x' | |
| cache: true | |
| - name: Run go fmt | |
| run: | | |
| if [ -n "$(gofmt -l .)" ]; then | |
| echo "Go code is not formatted:" | |
| gofmt -d . | |
| exit 1 | |
| fi | |
| - name: Create placeholder _web directories | |
| run: | | |
| mkdir -p cmd/network-debugger-web/_web cmd/wsapp/_web | |
| touch cmd/network-debugger-web/_web/.gitkeep cmd/wsapp/_web/.gitkeep | |
| - name: Run go vet | |
| run: | | |
| PACKAGES=$(go list ./... | grep -v -E "(internal/integration|internal/e2e)") | |
| go vet $PACKAGES | |
| test: | |
| name: Test | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| go-version: ['1.22.x'] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ matrix.go-version }} | |
| cache: true | |
| - name: Download dependencies | |
| run: go mod download | |
| - name: Verify dependencies | |
| run: go mod verify | |
| - name: Create placeholder _web directories | |
| shell: bash | |
| run: | | |
| mkdir -p cmd/network-debugger-web/_web cmd/wsapp/_web | |
| touch cmd/network-debugger-web/_web/.gitkeep cmd/wsapp/_web/.gitkeep | |
| - name: Run tests (exclude integration/e2e for race detector) | |
| shell: bash | |
| run: | | |
| # Run tests with race detector, excluding integration and e2e tests which have pre-existing race conditions | |
| # Use -short flag to skip long-running load/stress tests | |
| PACKAGES=$(go list ./... | grep -v -E "(internal/integration|internal/e2e)") | |
| echo "Testing packages: $PACKAGES" | |
| go test -short -race -coverprofile=coverage.out $PACKAGES | |
| - name: Upload coverage to codecov (ubuntu only) | |
| if: matrix.os == 'ubuntu-latest' | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| file: ./coverage.out | |
| flags: unittests | |
| fail_ci_if_error: false | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| build: | |
| name: Build Binaries | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| go-version: ['1.22.x'] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ matrix.go-version }} | |
| cache: true | |
| - name: Create placeholder _web directories | |
| shell: bash | |
| run: | | |
| mkdir -p cmd/network-debugger-web/_web cmd/wsapp/_web | |
| touch cmd/network-debugger-web/_web/.gitkeep cmd/wsapp/_web/.gitkeep | |
| - name: Build network-debugger | |
| run: | | |
| cd cmd/network-debugger | |
| go build -v -ldflags "-s -w" -o ../../bin/network-debugger${{ matrix.os == 'windows-latest' && '.exe' || '' }} | |
| - name: Test binary execution (smoke test) | |
| shell: bash | |
| run: | | |
| # Start the binary in the background | |
| ./bin/network-debugger${{ matrix.os == 'windows-latest' && '.exe' || '' }} & | |
| BINARY_PID=$! | |
| # Wait a bit for startup | |
| sleep 3 | |
| # Kill the process | |
| kill $BINARY_PID || true | |
| echo "Binary smoke test passed" | |
| env: | |
| ADDR: :19999 | |
| DEV_MODE: "1" | |
| timeout-minutes: 1 | |
| cross-compile: | |
| name: Cross-Compile Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.22.x' | |
| cache: true | |
| - name: Create placeholder _web directories | |
| run: | | |
| mkdir -p cmd/network-debugger-web/_web cmd/wsapp/_web | |
| touch cmd/network-debugger-web/_web/.gitkeep cmd/wsapp/_web/.gitkeep | |
| - name: Cross-compile for all platforms | |
| run: make build-cross | |
| - name: Verify binaries exist | |
| run: | | |
| ls -lh bin/ | |
| # Verify all expected binaries were created | |
| test -f bin/network-debugger_darwin_amd64 | |
| test -f bin/network-debugger_darwin_arm64 | |
| test -f bin/network-debugger_linux_amd64 | |
| test -f bin/network-debugger_linux_arm64 | |
| test -f bin/network-debugger_windows_amd64.exe | |
| test -f bin/network-debugger_windows_386.exe | |
| test -f bin/network-debugger_windows_arm64.exe | |
| echo "All binaries successfully built" | |
| integration: | |
| name: Integration Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.22.x' | |
| cache: true | |
| - name: Create placeholder _web directories | |
| run: | | |
| mkdir -p cmd/network-debugger-web/_web cmd/wsapp/_web | |
| touch cmd/network-debugger-web/_web/.gitkeep cmd/wsapp/_web/.gitkeep | |
| - name: Cache WASM test fixtures | |
| id: wasm-cache | |
| uses: actions/cache@v3 | |
| with: | |
| path: internal/e2e/testdata/scripts/wasm | |
| key: wasm-fixtures-${{ hashFiles('examples/scripts/**', 'internal/e2e/testdata/scripts/wasm-src/**') }} | |
| restore-keys: | | |
| wasm-fixtures- | |
| - name: Setup Rust (only if WASM cache miss) | |
| if: steps.wasm-cache.outputs.cache-hit != 'true' | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| toolchain: stable | |
| target: wasm32-unknown-unknown | |
| - name: Build WASM test fixtures (if cache miss) | |
| if: steps.wasm-cache.outputs.cache-hit != 'true' | |
| run: | | |
| chmod +x scripts/build_test_wasm.sh | |
| ./scripts/build_test_wasm.sh | |
| - name: Run integration tests | |
| run: go test -v ./internal/integration | |
| timeout-minutes: 5 | |
| - name: Run e2e tests (including Scripting API) | |
| run: go test -v ./internal/e2e | |
| env: | |
| E2E_TIMEOUT_SECONDS: 600 | |
| timeout-minutes: 12 |