CI/CD
PolitikTok uses GitHub Actions for continuous integration and documentation deployment.
CI Pipeline
The CI workflow (.github/workflows/ci.yml) runs on every push to any branch and on pull requests targeting main.
Concurrency
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: trueConcurrent runs on the same branch are cancelled, keeping CI fast and avoiding resource waste.
Environment
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-D warnings"All Rust warnings are promoted to errors, ensuring that no warnings are merged into main.
Jobs
1. Format Check (fmt)
cargo fmt --checkVerifies that all Rust code is formatted according to the project's rustfmt configuration. This job runs independently and quickly, providing early feedback.
2. Clippy Lint (clippy)
Runs Clippy separately for each feature flag:
# Server feature
cargo clippy --features server --no-default-features -- -D warnings
# Web feature
cargo clippy --features web --no-default-features -- -D warningsThis catches lint issues in both server-only and client-only code paths. Uses Swatinem/rust-cache@v2 for caching compiled dependencies.
3. Security Audit (audit)
rustsec/audit-check@v2.0.0Runs only on the main branch. Checks all dependencies against the RustSec Advisory Database for known vulnerabilities.
4. Tests (test)
# Server tests
cargo test --features server --no-default-features
# Web tests
cargo test --features web --no-default-featuresRuns after both fmt and clippy pass. Tests are executed separately for server and web features to catch feature-gated compilation issues.
Job Dependency Graph
fmt ──┐
├──> test
clippy ─┘
audit (main branch only, independent)Caching
The Swatinem/rust-cache@v2 action is used in clippy and test jobs to cache:
~/.cargo/registry(crate downloads)~/.cargo/git(git dependencies)target/(compiled artifacts)
This significantly speeds up subsequent CI runs.
Documentation Deployment
The docs workflow (.github/workflows/docs.yml) deploys this documentation site to GitHub Pages.
Triggers
- Push to
mainbranch when files indocs/or the workflow file change - Manual trigger via
workflow_dispatch
Build Process
- Checkout the repository
- Install mdBook v0.4.43
- Build the documentation:
mdbook build docs - Upload the
docs/book/directory as a GitHub Pages artifact
Deployment
The deploy job uses actions/deploy-pages@v4 to publish to the github-pages environment. The concurrency group ensures only one deployment runs at a time (no cancellation of in-progress deployments).
Permissions
permissions:
contents: read
pages: write
id-token: writeRunning CI Locally
You can replicate the CI checks locally before pushing:
# Format check
cargo fmt --check
# Clippy (server)
cargo clippy --features server --no-default-features -- -D warnings
# Clippy (web)
cargo clippy --features web --no-default-features -- -D warnings
# Tests (server)
cargo test --features server --no-default-features
# Tests (web)
cargo test --features web --no-default-features
# Security audit (requires cargo-audit)
cargo install cargo-audit
cargo auditAdding CI Steps
When adding new CI checks:
- Add the job to
.github/workflows/ci.yml. - Consider whether it should block merging (
needsdependency) or run independently. - Use
Swatinem/rust-cache@v2for any job that compiles Rust code. - Use the same feature flag separation (
--features server/--features web) to match the project's build targets.