@@ -2,9 +2,9 @@ name: Tests
22
33on :
44 push :
5- branches : [main]
5+ branches :
6+ - main
67 pull_request :
7- branches : [main]
88
99env :
1010 CARGO_TERM_COLOR : always
@@ -26,72 +26,89 @@ jobs:
2626 - name : Setup Rust cache
2727 uses : Swatinem/rust-cache@v2
2828
29+ - name : Install nextest
30+ uses : taiki-e/install-action@nextest
31+
2932 - name : Build
3033 run : cargo build --verbose
3134
3235 - name : Run unit tests
33- run : cargo test --bins --verbose
36+ run : cargo nextest run --profile ci --bins --verbose
3437
3538 - name : Run smoke tests
36- run : cargo test --test smoke_test --verbose
39+ run : cargo nextest run --profile ci --test smoke_test --verbose
3740
38- - name : Run macOS integration tests (with sudo)
41+ - name : Run weak mode integration tests
3942 run : |
40- # The tests require root privileges for PF rules on macOS
41- # GitHub Actions provides passwordless sudo on macOS runners
42- # Use -E to preserve environment and full path to cargo
43- sudo -E $(which cargo) test --test macos_integration --verbose
43+ # On macOS, we only support weak mode due to PF limitations
44+ # (PF translation rules cannot match on user/group)
45+ cargo nextest run --profile ci --test weak_integration --verbose
4446
4547 test-linux :
4648 name : Linux Tests
47- runs-on : ubuntu-latest
48- strategy :
49- matrix :
50- rust : [stable]
49+ runs-on : [self-hosted, linux]
5150
5251 steps :
53- - uses : actions/checkout@v4
52+ - name : Fix permissions from previous runs
53+ run : |
54+ # Clean up any files left from previous sudo runs before checkout
55+ # Use GITHUB_WORKSPACE parent directory or current working directory
56+ WORK_DIR="${GITHUB_WORKSPACE:-$(pwd)}"
57+ if [ -d "$WORK_DIR" ]; then
58+ sudo chown -R $(whoami):$(whoami) "$WORK_DIR" || true
59+ fi
5460
55- - name : Install Rust
56- uses : dtolnay/rust-toolchain@stable
57- with :
58- toolchain : ${{ matrix.rust }}
61+ - uses : actions/checkout@v4
5962
60- - name : Setup Rust cache
61- uses : Swatinem/rust-cache@v2
63+ - name : Fix permissions on current directory
64+ run : |
65+ # Clean up any files left from previous sudo runs
66+ if [ -d target ]; then
67+ sudo chown -R $(whoami):$(whoami) target || true
68+ fi
69+ if [ -d ~/.cargo/registry ]; then
70+ sudo chown -R $(whoami):$(whoami) ~/.cargo/registry || true
71+ fi
72+
73+ - name : Install nextest
74+ run : |
75+ source ~/.cargo/env
76+ if ! command -v cargo-nextest &> /dev/null; then
77+ cargo install cargo-nextest --locked
78+ fi
6279
6380 - name : Build
64- run : cargo build --verbose
81+ run : |
82+ source ~/.cargo/env
83+ cargo build --verbose
6584
6685 - name : Run unit tests
67- run : cargo test --bins --verbose
86+ run : |
87+ source ~/.cargo/env
88+ cargo nextest run --profile ci --bins --verbose
6889
6990 - name : Run smoke tests
70- run : cargo test --test smoke_test --verbose
71-
72- - name : Run jail integration tests
73- run : cargo test --test jail_integration --verbose
91+ run : |
92+ source ~/.cargo/env
93+ cargo nextest run --profile ci --test smoke_test --verbose
7494
75- - name : Debug TLS environment
95+ - name : Run Linux jail integration tests
7696 run : |
77- echo "=== Debugging TLS/Certificate Environment ==="
78- chmod +x scripts/debug_tls_env.sh
79- ./scripts/debug_tls_env.sh
80- sudo ./scripts/debug_tls_env.sh
81- echo "=== End TLS Debug ==="
97+ source ~/.cargo/env
98+ # Run all tests without CI workarounds since this is a self-hosted runner
99+ sudo -E $(which cargo) nextest run --profile ci --test linux_integration --verbose
82100
83- - name : Run Linux jail integration tests (with sudo)
101+ - name : Run isolated cleanup tests
84102 run : |
85- # Ensure ip netns support is available
86- sudo ip netns list || true
87- # Run the Linux-specific jail tests with root privileges
88- # Use full path to cargo since sudo doesn't preserve PATH
89- sudo -E $(which cargo) test --test linux_integration --verbose
103+ source ~/.cargo/env
104+ # Run only the comprehensive cleanup and sigint tests with the feature flag
105+ # These tests need to run in isolation from other tests
106+ sudo -E $(which cargo) test --test linux_integration --features isolated-cleanup-tests -- test_comprehensive_resource_cleanup test_cleanup_after_sigint
90107
91108 test-weak :
92109 name : Weak Mode Integration Tests (Linux)
93110 runs-on : ubuntu-latest
94-
111+
95112 steps :
96113 - uses : actions/checkout@v4
97114
@@ -103,15 +120,21 @@ jobs:
103120 - name : Setup Rust cache
104121 uses : Swatinem/rust-cache@v2
105122
123+ - name : Install nextest
124+ uses : taiki-e/install-action@nextest
125+
106126 - name : Build
107127 run : cargo build --verbose
108128
109129 - name : Run weak mode integration tests
110- run : cargo test --test weak_integration --verbose
130+ run : cargo nextest run --profile ci --test weak_integration --verbose
111131
112132 clippy :
113- name : Clippy
114- runs-on : ubuntu-latest
133+ name : Clippy (${{ matrix.os }})
134+ runs-on : ${{ matrix.os }}
135+ strategy :
136+ matrix :
137+ os : [ubuntu-latest, macos-latest]
115138
116139 steps :
117140 - uses : actions/checkout@v4
@@ -126,7 +149,7 @@ jobs:
126149 uses : Swatinem/rust-cache@v2
127150
128151 - name : Run clippy
129- run : cargo clippy -- -D warnings
152+ run : cargo clippy --all-targets -- -D warnings
130153
131154 fmt :
132155 name : Format
0 commit comments