Skip to content

Commit c42bd0f

Browse files
authored
Merge pull request #42 from oiwn/dev
Dev
2 parents 6a36bdf + 42942ec commit c42bd0f

File tree

7 files changed

+156
-45
lines changed

7 files changed

+156
-45
lines changed

.github/workflows/ci.yml

Lines changed: 147 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,173 @@
1-
on: [pull_request]
1+
name: Continuous Integration
22

3-
name: Continuous integration
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
workflow_dispatch: # Manual trigger
9+
10+
env:
11+
CARGO_TERM_COLOR: always
12+
REDIS_URI: redis://localhost:6379
413

514
jobs:
615
check:
716
name: Check
817
runs-on: ubuntu-latest
918
steps:
10-
- uses: actions/checkout@v2
11-
- uses: actions-rs/toolchain@v1
12-
with:
13-
profile: minimal
14-
toolchain: stable
15-
override: true
16-
- uses: actions-rs/cargo@v1
19+
- uses: actions/checkout@v4
20+
- uses: dtolnay/rust-toolchain@stable
21+
- uses: actions/cache@v3
1722
with:
18-
command: check
23+
path: |
24+
~/.cargo/bin/
25+
~/.cargo/registry/index/
26+
~/.cargo/registry/cache/
27+
~/.cargo/git/db/
28+
target/
29+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
30+
restore-keys: |
31+
${{ runner.os }}-cargo-
32+
33+
- name: Cargo check
34+
run: cargo check --all-features --workspace
1935

2036
test:
2137
name: Test Suite
2238
runs-on: ubuntu-latest
39+
services:
40+
redis:
41+
image: redis
42+
ports:
43+
- 6379:6379
44+
options: >-
45+
--health-cmd "redis-cli ping"
46+
--health-interval 10s
47+
--health-timeout 5s
48+
--health-retries 5
49+
2350
steps:
24-
- uses: actions/checkout@v2
25-
- uses: actions-rs/toolchain@v1
51+
- uses: actions/checkout@v4
52+
- uses: dtolnay/rust-toolchain@stable
53+
- uses: actions/cache@v3
2654
with:
27-
profile: minimal
28-
toolchain: stable
29-
override: true
30-
- uses: actions-rs/cargo@v1
31-
with:
32-
command: test
33-
args: --lib
55+
path: |
56+
~/.cargo/bin/
57+
~/.cargo/registry/index/
58+
~/.cargo/registry/cache/
59+
~/.cargo/git/db/
60+
target/
61+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
62+
63+
- name: Run unit tests
64+
run: cargo test --lib --all-features --workspace
65+
66+
- name: Run integration tests
67+
run: cargo test --test '*' --all-features --workspace
68+
69+
- name: Run doc tests
70+
run: cargo test --doc --all-features --workspace
3471

3572
fmt:
36-
name: Rustfmt
73+
name: Formatting
3774
runs-on: ubuntu-latest
3875
steps:
39-
- uses: actions/checkout@v2
40-
- uses: actions-rs/toolchain@v1
41-
with:
42-
profile: minimal
43-
toolchain: stable
44-
override: true
45-
- run: rustup component add rustfmt
46-
- uses: actions-rs/cargo@v1
76+
- uses: actions/checkout@v4
77+
- uses: dtolnay/rust-toolchain@stable
4778
with:
48-
command: fmt
49-
args: --all -- --check
79+
components: rustfmt
80+
- name: Check formatting
81+
run: cargo fmt --all -- --check
5082

5183
clippy:
5284
name: Clippy
5385
runs-on: ubuntu-latest
5486
steps:
55-
- uses: actions/checkout@v2
56-
- uses: actions-rs/toolchain@v1
87+
- uses: actions/checkout@v4
88+
- uses: dtolnay/rust-toolchain@stable
89+
with:
90+
components: clippy
91+
- uses: actions/cache@v3
92+
with:
93+
path: |
94+
~/.cargo/bin/
95+
~/.cargo/registry/index/
96+
~/.cargo/registry/cache/
97+
~/.cargo/git/db/
98+
target/
99+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
100+
101+
- name: Clippy check
102+
run: cargo clippy --all-features --workspace -- -D warnings
103+
104+
security-audit:
105+
name: Security Audit
106+
runs-on: ubuntu-latest
107+
steps:
108+
- uses: actions/checkout@v4
109+
- name: Install cargo-audit
110+
run: cargo install cargo-audit
111+
- name: Run security audit
112+
run: cargo audit
113+
114+
cross-platform:
115+
name: Cross-platform tests
116+
needs: [check, test] # Only run if initial tests pass
117+
strategy:
118+
matrix:
119+
os: [windows-latest, macos-latest]
120+
runs-on: ${{ matrix.os }}
121+
steps:
122+
- uses: actions/checkout@v4
123+
- uses: dtolnay/rust-toolchain@stable
124+
- uses: actions/cache@v3
125+
with:
126+
path: |
127+
~/.cargo/bin/
128+
~/.cargo/registry/index/
129+
~/.cargo/registry/cache/
130+
~/.cargo/git/db/
131+
target/
132+
key: ${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
133+
134+
- name: Run tests
135+
run: cargo test --lib --all-features --workspace
136+
137+
docs:
138+
name: Documentation
139+
runs-on: ubuntu-latest
140+
steps:
141+
- uses: actions/checkout@v4
142+
- uses: dtolnay/rust-toolchain@stable
143+
- name: Check documentation
144+
env:
145+
RUSTDOCFLAGS: "-D warnings"
146+
run: cargo doc --no-deps --all-features --workspace
147+
148+
coverage:
149+
name: Code coverage
150+
runs-on: ubuntu-latest
151+
services:
152+
redis:
153+
image: redis
154+
ports:
155+
- 6379:6379
156+
steps:
157+
- uses: actions/checkout@v4
158+
159+
- uses: dtolnay/rust-toolchain@stable
57160
with:
58-
profile: minimal
59-
toolchain: stable
60-
override: true
61-
- run: rustup component add clippy
62-
- uses: actions-rs/cargo@v1
161+
components: llvm-tools-preview
162+
163+
- name: Install cargo-llvm-cov
164+
uses: taiki-e/install-action@cargo-llvm-cov
165+
166+
- name: Generate code coverage
167+
run: cargo llvm-cov --workspace --lcov --output-path lcov.info
168+
169+
- name: Upload coverage to Codecov
170+
uses: codecov/codecov-action@v3
63171
with:
64-
command: clippy
65-
args: -- -D warnings
172+
files: lcov.info
173+
fail_ci_if_error: true

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ members = [
77
]
88

99
[workspace.package]
10-
version = "0.5.0"
10+
version = "0.4.5"
1111
edition = "2021"
1212
license = "MIT"
1313
authors = ["oiwn"]

capp-config/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub trait Configurable {
2626
Ok(config)
2727
}
2828

29-
/// Load Vec<String> from file with path `file path`
29+
/// Load `Vec<String>`` from file with path `file path`
3030
fn load_text_file_lines(
3131
file_path: impl AsRef<path::Path>,
3232
) -> Result<Vec<String>, ConfigError> {

capp-config/src/healthcheck.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ use tokio::time::{timeout, Duration};
88
/// There are a few hosts that are commonly used to check it
99
/// because they are typically reliable and have high uptime. i
1010
/// Examples:
11-
/// - Google's primary domain: https://www.google.com
12-
/// - Cloudflare's DNS resolver: https://1.1.1.1
13-
/// - Quad9's DNS resolver: https://9.9.9.9
11+
/// - Google's primary domain: <https://www.google.com>
12+
/// - Cloudflare's DNS resolver: <https://1.1.1.1>
13+
/// - Quad9's DNS resolver: <https://9.9.9.9>
1414
pub async fn internet(http_url: &str) -> bool {
1515
let client = Client::new();
1616
let request_future = client.get(http_url).send();

capp/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "capp"
3-
version = "0.4.4"
3+
version = "0.4.5"
44
edition = "2021"
55
license = "MIT"
66
authors = ["oiwn"]

capp/src/manager/handler.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![cfg_attr(doctest, doc = "")]
12
//! This module defines the `TaskHandler` trait, which provides a generic interface
23
//! for asynchronous task processing. It allows for flexible implementation of
34
//! request handling with associated types for requests, responses, and errors.
@@ -23,6 +24,7 @@ use std::sync::Arc;
2324
///
2425
/// ```no_run
2526
/// use async_trait::async_trait;
27+
/// use capp::prelude::TaskHandler;
2628
///
2729
/// struct MyHandler;
2830
///

capp/src/manager/stats.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ impl<'a> SharedStats<'a> {
6262
}
6363
}
6464

65+
#[allow(clippy::needless_lifetimes)]
6566
impl<'a> Default for SharedStats<'a> {
6667
fn default() -> Self {
6768
Self::new()

0 commit comments

Comments
 (0)