Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
with:
components: rustfmt
- name: cargo fmt
run: cargo fmt --check
run: cargo fmt --all --check

clippy:
name: Clippy
Expand All @@ -50,13 +50,17 @@ jobs:
- uses: Swatinem/rust-cache@v2
- name: cargo clippy
# --all-targets lints the test code as well.
run: cargo clippy --locked --all-targets -- -D warnings
run: cargo clippy --locked --workspace --all-targets -- -D warnings

test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Start MySQL and Redis
# Started before the toolchain so the containers initialise meanwhile.
# test-utils connects with defaults that match compose.yaml.
run: docker compose up --detach --wait database redis
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@v2
Expand All @@ -65,10 +69,13 @@ jobs:
- name: cargo nextest
# insta detects CI and fails on any snapshot mismatch instead of
# writing a new snapshot.
run: cargo nextest run --locked --all-targets
run: cargo nextest run --locked --workspace --all-targets
- name: doctests
# nextest does not run doctests.
run: cargo test --locked --doc
run: cargo test --locked --workspace --doc
- name: Service logs
if: failure()
run: docker compose logs database redis

cargo-deny:
name: cargo-deny check ${{ matrix.checks }}
Expand Down
145 changes: 139 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,12 @@ icu_collator = "2.3.1"
icu_locale_core = "2.3.0"

[dev-dependencies]
insta = "1.48.0"
insta = { version = "1.48.0", features = ["json"] }
proptest = "1.11.0"
sha2 = "0.10.9"
test-utils = { path = "test-utils" }

# test-utils is a separate crate so integration tests share one harness; it
# depends on this crate, which only uses it as a dev-dependency.
[workspace]
members = [".", "test-utils"]
22 changes: 20 additions & 2 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
version: '3'

# Local services for development and for the integration tests.
#
# Images follow production (website_k8s: verseghy-website/mysql and
# verseghy-website/backend2-redis). The integration tests connect to these
# ports as root by default; see docs/testing.md.
services:
database:
image: docker.io/mysql:8
Expand All @@ -8,8 +11,18 @@ services:
- "MYSQL_USER=backend"
- "MYSQL_PASSWORD=password"
- "MYSQL_ROOT_PASSWORD=secret"
# Every integration test opens its own small connection pool, and many run
# in parallel.
command: ["--max-connections=500"]
ports:
- "33061:3306"
healthcheck:
# Ping over TCP: during first-time initialisation the image runs a
# temporary server without networking, which would answer a socket ping.
test: ["CMD", "mysqladmin", "ping", "--host=127.0.0.1", "--user=root", "--password=secret"]
interval: 2s
timeout: 5s
retries: 60
redis:
image: docker.io/redis:6.2-alpine
environment:
Expand All @@ -18,3 +31,8 @@ services:
- "6379:6379"
command:
- "redis-server"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 2s
timeout: 5s
retries: 30
Loading