name: CI
on:
push:
branches: [main]
paths:
- "**/*.rs"
- "Cargo.toml"
- "Cargo.lock"
- ".github/workflows/ci.yml"
- "rust-toolchain.toml"
- "justfile"
pull_request:
paths:
- "**/*.rs"
- "Cargo.toml"
- "Cargo.lock"
- "CHANGELOG.md"
- ".github/workflows/ci.yml"
- "rust-toolchain.toml"
- "justfile"
merge_group:
env:
CARGO_TERM_COLOR: always
jobs:
format:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rustup show
- uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- run: cargo fmt --check
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: sudo apt-get update && sudo apt-get install -y libdbus-1-dev
- run: rustup show
- uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- run: cargo clippy --all-targets --all-features -- -D warnings
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: sudo apt-get update && sudo apt-get install -y libdbus-1-dev
- run: rustup show
- uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- run: cargo check --all-targets --all-features
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: sudo apt-get update && sudo apt-get install -y libdbus-1-dev
- run: rustup show
- uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- run: cargo test
changelog:
name: Changelog
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check CHANGELOG.md was updated
run: |
if git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -q '^CHANGELOG.md$'; then
echo "CHANGELOG.md updated"
else
echo "::error::CHANGELOG.md was not updated. Please add an entry under [Unreleased]."
exit 1
fi