5555 # Use GITHUB_WORKSPACE parent directory or current working directory
5656 WORK_DIR="${GITHUB_WORKSPACE:-$(pwd)}"
5757 if [ -d "$WORK_DIR" ]; then
58- sudo chown -R $(whoami):$(whoami) "$WORK_DIR" || true
58+ sudo chown -R ci:ci "$WORK_DIR" || true
59+ fi
60+ # Ensure cargo cache has correct permissions
61+ if [ -d /home/ci/.cargo ]; then
62+ sudo chown -R ci:ci /home/ci/.cargo || true
5963 fi
6064
6165 - uses : actions/checkout@v4
@@ -64,46 +68,69 @@ jobs:
6468 run : |
6569 # Clean up any files left from previous sudo runs
6670 if [ -d target ]; then
67- sudo chown -R $(whoami):$(whoami) target || true
71+ sudo chown -R ci:ci target || true
72+ fi
73+ # Fix cargo registry permissions to enable cache reuse
74+ if [ -d /home/ci/.cargo/registry ]; then
75+ sudo chown -R ci:ci /home/ci/.cargo/registry || true
6876 fi
69- if [ -d ~/.cargo/registry ]; then
70- sudo chown -R $(whoami):$(whoami) ~/.cargo/registry || true
77+ # Ensure git index cache has correct permissions
78+ if [ -d /home/ci/.cargo/git ]; then
79+ sudo chown -R ci:ci /home/ci/.cargo/git || true
7180 fi
7281
73- - name : Install nextest
82+ - name : Setup Rust environment and install nextest
7483 run : |
75- source ~/.cargo/env
84+ # Ensure we're using the ci user's cargo
85+ export PATH="/home/ci/.cargo/bin:$PATH"
86+ export CARGO_HOME="/home/ci/.cargo"
87+ export RUSTUP_HOME="/home/ci/.rustup"
88+
89+ # Install nextest if not already present
7690 if ! command -v cargo-nextest &> /dev/null; then
7791 cargo install cargo-nextest --locked
7892 fi
7993
8094 - name : Build
8195 run : |
82- source ~/.cargo/env
96+ export PATH="/home/ci/.cargo/bin:$PATH"
97+ export CARGO_HOME="/home/ci/.cargo"
98+ export RUSTUP_HOME="/home/ci/.rustup"
99+ # Use incremental compilation for faster builds
100+ export CARGO_INCREMENTAL=1
83101 cargo build --verbose
84102
85103 - name : Run unit tests
86104 run : |
87- source ~/.cargo/env
105+ export PATH="/home/ci/.cargo/bin:$PATH"
106+ export CARGO_HOME="/home/ci/.cargo"
107+ export RUSTUP_HOME="/home/ci/.rustup"
88108 cargo nextest run --profile ci --bins --verbose
89109
90110 - name : Run smoke tests
91111 run : |
92- source ~/.cargo/env
112+ export PATH="/home/ci/.cargo/bin:$PATH"
113+ export CARGO_HOME="/home/ci/.cargo"
114+ export RUSTUP_HOME="/home/ci/.rustup"
93115 cargo nextest run --profile ci --test smoke_test --verbose
94116
95117 - name : Run Linux jail integration tests
96118 run : |
97- source ~/.cargo/env
119+ export PATH="/home/ci/.cargo/bin:$PATH"
120+ export CARGO_HOME="/home/ci/.cargo"
121+ export RUSTUP_HOME="/home/ci/.rustup"
98122 # 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
123+ # Preserve environment for sudo to maintain cargo paths
124+ sudo -E PATH="$PATH" CARGO_HOME="$CARGO_HOME" RUSTUP_HOME="$RUSTUP_HOME" $(which cargo) nextest run --profile ci --test linux_integration --verbose
100125
101126 - name : Run isolated cleanup tests
102127 run : |
103- source ~/.cargo/env
128+ export PATH="/home/ci/.cargo/bin:$PATH"
129+ export CARGO_HOME="/home/ci/.cargo"
130+ export RUSTUP_HOME="/home/ci/.rustup"
104131 # Run only the comprehensive cleanup and sigint tests with the feature flag
105132 # 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
133+ sudo -E PATH="$PATH" CARGO_HOME="$CARGO_HOME" RUSTUP_HOME="$RUSTUP_HOME" $(which cargo) test --test linux_integration --features isolated-cleanup-tests -- test_comprehensive_resource_cleanup test_cleanup_after_sigint
107134
108135 test-weak :
109136 name : Weak Mode Integration Tests (Linux)
0 commit comments