name: Test
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
test:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Free Disk Space (Ubuntu)
if: matrix.os == 'ubuntu-latest'
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: false
- name: Install OpenSSL for Windows
if: matrix.os == 'windows-latest'
run: |
vcpkg install openssl:x64-windows-static-md
echo "OPENSSL_DIR=C:/vcpkg/installed/x64-windows-static-md" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "OPENSSL_ROOT_DIR=C:/vcpkg/installed/x64-windows-static-md" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "OPENSSL_INCLUDE_DIR=C:/vcpkg/installed/x64-windows-static-md/include" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "OPENSSL_LIB_DIR=C:/vcpkg/installed/x64-windows-static-md/lib" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "VCPKG_ROOT=C:/vcpkg" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Ensure cargo in PATH (Windows)
if: matrix.os == 'windows-latest'
run: echo "$HOME/.cargo/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Cache cargo registry
uses: actions/cache@v5
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: Cache cargo index
uses: actions/cache@v5
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-index-
- name: Cache cargo build
uses: actions/cache@v5
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-target-
- name: Install SQLx CLI
run: cargo install sqlx-cli --no-default-features --features sqlite
- name: Setup database
run: |
sqlx database setup --source torc-server/migrations
env:
DATABASE_URL: sqlite:db/sqlite/dev.db
- name: Build test binaries (only necessary packages)
run: cargo build --all-features -p torc
env:
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always
- name: Run tests (Windows - limited test set)
if: matrix.os == 'windows-latest'
run: cargo test --all-features --test test_full_workflows test_many_jobs_parameterized -- --test-threads 1
env:
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: 0
OPENSSL_DIR: C:/vcpkg/installed/x64-windows-static-md
OPENSSL_ROOT_DIR: C:/vcpkg/installed/x64-windows-static-md
OPENSSL_INCLUDE_DIR: C:/vcpkg/installed/x64-windows-static-md/include
OPENSSL_LIB_DIR: C:/vcpkg/installed/x64-windows-static-md/lib
VCPKG_ROOT: C:/vcpkg
- name: Run tests (Unix - full test suite)
if: matrix.os != 'windows-latest'
run: cargo test --all-features -- --test-threads 1
env:
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: 0
- name: Clean up build artifacts
if: matrix.os == 'ubuntu-latest'
run: |
echo "Disk space before cleanup:"
df -h .
# Remove intermediate build artifacts but keep binaries
rm -rf target/debug/deps
rm -rf target/debug/incremental
rm -rf target/debug/build
rm -rf target/debug/.fingerprint
rm -rf target/debug/examples
# Clean up the entire cargo registry cache (will be restored next time)
rm -rf ~/.cargo/registry/cache
rm -rf ~/.cargo/registry/index
rm -rf ~/.cargo/git/db
echo "Disk space after cleanup:"
df -h .
- name: Setup Python
if: matrix.os == 'ubuntu-latest'
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Install Python client dependencies
if: matrix.os == 'ubuntu-latest'
run: |
cd python_client
pip install -e .[dev]
- name: Start torc server
if: matrix.os == 'ubuntu-latest'
run: |
export DATABASE_URL=sqlite:db/sqlite/dev.db
./target/debug/torc-server run > server.log 2>&1 &
SERVER_PID=$!
echo "Server started with PID $SERVER_PID"
# Wait for server to be ready
for i in {1..30}; do
if curl -s http://localhost:8080/torc-service/v1/ping > /dev/null 2>&1; then
echo "Server is ready"
break
fi
echo "Waiting for server... ($i/30)"
sleep 1
done
# Show server log if it failed to start
if ! curl -s http://localhost:8080/torc-service/v1/ping > /dev/null 2>&1; then
echo "Server failed to start. Log:"
cat server.log
exit 1
fi
- name: Run Python client tests
if: matrix.os == 'ubuntu-latest'
run: |
cd python_client
pytest tests/ -v
env:
TORC_API_URL: http://localhost:8080/torc-service/v1