From 16495d51c1d4eedf16a3808f42de29305f6d951b Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Wed, 10 Sep 2025 10:56:32 -0500 Subject: [PATCH 1/3] CI: Fix PATH issues by using source for cargo env The previous commit changed from 'source ~/.cargo/env' to manually setting PATH, but sudo doesn't preserve PATH by default. Using source ensures the full environment is properly configured including system paths needed for commands like sysctl. --- .github/workflows/tests.yml | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c1437c5f..f1b6bf02 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -80,10 +80,8 @@ jobs: - name: Setup Rust environment and install nextest run: | - # Ensure we're using the ci user's cargo - export PATH="/home/ci/.cargo/bin:$PATH" - export CARGO_HOME="/home/ci/.cargo" - export RUSTUP_HOME="/home/ci/.rustup" + # Source the cargo environment for the ci user + source /home/ci/.cargo/env # Install nextest if not already present if ! command -v cargo-nextest &> /dev/null; then @@ -92,41 +90,31 @@ jobs: - name: Build run: | - export PATH="/home/ci/.cargo/bin:$PATH" - export CARGO_HOME="/home/ci/.cargo" - export RUSTUP_HOME="/home/ci/.rustup" + source /home/ci/.cargo/env # Use incremental compilation for faster builds export CARGO_INCREMENTAL=1 cargo build --verbose - name: Run unit tests run: | - export PATH="/home/ci/.cargo/bin:$PATH" - export CARGO_HOME="/home/ci/.cargo" - export RUSTUP_HOME="/home/ci/.rustup" + source /home/ci/.cargo/env cargo nextest run --profile ci --bins --verbose - name: Run smoke tests run: | - export PATH="/home/ci/.cargo/bin:$PATH" - export CARGO_HOME="/home/ci/.cargo" - export RUSTUP_HOME="/home/ci/.rustup" + source /home/ci/.cargo/env cargo nextest run --profile ci --test smoke_test --verbose - name: Run Linux jail integration tests run: | - export PATH="/home/ci/.cargo/bin:$PATH" - export CARGO_HOME="/home/ci/.cargo" - export RUSTUP_HOME="/home/ci/.rustup" + source /home/ci/.cargo/env # Run all tests without CI workarounds since this is a self-hosted runner - # Use sudo with env to preserve the full PATH + # Use sudo with env to preserve the full environment sudo env "PATH=$PATH" "CARGO_HOME=$CARGO_HOME" "RUSTUP_HOME=$RUSTUP_HOME" $(which cargo) nextest run --profile ci --test linux_integration --verbose - name: Run isolated cleanup tests run: | - export PATH="/home/ci/.cargo/bin:$PATH" - export CARGO_HOME="/home/ci/.cargo" - export RUSTUP_HOME="/home/ci/.rustup" + source /home/ci/.cargo/env # Run only the comprehensive cleanup and sigint tests with the feature flag # These tests need to run in isolation from other tests sudo env "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 From ebad2c4e6d72af8a0127e6fa82f1e98f5732abb2 Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Wed, 10 Sep 2025 10:59:25 -0500 Subject: [PATCH 2/3] CI: Fix cargo env path with fallback to current user The self-hosted runner doesn't have /home/ci/.cargo/env, so we need to fallback to ~/.cargo/env for the current user. --- .github/workflows/tests.yml | 38 ++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f1b6bf02..eecd01f7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -80,8 +80,12 @@ jobs: - name: Setup Rust environment and install nextest run: | - # Source the cargo environment for the ci user - source /home/ci/.cargo/env + # Source the cargo environment - try ci user first, fallback to current user + if [ -f /home/ci/.cargo/env ]; then + source /home/ci/.cargo/env + else + source ~/.cargo/env + fi # Install nextest if not already present if ! command -v cargo-nextest &> /dev/null; then @@ -90,31 +94,51 @@ jobs: - name: Build run: | - source /home/ci/.cargo/env + if [ -f /home/ci/.cargo/env ]; then + source /home/ci/.cargo/env + else + source ~/.cargo/env + fi # Use incremental compilation for faster builds export CARGO_INCREMENTAL=1 cargo build --verbose - name: Run unit tests run: | - source /home/ci/.cargo/env + if [ -f /home/ci/.cargo/env ]; then + source /home/ci/.cargo/env + else + source ~/.cargo/env + fi cargo nextest run --profile ci --bins --verbose - name: Run smoke tests run: | - source /home/ci/.cargo/env + if [ -f /home/ci/.cargo/env ]; then + source /home/ci/.cargo/env + else + source ~/.cargo/env + fi cargo nextest run --profile ci --test smoke_test --verbose - name: Run Linux jail integration tests run: | - source /home/ci/.cargo/env + if [ -f /home/ci/.cargo/env ]; then + source /home/ci/.cargo/env + else + source ~/.cargo/env + fi # Run all tests without CI workarounds since this is a self-hosted runner # Use sudo with env to preserve the full environment sudo env "PATH=$PATH" "CARGO_HOME=$CARGO_HOME" "RUSTUP_HOME=$RUSTUP_HOME" $(which cargo) nextest run --profile ci --test linux_integration --verbose - name: Run isolated cleanup tests run: | - source /home/ci/.cargo/env + if [ -f /home/ci/.cargo/env ]; then + source /home/ci/.cargo/env + else + source ~/.cargo/env + fi # Run only the comprehensive cleanup and sigint tests with the feature flag # These tests need to run in isolation from other tests sudo env "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 From bb3dfbbde3a58c4f3baf70944d922fd2d5e8b5f9 Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Wed, 10 Sep 2025 11:01:50 -0500 Subject: [PATCH 3/3] CI: Revert to simpler sudo -E approach The explicit PATH passing wasn't working due to sudo's environment restrictions. Reverting to the simpler approach that was working before commit 5c391a1. --- .github/workflows/tests.yml | 42 +++++++------------------------------ 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index eecd01f7..a4aac5bf 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -80,12 +80,7 @@ jobs: - name: Setup Rust environment and install nextest run: | - # Source the cargo environment - try ci user first, fallback to current user - if [ -f /home/ci/.cargo/env ]; then - source /home/ci/.cargo/env - else - source ~/.cargo/env - fi + source ~/.cargo/env # Install nextest if not already present if ! command -v cargo-nextest &> /dev/null; then @@ -94,54 +89,33 @@ jobs: - name: Build run: | - if [ -f /home/ci/.cargo/env ]; then - source /home/ci/.cargo/env - else - source ~/.cargo/env - fi + source ~/.cargo/env # Use incremental compilation for faster builds export CARGO_INCREMENTAL=1 cargo build --verbose - name: Run unit tests run: | - if [ -f /home/ci/.cargo/env ]; then - source /home/ci/.cargo/env - else - source ~/.cargo/env - fi + source ~/.cargo/env cargo nextest run --profile ci --bins --verbose - name: Run smoke tests run: | - if [ -f /home/ci/.cargo/env ]; then - source /home/ci/.cargo/env - else - source ~/.cargo/env - fi + source ~/.cargo/env cargo nextest run --profile ci --test smoke_test --verbose - name: Run Linux jail integration tests run: | - if [ -f /home/ci/.cargo/env ]; then - source /home/ci/.cargo/env - else - source ~/.cargo/env - fi + source ~/.cargo/env # Run all tests without CI workarounds since this is a self-hosted runner - # Use sudo with env to preserve the full environment - sudo env "PATH=$PATH" "CARGO_HOME=$CARGO_HOME" "RUSTUP_HOME=$RUSTUP_HOME" $(which cargo) nextest run --profile ci --test linux_integration --verbose + sudo -E $(which cargo) nextest run --profile ci --test linux_integration --verbose - name: Run isolated cleanup tests run: | - if [ -f /home/ci/.cargo/env ]; then - source /home/ci/.cargo/env - else - source ~/.cargo/env - fi + source ~/.cargo/env # Run only the comprehensive cleanup and sigint tests with the feature flag # These tests need to run in isolation from other tests - sudo env "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 + sudo -E $(which cargo) test --test linux_integration --features isolated-cleanup-tests -- test_comprehensive_resource_cleanup test_cleanup_after_sigint test-weak: name: Weak Mode Integration Tests (Linux)