Skip to content

Commit

Permalink
Merge pull request #7 from plabayo/patch/more-ci-checks
Browse files Browse the repository at this point in the history
add more CI checks, sync the existing ones and fix deps order
  • Loading branch information
GlenDC authored Jul 24, 2023
2 parents 891c9c7 + bdd1911 commit bea6058
Show file tree
Hide file tree
Showing 10 changed files with 185 additions and 93 deletions.
193 changes: 126 additions & 67 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,91 +1,150 @@
name: CI

env:
CARGO_TERM_COLOR: always
RUST_TOOLCHAIN: nightly-2023-07-08

on:
push:
branches:
- master
- master
pull_request: {}

env:
RUST_TOOLCHAIN: nightly-2023-07-08

jobs:
check-nightly:
# Run `cargo check` first to ensure that the pushed code at least compiles.
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{env.RUST_TOOLCHAIN}}
profile: minimal
override: true
- name: Check
uses: actions-rs/cargo@v1
with:
command: check
args: --workspace --all-features --all-targets
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{env.RUST_TOOLCHAIN}}
override: true
profile: minimal
components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2
- name: check
run: |
cargo check --all --all-targets --all-features
- name: clippy
run: |
cargo clippy --all --all-targets --all-features
- name: rustfmt
run: |
cargo fmt --all -- --check
check-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{env.RUST_TOOLCHAIN}}
profile: minimal
- name: cargo doc
env:
RUSTDOCFLAGS: "-D rustdoc::broken_intra_doc_links"
run: cargo doc --all-features --no-deps
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{env.RUST_TOOLCHAIN}}
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

test:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{env.RUST_TOOLCHAIN}}
override: true
profile: minimal
- uses: Swatinem/rust-cache@v1
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features

test-docs:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{env.RUST_TOOLCHAIN}}
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

test-examples:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{env.RUST_TOOLCHAIN}}
override: true
profile: minimal
- uses: Swatinem/rust-cache@v1
- name: Run doc tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --examples

cargo-hack:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
- name: install cargo-hack
uses: taiki-e/install-action@cargo-hack
- name: cargo hack check
run: cargo hack check --each-feature --no-dev-deps --workspace
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{env.RUST_TOOLCHAIN}}
profile: minimal
- name: install cargo-hack
uses: taiki-e/install-action@cargo-hack
- name: cargo hack check
run: cargo hack check --each-feature --no-dev-deps --workspace

test:
needs: check-nightly
dependencies-are-sorted:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{env.RUST_TOOLCHAIN}}
override: true
profile: minimal
- uses: Swatinem/rust-cache@v2
- name: Install cargo-sort
run: |
cargo install cargo-sort
- name: Check dependency tables
working-directory: .
run: |
cargo sort --workspace --grouped --check
cargo-deny:
needs: check
runs-on: ubuntu-latest
strategy:
# Disable fail-fast. If the test run for a particular Rust version fails,
# don't cancel the other test runs, so that we can determine whether a
# failure only occurs on a particular version.
fail-fast: false
steps:
- uses: actions/checkout@master
- name: "install Rust"
uses: actions-rs/toolchain@v1
with:
toolchain: ${{env.RUST_TOOLCHAIN}}
profile: minimal
override: true
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --workspace --all-features
- uses: actions/checkout@v3
- uses: EmbarkStudios/cargo-deny-action@v1

style:
needs: check-nightly
semver-checks:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{env.RUST_TOOLCHAIN}}
components: rustfmt
profile: minimal
- name: rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Checkout
uses: actions/checkout@v3
- name: Check semver
uses: obi1kenobi/cargo-semver-checks-action@v2
with:
rust-toolchain: ${{env.RUST_TOOLCHAIN}}
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

members = [
"tower-async",
"tower-async-http",
"tower-async-bridge",
"tower-async-http",
"tower-async-layer",
"tower-async-service",
"tower-async-test",
Expand Down
23 changes: 23 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[advisories]
vulnerability = "deny"
unmaintained = "warn"
notice = "warn"
ignore = []

[licenses]
unlicensed = "warn"
allow = []
deny = []
copyleft = "warn"
allow-osi-fsf-free = "either"
confidence-threshold = 0.8

[bans]
multiple-versions = "warn"
highlight = "all"
skip-tree = []

[sources]
unknown-registry = "warn"
unknown-git = "warn"
allow-git = []
14 changes: 7 additions & 7 deletions tower-async-bridge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ full = [
into_async = ["tower/util"]

[dependencies]
tower-service = { version = "0.3" }
tower-layer = { version = "0.3" }
tower = { version = "0.4", optional = true }
tower-async-service = { version = "0.1", path = "../tower-async-service" }
tower-async-layer = { version = "0.1", path = "../tower-async-layer" }
tower-async-service = { version = "0.1", path = "../tower-async-service" }
tower-layer = { version = "0.3" }
tower-service = { version = "0.3" }

[dev-dependencies]
futures-core = "0.3"
hyper = { version = "0.14", features = ["full"] }
pin-project-lite = "0.2"
tokio = { version = "1.11", features = ["macros", "rt-multi-thread"] }
tokio-test = { version = "0.4" }
tokio-test = { version = "0.4" }
tower = { version = "0.4", features = ["full"] }
tower-async = { path = "../tower-async", features = ["full"] }
pin-project-lite = "0.2"
futures-core = "0.3"
hyper = { version = "0.14", features = ["full"] }

[package.metadata.docs.rs]
all-features = true
Expand Down
6 changes: 6 additions & 0 deletions tower-async-http/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.1.3 (July 24, 2023)

## Changed

- update `http-range-header` from `0.3.0` to `0.4.0` and fix range OOB test from reject to accept;

## 0.1.2 (July 20, 2023)

Sync with original `tower-http` codebase from [`0.4.1`](https://github.com/tower-rs/tower-http/releases/tag/tower-http-0.4.1)
Expand Down
18 changes: 9 additions & 9 deletions tower-async-http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description = """
Tower Async middleware and utilities for HTTP clients and servers.
An "Async Trait" fork from the original Tower Library.
"""
version = "0.1.2"
version = "0.1.3"
authors = ["Glen De Cauwsemaecker <glen@plabayo.tech>"]
edition = "2021"
license = "MIT"
Expand All @@ -27,7 +27,8 @@ tower-async-service = { version = "0.1", path = "../tower-async-service" }
# optional dependencies
async-compression = { version = "0.4", optional = true, features = ["tokio"] }
base64 = { version = "0.21", optional = true }
http-range-header = "0.3.0"
http-range-header = "0.4.0"
httpdate = { version = "1.0", optional = true }
iri-string = { version = "0.7.0", optional = true }
mime = { version = "0.3.17", optional = true, default_features = false }
mime_guess = { version = "2", optional = true, default_features = false }
Expand All @@ -36,28 +37,27 @@ tokio = { version = "1.6", optional = true, default_features = false }
tokio-util = { version = "0.7", optional = true, default_features = false, features = ["io"] }
tower-async = { version = "0.1", path = "../tower-async", optional = true }
tracing = { version = "0.1", default_features = false, optional = true }
httpdate = { version = "1.0", optional = true }
uuid = { version = "1.0", features = ["v4"], optional = true }

[dev-dependencies]
axum = { version = "0.6" }
brotli = "3"
bytes = "1"
clap = { version = "4.3", features = ["derive"] }
flate2 = "1.0"
brotli = "3"
futures = "0.3"
hyper = { version = "0.14", features = ["full"] }
axum = { version = "0.6" }
once_cell = "1"
serde_json = "1.0"
tokio = { version = "1", features = ["full"] }
tower = { version = "0.4", features = ["util", "make", "timeout"] }
tower-async = { path = "../tower-async", features = ["full"] }
tower-async-http = { path = ".", features = ["full"] }
tower-async-bridge = { path = "../tower-async-bridge", features = ["full"] }
tower-async-http = { path = ".", features = ["full"] }
tracing = { version = "0.1", default_features = false }
tracing-subscriber = "0.3"
uuid = { version = "1.0", features = ["v4"] }
serde_json = "1.0"
zstd = "0.12"
clap = { version = "4.3", features = ["derive"] }
tracing = { version = "0.1", default_features = false }

[features]
default = []
Expand Down
10 changes: 7 additions & 3 deletions tower-async-http/src/services/fs/serve_dir/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ async fn read_partial_in_bounds() {
}

#[tokio::test]
async fn read_partial_rejects_out_of_bounds_range() {
async fn read_partial_accepts_out_of_bounds_range() {
let svc = ServeDir::new("..");
let bytes_start_incl = 0;
let bytes_end_excl = 9999999;
Expand All @@ -496,11 +496,15 @@ async fn read_partial_rejects_out_of_bounds_range() {
.unwrap();
let res = svc.oneshot(req).await.unwrap();

assert_eq!(res.status(), StatusCode::RANGE_NOT_SATISFIABLE);
assert_eq!(res.status(), StatusCode::PARTIAL_CONTENT);
let file_contents = std::fs::read("../README.md").unwrap();
assert_eq!(
res.headers()["content-range"],
&format!("bytes */{}", file_contents.len())
&format!(
"bytes 0-{}/{}",
file_contents.len() - 1,
file_contents.len()
)
)
}

Expand Down
2 changes: 1 addition & 1 deletion tower-async-layer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ edition = "2021"
[dependencies]

[dev-dependencies]
tower-async-service = { path = "../tower-async-service" }
tower-async = { path = "../tower-async", features = ["util"] }
tower-async-service = { path = "../tower-async-service" }
4 changes: 2 additions & 2 deletions tower-async-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ edition = "2021"
[dependencies]

[dev-dependencies]
futures = "0.3"
http = "0.2"
tower-async-layer = { path = "../tower-async-layer" }
tokio = { version = "1", features = ["macros", "time"] }
futures = "0.3"
tower-async-layer = { path = "../tower-async-layer" }
Loading

0 comments on commit bea6058

Please sign in to comment.