mirror of
https://github.com/tokio-rs/axum.git
synced 2026-04-23 12:29:40 +00:00
Currently, both cargo deny and our MSRV checks use Cargo.lock file which has unified features and versions across both the axum crates and all the examples. This can hide some issues as usually when someone adds an example, they might use cargo add which will silently update the dependency for the whole repository. Some compilation errors (like axum requiring bytes@1.0 while it uses features from bytes@1.7) will then be hidden. I don't think most users would ever need to use the minimal versions anyway so this is not as severe, but someone might run into compilation errors.
257 lines
7.2 KiB
YAML
257 lines
7.2 KiB
YAML
name: CI
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
MSRV: '1.78'
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- v0.*
|
|
pull_request: {}
|
|
|
|
jobs:
|
|
check:
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- uses: dtolnay/rust-toolchain@beta
|
|
with:
|
|
components: clippy, rustfmt
|
|
- uses: Swatinem/rust-cache@v2
|
|
with:
|
|
save-if: ${{ github.ref == 'refs/heads/main' }}
|
|
- name: Check
|
|
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
|
|
- name: Check
|
|
run: cargo clippy --manifest-path examples/Cargo.toml --workspace --all-targets --all-features -- -D warnings
|
|
- name: rustfmt
|
|
run: cargo fmt --all --check
|
|
|
|
check-docs:
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
- uses: Swatinem/rust-cache@v2
|
|
with:
|
|
save-if: ${{ github.ref == 'refs/heads/main' }}
|
|
- name: cargo doc -p axum-core
|
|
run: cargo doc --package axum-core --all-features --no-deps
|
|
- name: cargo doc -p axum
|
|
run: cargo doc --package axum --all-features --no-deps
|
|
- name: cargo doc -p axum-extra
|
|
run: cargo doc --package axum-extra --all-features --no-deps
|
|
env:
|
|
RUSTDOCFLAGS: "-D rustdoc::all -A rustdoc::private-doc-tests"
|
|
|
|
cargo-hack:
|
|
runs-on: ubuntu-24.04
|
|
env:
|
|
# Fail the build if there are any warnings
|
|
RUSTFLAGS: "-D warnings"
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
- uses: Swatinem/rust-cache@v2
|
|
with:
|
|
save-if: ${{ github.ref == 'refs/heads/main' }}
|
|
- uses: taiki-e/install-action@cargo-hack
|
|
- name: cargo hack check
|
|
run: cargo hack check --each-feature --no-dev-deps --all
|
|
|
|
cargo-public-api-crates:
|
|
runs-on: ubuntu-24.04
|
|
strategy:
|
|
matrix:
|
|
crate: [axum, axum-core, axum-extra, axum-macros]
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- uses: dtolnay/rust-toolchain@nightly
|
|
- uses: Swatinem/rust-cache@v2
|
|
with:
|
|
save-if: ${{ github.ref == 'refs/heads/main' }}
|
|
- name: Install cargo-public-api-crates
|
|
run: |
|
|
cargo install --git https://github.com/jplatte/cargo-public-api-crates
|
|
- name: cargo public-api-crates check
|
|
run: cargo public-api-crates --manifest-path ${{ matrix.crate }}/Cargo.toml check
|
|
|
|
test-versions:
|
|
needs: check
|
|
runs-on: ubuntu-24.04
|
|
strategy:
|
|
matrix:
|
|
rust: [stable, beta]
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- uses: dtolnay/rust-toolchain@master
|
|
with:
|
|
toolchain: ${{ matrix.rust }}
|
|
- uses: Swatinem/rust-cache@v2
|
|
with:
|
|
save-if: ${{ github.ref == 'refs/heads/main' }}
|
|
- name: Run tests
|
|
run: cargo test --workspace --all-features --all-targets
|
|
- name: Test examples
|
|
run: cargo test --manifest-path examples/Cargo.toml --workspace --all-features --all-targets
|
|
|
|
# some examples don't support our MSRV so we only test axum itself on our MSRV
|
|
test-nightly:
|
|
needs: check
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- name: Get rust-toolchain version
|
|
id: rust-toolchain
|
|
run: echo "version=$(cat axum-macros/rust-toolchain)" >> $GITHUB_OUTPUT
|
|
- uses: dtolnay/rust-toolchain@master
|
|
with:
|
|
toolchain: ${{ steps.rust-toolchain.outputs.version }}
|
|
- uses: Swatinem/rust-cache@v2
|
|
with:
|
|
save-if: ${{ github.ref == 'refs/heads/main' }}
|
|
- name: Run nightly tests
|
|
working-directory: axum-macros
|
|
run: cargo test
|
|
|
|
# some examples don't support our MSRV (such as async-graphql)
|
|
# so we only test axum itself on our MSRV
|
|
test-msrv:
|
|
needs: check
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- uses: dtolnay/rust-toolchain@master
|
|
with:
|
|
toolchain: ${{ env.MSRV }}
|
|
- name: "install Rust nightly"
|
|
uses: dtolnay/rust-toolchain@nightly
|
|
- uses: Swatinem/rust-cache@v2
|
|
with:
|
|
save-if: ${{ github.ref == 'refs/heads/main' }}
|
|
- name: Select minimal version
|
|
run: cargo +nightly update -Z minimal-versions
|
|
- name: Fix up Cargo.lock - crc32fast
|
|
run: cargo +nightly update -p crc32fast --precise 1.1.1
|
|
- name: Fix up Cargo.lock - version_check
|
|
run : cargo +nightly update -p version_check@0.1.0 --precise 0.1.4
|
|
- name: Fix up Cargo.lock - lazy_static
|
|
run: cargo +nightly update -p lazy_static --precise 1.1.0
|
|
- name: Run tests
|
|
run: >
|
|
cargo +${{ env.MSRV }}
|
|
test
|
|
-p axum
|
|
-p axum-extra
|
|
-p axum-core
|
|
--all-features
|
|
--locked
|
|
# the compiler errors are different on our MSRV which makes
|
|
# the trybuild tests in axum-macros fail, so just run the doc
|
|
# tests
|
|
- name: Run axum-macros doc tests
|
|
run: >
|
|
cargo +${{ env.MSRV }}
|
|
test
|
|
-p axum-macros
|
|
--doc
|
|
--all-features
|
|
--locked
|
|
|
|
test-docs:
|
|
needs: check
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
- uses: Swatinem/rust-cache@v2
|
|
with:
|
|
save-if: ${{ github.ref == 'refs/heads/main' }}
|
|
- name: Run doc tests
|
|
run: cargo test --all-features --doc
|
|
|
|
deny-check:
|
|
name: cargo-deny check
|
|
runs-on: ubuntu-24.04
|
|
continue-on-error: ${{ matrix.checks == 'advisories' }}
|
|
strategy:
|
|
matrix:
|
|
checks:
|
|
- advisories
|
|
- bans licenses sources
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- uses: EmbarkStudios/cargo-deny-action@v2
|
|
with:
|
|
command: check ${{ matrix.checks }}
|
|
manifest-path: axum/Cargo.toml
|
|
|
|
armv5te-unknown-linux-musleabi:
|
|
needs: check
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
target: armv5te-unknown-linux-musleabi
|
|
- uses: Swatinem/rust-cache@v2
|
|
with:
|
|
save-if: ${{ github.ref == 'refs/heads/main' }}
|
|
- name: Check
|
|
env:
|
|
# Clang has native cross-compilation support
|
|
CC: clang
|
|
run: >
|
|
cargo
|
|
check
|
|
--all-targets
|
|
--all-features
|
|
-p axum
|
|
-p axum-core
|
|
-p axum-extra
|
|
-p axum-macros
|
|
--target armv5te-unknown-linux-musleabi
|
|
|
|
wasm32-unknown-unknown:
|
|
needs: check
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
target: wasm32-unknown-unknown
|
|
- uses: Swatinem/rust-cache@v2
|
|
with:
|
|
save-if: ${{ github.ref == 'refs/heads/main' }}
|
|
- name: Check
|
|
run: >
|
|
cargo
|
|
check
|
|
--manifest-path ./examples/simple-router-wasm/Cargo.toml
|
|
--target wasm32-unknown-unknown
|
|
|
|
dependencies-are-sorted:
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- name: Install cargo-sort
|
|
uses: taiki-e/install-action@v2
|
|
with:
|
|
tool: cargo-sort@2.0.2
|
|
- name: Check dependency tables
|
|
run: |
|
|
cargo-sort --workspace --grouped --check
|
|
|
|
typos:
|
|
name: Spell Check with Typos
|
|
runs-on: ubuntu-24.04
|
|
|
|
steps:
|
|
- name: Checkout Actions Repository
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Check the spelling of the files in our repo
|
|
uses: crate-ci/typos@v1.29.4
|