diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 75b4819..d7228dd 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -10,20 +10,44 @@ on: types: [ opened, synchronize, reopened ] branches: - master - env: CARGO_TERM_COLOR: always jobs: - - tests: - name: Run tests with coverage + test: + name: test ${{ matrix.rust }} ${{ matrix.flags }} runs-on: ubuntu-latest + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + rust: [ "stable", "beta", "nightly", "1.65" ] # MSRV + flags: [ "--no-default-features", "", "--all-features" ] + exclude: + # Skip because some features have highest MSRV. + - rust: "1.65" # MSRV + flags: "--all-features" + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.rust }} + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + # Only run tests on the latest stable and above + - name: check + if: ${{ matrix.rust == '1.65' }} # MSRV + run: cargo check --workspace ${{ matrix.flags }} + - name: test + if: ${{ matrix.rust != '1.65' }} # MSRV + run: cargo test --workspace ${{ matrix.flags }} + coverage: + name: Code Coverage + runs-on: ubuntu-latest env: - CARGO_TERM_COLOR: always LLVMCOV_VERSION: 0.5.14 - steps: - name: Checkout repository uses: actions/checkout@v3 @@ -39,25 +63,87 @@ jobs: - name: Cache rust dependencies uses: Swatinem/rust-cache@v2 with: - shared-key: rust-cache-hyper-server-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}-${{ env.LLVMCOV_VERSION }} + shared-key: rust-cache-hyper-server-coverage-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}-${{ env.LLVMCOV_VERSION }} - name: Install cargo-llvm-cov run: cargo install cargo-llvm-cov --version=${{ env.LLVMCOV_VERSION }} --locked - - name: Check Formatting - run: cargo fmt --all -- --check - - - name: Check With Clippy - run: cargo clippy --all --all-targets --all-features -- -D warnings - - name: Generate code coverage run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info - env: - APP_RPC__URI: http://127.0.0.1:8545 - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos files: lcov.info - fail_ci_if_error: false \ No newline at end of file + fail_ci_if_error: false + +# TODO(Miri presently has errors/detects undefined behavior in the codebase) +# We should fix this and then enable. +# miri: +# name: miri ${{ matrix.flags }} +# runs-on: ubuntu-latest +# timeout-minutes: 30 +# strategy: +# fail-fast: false +# matrix: +# flags: [ "--no-default-features", "", "--all-features" ] +# env: +# MIRIFLAGS: -Zmiri-strict-provenance +# steps: +# - uses: actions/checkout@v3 +# - uses: dtolnay/rust-toolchain@miri +# - uses: Swatinem/rust-cache@v2 +# with: +# cache-on-failure: true +# - run: cargo miri setup ${{ matrix.flags }} +# - run: cargo miri test ${{ matrix.flags }} + + feature-checks: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + - uses: taiki-e/install-action@cargo-hack + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + - name: cargo hack + run: cargo hack check --feature-powerset --depth 2 + + clippy: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@clippy + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + - run: cargo clippy --workspace --all-targets --all-features + env: + RUSTFLAGS: -Dwarnings + + docs: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@nightly + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + - run: cargo doc --workspace --all-features --no-deps --document-private-items + env: + RUSTDOCFLAGS: "--cfg docsrs -D warnings" + + fmt: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@nightly + with: + components: rustfmt + - run: cargo fmt --all --check \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 3bb5bfe..f017098 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,25 +17,25 @@ tls-rustls = ["arc-swap", "pin-project-lite", "rustls", "rustls-pemfile", "tokio tls-openssl = ["openssl", "tokio-openssl", "pin-project-lite"] [dependencies] + +# optional dependencies +## rustls +arc-swap = { version = "1", optional = true } bytes = "1" futures-util = { version = "0.3", default-features = false, features = ["alloc"] } http = "0.2" http-body = "0.4" hyper = { version = "0.14.27", features = ["http1", "http2", "server", "runtime"] } -tokio = { version = "1", features = ["macros", "net", "sync"] } -tower-service = "0.3" -# optional dependencies -## rustls -arc-swap = { version = "1", optional = true } +## openssl +openssl = { version = "0.10", optional = true } pin-project-lite = { version = "0.2", optional = true } rustls = { version = "0.21", features = ["dangerous_configuration"], optional = true } rustls-pemfile = { version = "1", optional = true } -tokio-rustls = { version = "0.24", optional = true } - -## openssl -openssl = { version = "0.10", optional = true } +tokio = { version = "1", features = ["macros", "net", "sync"] } tokio-openssl = { version = "0.6", optional = true } +tokio-rustls = { version = "0.24", optional = true } +tower-service = "0.3" [dev-dependencies] axum = "0.6" diff --git a/README.md b/README.md index 910d29c..6b4c4a9 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ You can find more examples [here](/examples). ## Minimum Supported Rust Version -axum-server's MSRV is `1.49`. +axum-server's MSRV is `1.65`. ## Safety