Skip to content

Commit 7798997

Browse files
authored
v0.1.0 (#6)
1 parent 602b253 commit 7798997

33 files changed

Lines changed: 2554 additions & 1855 deletions

.codex/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# See https://github.com/openai/codex/blob/main/docs/config.md
2+
[tools]
3+
web_search = true

.config/nextest.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Nextest configuration file
2+
# https://nexte.st/book/configuration
3+
4+
[profile.default]
5+
# Stop test run after 5 failures
6+
fail-fast = { max-fail = 5 }
7+
8+
# Test output settings
9+
success-output = "never"
10+
status-level = "pass"
11+
12+
# Retry settings
13+
retries = { backoff = "fixed", count = 0 }
14+
15+
# Timeout settings
16+
slow-timeout = { period = "60s", terminate-after = 2 }
17+
18+
[profile.ci]
19+
# CI-specific configuration (inherits from default)
20+
# More verbose output for debugging CI failures
21+
failure-output = "final"
22+
success-output = "never"
23+
status-level = "retry"
24+
25+
# Allow more retries in CI for flaky tests
26+
retries = { backoff = "exponential", count = 2, delay = "1s", max-delay = "10s" }

.github/workflows/tests.yml

Lines changed: 66 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Tests
22

33
on:
44
push:
5-
branches: [main]
5+
branches:
6+
- main
67
pull_request:
7-
branches: [main]
88

99
env:
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

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
target/
2+
3+
# Local Claude Code instructions (not committed to repo)
4+
CLAUDE.local.md

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CLAUDE.md

CLAUDE.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,14 @@ User-facing documentation should be in the README.md file.
3636
Code/testing/contributing documentation should be in the CONTRIBUTING.md file.
3737

3838
When updating any user-facing interface of the tool in a way that breaks compatibility or adds a new feature, update the README.md file.
39+
40+
## Clippy
41+
42+
CI requires the following to pass on both macOS and Linux targets:
43+
44+
```
45+
cargo clippy --all-targets -- -D warnings
46+
```
47+
48+
When the user asks to run clippy and provides the ability to run on both targets, try to run it
49+
on both targets.

CONTRIBUTING.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,18 @@ Run the standard unit tests:
3434
cargo test
3535
```
3636

37-
### Integration Tests (macOS)
37+
### Integration Tests
3838

39-
The integration tests require sudo access to set up PF rules and groups:
39+
#### macOS
4040

41-
```bash
42-
# Run all integration tests (requires sudo)
43-
sudo -E cargo test -- --ignored
41+
On macOS, httpjail runs in weak mode (environment variable-based):
4442

45-
# Run a specific integration test suite
46-
sudo -E cargo test --test jail_integration -- --ignored
43+
```bash
44+
# Run weak mode tests
45+
cargo test --test weak_integration
4746

4847
# Run with output for debugging
49-
sudo -E cargo test -- --ignored --nocapture
48+
cargo test --test weak_integration -- --nocapture
5049
```
5150

5251
### Manual Testing
@@ -71,7 +70,7 @@ sudo ./target/release/httpjail --log-only -- curl http://example.com
7170

7271
- `tests/smoke_test.rs` - Basic CLI tests that don't require network or sudo
7372
- `tests/jail_integration.rs` - Comprehensive integration tests for jail functionality
74-
- `tests/macos_integration.rs` - macOS-specific integration tests using assert_cmd
73+
- `tests/weak_integration.rs` - Weak mode (environment-based) integration tests
7574

7675
## Code Style
7776

0 commit comments

Comments
 (0)