axum/.github/workflows/CI.yml
Georg Semmler d5de3bc7e3
Improve compile errors for unimplemented traits (#1436)
* Improve `debug_handler` to use the correct span for specific bounds

This results in better localised error messages, as they now point
directly to the corresponding argument instead of to the macro itself.

* Improve some error messages behind a `nightly-error-messages` feature
flag

This uses the nightly only `rustc_on_unimplemented` attribute to improve
some error messages when users try to use invalid handler functions.
This should be seen as prove of concept, not as full solution for all
potential error cases.

The underlying feature is currently marked as permanently unstable, but
I'm working on getting this specific attribute (or an attribute with
different name, similar functionality) ready to work on a stable compiler.

* Apply suggestions from code review

Co-authored-by: Jonas Platte <jplatte+git@posteo.de>

* Enable the `nightly-error-messages` feature unconditionally for nightly compilers

* Use a nightly compiler to run the axum-marcos compile fail tests

* update to newer nightly

* Run axum-macros tests on nightly

* tweak compile error hints a bit

* more tweaks

* update test

Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
2022-11-19 12:45:03 +01:00

274 lines
6.8 KiB
YAML

name: CI
env:
CARGO_TERM_COLOR: always
MSRV: '1.60'
on:
push:
branches:
- main
pull_request: {}
jobs:
check:
runs-on: ubuntu-latest
strategy:
matrix:
pwd:
- .
- examples
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
with:
toolchain: beta
override: true
profile: minimal
components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.pwd }}
workspaces: ${{ matrix.pwd }}
- name: Check
working-directory: ${{ matrix.pwd }}
run: |
cargo clippy --all --all-targets --all-features
- name: rustfmt
working-directory: ${{ matrix.pwd }}
run: |
cargo fmt --all -- --check
check-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
- uses: Swatinem/rust-cache@v1
- name: cargo doc
env:
RUSTDOCFLAGS: "-D broken-intra-doc-links"
run: cargo doc --all-features --no-deps
cargo-hack:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
- uses: Swatinem/rust-cache@v1
- 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
test-versions:
needs: check
runs-on: ubuntu-latest
strategy:
matrix:
rust: [stable, beta]
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
override: true
profile: minimal
- uses: Swatinem/rust-cache@v1
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all --all-features --all-targets
test-nightly:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
with:
# same as `axum-macros/rust-toolchain`
toolchain: nightly-2022-11-18
override: true
profile: minimal
- uses: Swatinem/rust-cache@v1
- name: Run nightly tests
working-directory: axum-macros
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@master
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.MSRV }}
override: true
profile: minimal
- name: "install Rust nightly"
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
profile: minimal
- uses: Swatinem/rust-cache@v1
- name: Select minimal versions
uses: actions-rs/cargo@v1
with:
command: update
args: -Z minimal-versions
toolchain: nightly
- name: Fix up Cargo.lock
uses: actions-rs/cargo@v1
with:
command: update
args: -p crc32fast --precise 1.1.1
toolchain: nightly
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: >
-p axum
-p axum-extra
-p axum-core
--all-features
--all-targets
--locked
toolchain: ${{ env.MSRV }}
# 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
uses: actions-rs/cargo@v1
with:
command: test
args: >
-p axum-macros
--doc
--all-features
--locked
toolchain: ${{ env.MSRV }}
test-docs:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
- uses: Swatinem/rust-cache@v1
- name: Run doc tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --doc
deny-check:
name: cargo-deny check
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.checks == 'advisories' }}
strategy:
matrix:
checks:
- advisories
- bans licenses sources
steps:
- uses: actions/checkout@v2
- uses: EmbarkStudios/cargo-deny-action@v1
with:
command: check ${{ matrix.checks }}
arguments: --all-features --manifest-path axum/Cargo.toml
armv5te-unknown-linux-musleabi:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: armv5te-unknown-linux-musleabi
override: true
profile: minimal
- uses: Swatinem/rust-cache@v1
- name: Check
uses: actions-rs/cargo@v1
env:
# Clang has native cross-compilation support
CC: clang
with:
command: check
args: >
--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@master
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: wasm32-unknown-unknown
override: true
profile: minimal
- uses: Swatinem/rust-cache@v1
- name: Check
uses: actions-rs/cargo@v1
with:
command: check
args: >
--manifest-path ./examples/simple-router-wasm/Cargo.toml
--target wasm32-unknown-unknown
dependencies-are-sorted:
runs-on: ubuntu-latest
strategy:
matrix:
pwd:
- .
- examples
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
with:
toolchain: beta
override: true
profile: minimal
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.pwd }}
workspaces: ${{ matrix.pwd }}
- name: Install cargo-sort
run: |
cargo install cargo-sort
- name: Remove non-crate folder
run: rm -rf async-graphql || true
working-directory: ${{ matrix.pwd }}
- name: Check dependency tables
working-directory: ${{ matrix.pwd }}
run: |
cargo sort --workspace --grouped --check