diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 00000000..455d0d32 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,39 @@ +name: CI +on: + pull_request: + push: + branches: + - main + +jobs: + CI: + runs-on: ubuntu-latest + + strategy: + matrix: + toolchain: ['stable', 'nightly'] + + steps: + - uses: actions/checkout@v4 + + - name: Install task command + run: sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin + + - uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.toolchain }} + profile: minimal + override: true + + - name: Cache cargo tools + id: cache_cargo_tools + uses: actions/cache@v3 + with: + key: ${{ runner.os }}-cargo-install + path: ~/.cargo/bin + - name: Install cargo tools + if: ${{ steps.cache_cargo_tools.outputs.cache-hit != 'true' }} + run: cargo install sqlx-cli --no-default-features --features native-tls,postgres + + - name: Run tasks + run: task test check ${{ matrix.toolchain == 'nightly' && 'bench' || '' }} diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml deleted file mode 100644 index 3318f107..00000000 --- a/.github/workflows/check.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: check -on: - pull_request: - push: - branches: - - main - -jobs: - Check: - runs-on: ubuntu-latest - - strategy: - matrix: - rt: ['tokio', 'async-std'] - toolchain: ['stable', 'nightly'] - custom-header: [true, false] - - steps: - - uses: actions/checkout@v4 - - - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.toolchain }} - profile: minimal - override: true - - - name: Check ohkami's buildability - run: cargo check --features rt_${{ matrix.rt }}${{ matrix.custom-header && ',custom-header' || '' }} - - - name: Check ohkami's buildability without default features except fot `utils` - run: cargo check --no-default-features --features utils,rt_${{ matrix.rt }}${{ matrix.custom-header && ',custom-header' || '' }} - - - name: Check ohkami's buildability without default features except fot `testing` - run: cargo check --no-default-features --features testing,rt_${{ matrix.rt }}${{ matrix.custom-header && ',custom-header' || '' }} - - - name: Check ohkami's buildability without default features - run: cargo check --no-default-features --features rt_${{ matrix.rt }}${{ matrix.custom-header && ',custom-header' || '' }} - - - name: Cache cargo tools - id: cache_cargo_tools - uses: actions/cache@v3 - with: - key: ${{ runner.os }}-cargo-install - path: ~/.cargo/bin - - name: Install cargo tools - if: ${{ steps.cache_cargo_tools.outputs.cache-hit != 'true' }} - run: | - cargo install sqlx-cli --no-default-features --features native-tls,postgres - - name: Check examples' buildablity - working-directory: examples - run: | - docker-compose -f ./realworld/docker-compose.yml up -d - cd ./realworld && sqlx migrate run - cargo check diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index f8084f60..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,63 +0,0 @@ -name: test -on: - pull_request: - push: - branches: - - main - -jobs: - Test: - runs-on: ubuntu-latest - - strategy: - matrix: - rt: ['tokio', 'async-std'] - toolchain: ['stable', 'nightly'] - custom-header: [true, false] - - steps: - - uses: actions/checkout@v4 - - - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.toolchain }} - profile: minimal - override: true - - - name: Run ohkami's doc tests - if: matrix.rt == 'tokio' - run: cargo test --doc --features rt_${{ matrix.rt }},DEBUG${{ matrix.custom-header && ',custom-header' || '' }} - - - name: Run ohkami's lib tests - run: cargo test --lib --features rt_${{ matrix.rt }},DEBUG${{ matrix.custom-header && ',custom-header' || '' }} - - - name: Run ohkami's lib tests without default features except fot `utils` - run: cargo test --lib --no-default-features --features utils,rt_${{ matrix.rt }},DEBUG${{ matrix.custom-header && ',custom-header' || '' }} - - - name: Run ohkami's lib tests without default features except fot `testing` - run: cargo test --lib --no-default-features --features testing,rt_${{ matrix.rt }},DEBUG${{ matrix.custom-header && ',custom-header' || '' }} - - - name: Run ohkami's lib tests without default features - run: cargo test --lib --no-default-features --features rt_${{ matrix.rt }},DEBUG${{ matrix.custom-header && ',custom-header' || '' }} - - - name: Run ohkami's benchmark - if: matrix.toolchain == 'nightly' - working-directory: benches - run: cargo bench - - - name: Cache cargo tools - id: cache_cargo_tools - uses: actions/cache@v3 - with: - key: ${{ runner.os }}-cargo-install - path: ~/.cargo/bin - - name: Install cargo tools - if: ${{ steps.cache_cargo_tools.outputs.cache-hit != 'true' }} - run: | - cargo install sqlx-cli --no-default-features --features native-tls,postgres - - name: Run tests of examples - working-directory: examples - run: | - docker-compose -f ./realworld/docker-compose.yml up -d - cd ./realworld && sqlx migrate run - cargo test diff --git a/README.md b/README.md index 91c8f72c..38bd0835 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,7 @@ - *multi runtime* support:`tokio`, `async-std`
- build check status of ohkami - test status of ohkami + build check status of ohkami

@@ -243,7 +242,5 @@ async fn test_my_ohkami() { ## MSRV (Minimum Supported Rust Version) Latest stable. -
- ## License `ohkami` is licensed under MIT LICENSE ([LICENSE-MIT](https://github.com/kana-rus/ohkami/blob/main/LICENSE-MIT) or [https://opensource.org/licenses/MIT](https://opensource.org/licenses/MIT)). diff --git a/Taskfile.yaml b/Taskfile.yaml index 3fae42e0..7979e7b6 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -1,23 +1,93 @@ version: '3' tasks: - test_rt_async-std: + test: + deps: + - test_doc + - test_rt_tokio + - test_rt_tokio_with_custom-header + - test_rt_async-std + - test_rt_async-std_with_custom-header + - test_examples + + check: + deps: + - check_rt_tokio + - check_rt_async-std + + bench: + dir: benches + cmds: + - cargo bench + +#### tests #### + test_doc: + dir: ohkami cmds: - - cargo test --no-default-features --features rt_tokio - - cargo test --no-default-features --features rt_tokio,utils - - cargo test --no-default-features --features rt_tokio,testing - - cargo test --no-default-features --features rt_tokio,utils,testing - - cargo test --no-default-features --features custom-header,rt_tokio - - cargo test --no-default-features --features custom-header,rt_tokio,utils - - cargo test --no-default-features --features custom-header,rt_tokio,testing - - cargo test --no-default-features --features custom-header,rt_tokio,utils,testing + - cargo test --doc --features DEBUG,rt_tokio + - cargo test --doc --features DEBUG,rt_tokio,custom-header + + test_rt_tokio: + dir: ohkami + cmds: + - cargo test --lib --no-default-features --features DEBUG,rt_tokio + - cargo test --lib --no-default-features --features DEBUG,rt_tokio,utils + - cargo test --lib --no-default-features --features DEBUG,rt_tokio,testing + - cargo test --lib --no-default-features --features DEBUG,rt_tokio,utils,testing + test_rt_tokio_with_custom-header: + dir: ohkami + cmds: + - cargo test --lib --no-default-features --features DEBUG,custom-header,rt_tokio + - cargo test --lib --no-default-features --features DEBUG,custom-header,rt_tokio,utils + - cargo test --lib --no-default-features --features DEBUG,custom-header,rt_tokio,testing + - cargo test --lib --no-default-features --features DEBUG,custom-header,rt_tokio,utils,testing + test_rt_async-std: + dir: ohkami + cmds: + - cargo test --lib --no-default-features --features DEBUG,rt_async-std + - cargo test --lib --no-default-features --features DEBUG,rt_async-std,utils + - cargo test --lib --no-default-features --features DEBUG,rt_async-std,testing + - cargo test --lib --no-default-features --features DEBUG,rt_async-std,utils,testing + test_rt_async-std_with_custom-header: + dir: ohkami + cmds: + - cargo test --lib --no-default-features --features DEBUG,custom-header,rt_async-std + - cargo test --lib --no-default-features --features DEBUG,custom-header,rt_async-std,utils + - cargo test --lib --no-default-features --features DEBUG,custom-header,rt_async-std,testing + - cargo test --lib --no-default-features --features DEBUG,custom-header,rt_async-std,utils,testing + + test_examples: + dir: examples + cmds: + - docker compose -f ./realworld/docker-compose.yml up -d + - cd ./realworld && sleep 5 && sqlx migrate run + - cargo test + - docker compose -f ./realworld/docker-compose.yml down + +#### checks #### + # Assure buildability without "DEBUG" feature + + check_rt_tokio: + dir: ohkami + cmds: + - cargo check --lib --no-default-features --features rt_tokio + - cargo check --lib --no-default-features --features rt_tokio,utils + - cargo check --lib --no-default-features --features rt_tokio,testing + - cargo check --lib --no-default-features --features rt_tokio,utils,testing + - cargo check --lib --no-default-features --features custom-header,rt_tokio + - cargo check --lib --no-default-features --features custom-header,rt_tokio,utils + - cargo check --lib --no-default-features --features custom-header,rt_tokio,testing + - cargo check --lib --no-default-features --features custom-header,rt_tokio,utils,testing + + check_rt_async-std: + dir: ohkami cmds: - - cargo test --no-default-features --features rt_async-std - - cargo test --no-default-features --features rt_async-std,utils - - cargo test --no-default-features --features rt_async-std,testing - - cargo test --no-default-features --features rt_async-std,utils,testing - - cargo test --no-default-features --features custom-header,rt_async-std - - cargo test --no-default-features --features custom-header,rt_async-std,utils - - cargo test --no-default-features --features custom-header,rt_async-std,testing - - cargo test --no-default-features --features custom-header,rt_async-std,utils,testing \ No newline at end of file + - cargo check --lib --no-default-features --features rt_async-std + - cargo check --lib --no-default-features --features rt_async-std,utils + - cargo check --lib --no-default-features --features rt_async-std,testing + - cargo check --lib --no-default-features --features rt_async-std,utils,testing + - cargo check --lib --no-default-features --features custom-header,rt_async-std + - cargo check --lib --no-default-features --features custom-header,rt_async-std,utils + - cargo check --lib --no-default-features --features custom-header,rt_async-std,testing + - cargo check --lib --no-default-features --features custom-header,rt_async-std,utils,testing diff --git a/ohkami/Cargo.toml b/ohkami/Cargo.toml index 0bfca8ef..bca85933 100644 --- a/ohkami/Cargo.toml +++ b/ohkami/Cargo.toml @@ -21,7 +21,7 @@ ohkami_macros = { version = "=0.5.1", path = "../ohkami_macros" } tokio = { version = "1", optional = true, features = ["net", "rt", "io-util", "sync"] } async-std = { version = "1", optional = true } byte_reader = { version = "2.0.0", features = ["text"] } -serde = "1.0" +serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" sha1 = { version = "=0.11.0-pre.0", optional = true, default-features = false } sha2 = { version = "=0.11.0-pre.0", default-features = false } @@ -40,7 +40,6 @@ custom-header = ["dep:rustc-hash"] ##### DEBUG ##### DEBUG = [ - "serde/derive", "tokio?/macros", "tokio?/rt-multi-thread", "async-std?/attributes", diff --git a/ohkami/src/response/mod.rs b/ohkami/src/response/mod.rs index 674a4c3e..5080ca92 100644 --- a/ohkami/src/response/mod.rs +++ b/ohkami/src/response/mod.rs @@ -2,7 +2,9 @@ mod status; pub use status::Status; mod headers; -pub use headers::{Headers as ResponseHeaders, Header as ResponseHeader}; +pub use headers::{Headers as ResponseHeaders}; +#[cfg(any(feature="testing", feature="DEBUG"))] +pub use headers::Header as ResponseHeader; mod into_response; pub use into_response::IntoResponse;