axum/.github/workflows/CI.yml

231 lines
6.2 KiB
YAML
Raw Normal View History

2021-06-12 20:18:21 +02:00
name: CI
env:
CARGO_TERM_COLOR: always
MSRV: '1.66'
2021-06-12 20:18:21 +02:00
on:
push:
branches:
2021-08-07 11:11:29 +02:00
- main
2021-06-12 20:18:21 +02:00
pull_request: {}
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
2023-04-15 17:02:47 +02:00
- uses: taiki-e/install-action@protoc
2023-04-15 09:46:43 +02:00
- uses: dtolnay/rust-toolchain@beta
2021-06-12 20:18:21 +02:00
with:
components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2
2021-06-12 20:18:21 +02:00
- name: Check
2023-04-15 17:02:47 +02:00
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
2021-06-12 20:18:21 +02:00
- name: rustfmt
2023-04-15 17:02:47 +02:00
run: cargo fmt --all --check
2021-06-12 20:18:21 +02:00
check-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
2023-04-15 17:02:47 +02:00
- uses: Swatinem/rust-cache@v2
- name: cargo doc
env:
RUSTDOCFLAGS: "-D rustdoc::all -A rustdoc::private-doc-tests"
run: cargo doc --all-features --no-deps
2021-06-12 20:18:21 +02:00
cargo-hack:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
2023-04-15 17:02:47 +02:00
- uses: taiki-e/install-action@protoc
- uses: dtolnay/rust-toolchain@stable
2023-04-15 17:02:47 +02:00
- uses: Swatinem/rust-cache@v2
2021-06-12 20:18:21 +02:00
- name: Install cargo-hack
run: |
curl -LsSf https://github.com/taiki-e/cargo-hack/releases/latest/download/cargo-hack-x86_64-unknown-linux-gnu.tar.gz | tar xzf - -C ~/.cargo/bin
- name: cargo hack check
run: cargo hack check --each-feature --no-dev-deps --all
cargo-public-api-crates:
runs-on: ubuntu-latest
strategy:
matrix:
crate: [axum, axum-core, axum-extra, axum-macros]
steps:
- uses: actions/checkout@v4
2023-04-15 09:46:43 +02:00
- uses: dtolnay/rust-toolchain@nightly
2023-04-15 17:02:47 +02:00
- uses: Swatinem/rust-cache@v2
- name: Install cargo-public-api-crates
run: |
cargo install --git https://github.com/davidpdrsn/cargo-public-api-crates
- name: cargo public-api-crates check
run: cargo public-api-crates --manifest-path ${{ matrix.crate }}/Cargo.toml check
2021-06-12 20:18:21 +02:00
test-versions:
needs: check
runs-on: ubuntu-latest
strategy:
matrix:
rust: [stable, beta]
2021-06-12 20:18:21 +02:00
steps:
- uses: actions/checkout@v4
2023-04-15 17:02:47 +02:00
- uses: taiki-e/install-action@protoc
2023-04-15 09:46:43 +02:00
- uses: dtolnay/rust-toolchain@master
2021-06-12 20:18:21 +02:00
with:
toolchain: ${{ matrix.rust }}
2023-04-15 17:02:47 +02:00
- uses: Swatinem/rust-cache@v2
2021-06-12 20:18:21 +02:00
- name: Run tests
2023-04-15 17:02:47 +02:00
run: cargo test --workspace --all-features --all-targets
2021-06-12 20:18:21 +02:00
# some examples doesn't support our MSRV so we only test axum itself on our MSRV
test-nightly:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get rust-toolchain version
id: rust-toolchain
run: echo "version=$(cat axum-macros/rust-toolchain)" >> $GITHUB_OUTPUT
2023-04-15 09:46:43 +02:00
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.rust-toolchain.outputs.version }}
2023-04-15 17:02:47 +02:00
- uses: Swatinem/rust-cache@v2
- name: Run nightly tests
working-directory: axum-macros
2023-04-15 17:02:47 +02:00
run: cargo test
# some examples doesn't support our MSRV (such as async-graphql)
# so we only test axum itself on our MSRV
test-msrv:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
2023-04-15 09:46:43 +02:00
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.MSRV }}
- name: "install Rust nightly"
2023-04-15 09:46:43 +02:00
uses: dtolnay/rust-toolchain@nightly
2023-04-15 17:02:47 +02:00
- uses: Swatinem/rust-cache@v2
- name: Select minimal version
run: cargo +nightly update -Z minimal-versions
- name: Fix up Cargo.lock
2023-04-15 17:02:47 +02:00
run: cargo +nightly update -p crc32fast --precise 1.1.1
- name: Run tests
2023-04-15 17:02:47 +02:00
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
2022-01-31 22:46:44 +01:00
# the trybuild tests in axum-macros fail, so just run the doc
# tests
2022-01-31 22:46:44 +01:00
- name: Run axum-macros doc tests
2023-04-15 17:02:47 +02:00
run: >
cargo +${{ env.MSRV }}
test
-p axum-macros
--doc
--all-features
--locked
test-docs:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
2023-04-15 17:02:47 +02:00
- uses: Swatinem/rust-cache@v2
- name: Run doc tests
2023-04-15 17:02:47 +02:00
run: cargo test --all-features --doc
2021-06-12 20:18:21 +02:00
deny-check:
name: cargo-deny check
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.checks == 'advisories' }}
strategy:
matrix:
checks:
- advisories
- bans licenses sources
2021-06-12 20:18:21 +02:00
steps:
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v1
with:
command: check ${{ matrix.checks }}
2024-02-22 09:59:05 +01:00
manifest-path: axum/Cargo.toml
2021-12-12 15:19:30 +01:00
armv5te-unknown-linux-musleabi:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
2021-12-12 15:19:30 +01:00
with:
target: armv5te-unknown-linux-musleabi
2023-04-15 17:02:47 +02:00
- uses: Swatinem/rust-cache@v2
2021-12-12 15:19:30 +01:00
- name: Check
env:
# Clang has native cross-compilation support
CC: clang
2023-04-15 17:02:47 +02:00
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-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
target: wasm32-unknown-unknown
2023-04-15 17:02:47 +02:00
- uses: Swatinem/rust-cache@v2
- name: Check
2023-04-15 17:02:47 +02:00
run: >
cargo
check
--manifest-path ./examples/simple-router-wasm/Cargo.toml
--target wasm32-unknown-unknown
2022-07-26 14:03:35 +02:00
dependencies-are-sorted:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
2023-04-15 09:46:43 +02:00
- uses: dtolnay/rust-toolchain@beta
- uses: Swatinem/rust-cache@v2
- name: Install cargo-sort
run: |
cargo install cargo-sort
# Work around cargo-sort not honoring workspace.exclude
- name: Remove non-crate folder
run: rm -rf examples/async-graphql
- name: Check dependency tables
run: |
cargo sort --workspace --grouped --check
2023-08-08 10:40:57 +02:00
typos:
name: Spell Check with Typos
runs-on: ubuntu-latest
if: github.event_name == 'push' || !github.event.pull_request.draft
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v4
2023-08-08 10:40:57 +02:00
- name: Check the spelling of the files in our repo
uses: crate-ci/typos@v1.20.8