Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update CI for library #2

Merged
merged 7 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 102 additions & 16 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
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
18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading