name: CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
- beta
- nightly
features:
- async
- sync
steps:
- uses: actions/checkout@v4
- name: Start Rspamd container
run: |
echo "Starting Rspamd container..."
docker compose up -d rspamd
echo "Waiting for container to start..."
sleep 5
echo "Checking container status..."
docker compose ps
echo "Checking Rspamd logs..."
docker compose logs rspamd | tail -20
echo "Waiting for Rspamd HTTP API to be ready..."
# Use curl from host instead of exec into container
for i in {1..60}; do
if curl -sf http://localhost:11333/ping > /dev/null 2>&1; then
echo "Rspamd is ready!"
break
fi
echo "Attempt $i/60: Waiting for Rspamd..."
sleep 3
done
# Verify Rspamd is responding
if ! curl -sf http://localhost:11333/ping > /dev/null 2>&1; then
echo "ERROR: Rspamd failed to start!"
docker compose logs rspamd
exit 1
fi
echo "Creating test file for File header tests..."
echo "From: test@example.com" > /tmp/test_email.eml
echo "To: user@example.com" >> /tmp/test_email.eml
echo "Subject: Test" >> /tmp/test_email.eml
echo "" >> /tmp/test_email.eml
echo "Test email body" >> /tmp/test_email.eml
echo "Copying test file to container..."
docker cp /tmp/test_email.eml rspamd-test:/tmp/test_email.eml
echo "Test environment ready!"
- name: Install Rust ${{ matrix.rust }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Run tests
run: cargo test --verbose --no-default-features --features ${{ matrix.features }} --no-fail-fast
- name: Run doc tests
run: cargo test --doc --no-default-features --features ${{ matrix.features }}
- name: Stop Rspamd container
if: always()
run: docker compose down
clippy:
name: Clippy
runs-on: ubuntu-latest
strategy:
matrix:
features:
- async
- sync
steps:
- uses: actions/checkout@v4
- name: Start Rspamd container (for test compilation)
run: |
echo "Starting Rspamd container..."
docker compose up -d rspamd
echo "Waiting for Rspamd HTTP API to be ready..."
for i in {1..60}; do
if curl -sf http://localhost:11333/ping > /dev/null 2>&1; then
echo "Rspamd is ready!"
break
fi
echo "Attempt $i/60: Waiting for Rspamd..."
sleep 3
done
if ! curl -sf http://localhost:11333/ping > /dev/null 2>&1; then
echo "ERROR: Rspamd failed to start!"
docker compose logs rspamd
exit 1
fi
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Run clippy
run: cargo clippy --no-default-features --features ${{ matrix.features }} --all-targets -- -D warnings
- name: Stop Rspamd container
if: always()
run: docker compose down
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Run rustfmt
run: cargo fmt -- --check
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
features:
- async
- sync
steps:
- uses: actions/checkout@v4
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Build
run: cargo build --verbose --no-default-features --features ${{ matrix.features }}
- name: Build release
run: cargo build --release --no-default-features --features ${{ matrix.features }}