name: CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Test on ${{ matrix.os }} - rust ${{ matrix.rust }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
rust: [stable]
steps:
- uses: actions/checkout@v3
- name: Install Rust ${{ matrix.rust }}
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
components: rustfmt, clippy
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy
- name: Check formatting
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy -- -D warnings
compatibility:
name: MSRV Compatibility
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install minimum supported Rust version
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.85.0
override: true
- name: Check build on minimum Rust version
run: cargo check
integration:
name: Integration with mdBook
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install mdBook
run: cargo install mdbook
- name: Install current crate
run: cargo install --path .
- name: Create test book
run: |
mkdir -p test-book/src
echo '# Test Book' > test-book/src/SUMMARY.md
echo '# Chapter 1' > test-book/src/chapter-1.md
echo '```rust' >> test-book/src/chapter-1.md
echo '{{#source_file!("src/lib.rs")}}' >> test-book/src/chapter-1.md
echo '```' >> test-book/src/chapter-1.md
echo '[preprocessor.include-doc]' > test-book/book.toml
- name: Test with mdBook
run: cd test-book && mdbook build