name: CI
on:
push:
branches: [main]
pull_request:
workflow_call:
env:
CARGO_TERM_COLOR: always
jobs:
stable:
name: stable (fmt, clippy, tests)
runs-on: ubuntu-latest
services:
postgres:
image: postgres:18-alpine
env:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: test
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U test"
--health-interval 5s
--health-timeout 5s
--health-retries 10
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
key: stable
- name: JetStream fixture
run: |
docker run -d --name acs-nats -p 4222:4222 \
-v "$PWD/Docker/nats-test.conf:/etc/nats/nats.conf:ro" \
nats:2.12-alpine -js -c /etc/nats/nats.conf
for i in $(seq 1 30); do
docker logs acs-nats 2>&1 | grep -q 'Server is ready' && exit 0
sleep 1
done
echo "the JetStream fixture never became ready"; docker logs acs-nats; exit 1
- name: Format
run: cargo fmt --check
- name: Clippy
run: cargo clippy --all-targets -- -D warnings
- name: Tests
run: cargo test
env:
TEST_DATABASE_URL: postgres://test:test@localhost:5432/test
AI_CREW_SYNC_REQUIRE_DB: "1"
AI_CREW_SYNC_REQUIRE_NATS: "1"
TEST_NATS_URL: nats://127.0.0.1:4222
msrv:
name: MSRV 1.98.1 (build, tests)
runs-on: ubuntu-latest
services:
postgres:
image: postgres:18-alpine
env:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: test
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U test"
--health-interval 5s
--health-timeout 5s
--health-retries 10
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.98.1
- uses: Swatinem/rust-cache@v2
with:
key: msrv
- name: Assert the pin matches Cargo.toml
run: |
declared=$(grep -m1 '^rust-version' Cargo.toml | cut -d'"' -f2)
if [ "$declared" != "1.98.1" ]; then
echo "Cargo.toml declares rust-version = $declared but this job pins 1.98.1."
echo "Update the toolchain here and the MSRV policy in the READMEs."
exit 1
fi
- name: JetStream fixture
run: |
docker run -d --name acs-nats -p 4222:4222 \
-v "$PWD/Docker/nats-test.conf:/etc/nats/nats.conf:ro" \
nats:2.12-alpine -js -c /etc/nats/nats.conf
for i in $(seq 1 30); do
docker logs acs-nats 2>&1 | grep -q 'Server is ready' && exit 0
sleep 1
done
echo "the JetStream fixture never became ready"; docker logs acs-nats; exit 1
- name: Build
run: cargo build --all-targets
- name: Tests
run: cargo test
env:
TEST_DATABASE_URL: postgres://test:test@localhost:5432/test
AI_CREW_SYNC_REQUIRE_DB: "1"
AI_CREW_SYNC_REQUIRE_NATS: "1"
TEST_NATS_URL: nats://127.0.0.1:4222
compose:
name: compose file renders
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Validate
run: |
docker compose --project-directory . -f Docker/docker-compose.yml config -q