Skip to content

Commit

Permalink
Merge pull request #42 from oiwn/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
oiwn authored Dec 10, 2024
2 parents 6a36bdf + 42942ec commit c42bd0f
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 45 deletions.
186 changes: 147 additions & 39 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,65 +1,173 @@
on: [pull_request]
name: Continuous Integration

name: Continuous integration
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
workflow_dispatch: # Manual trigger

env:
CARGO_TERM_COLOR: always
REDIS_URI: redis://localhost:6379

jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v3
with:
command: check
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Cargo check
run: cargo check --all-features --workspace

test:
name: Test Suite
runs-on: ubuntu-latest
services:
redis:
image: redis
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v3
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: test
args: --lib
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Run unit tests
run: cargo test --lib --all-features --workspace

- name: Run integration tests
run: cargo test --test '*' --all-features --workspace

- name: Run doc tests
run: cargo test --doc --all-features --workspace

fmt:
name: Rustfmt
name: Formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
command: fmt
args: --all -- --check
components: rustfmt
- name: Check formatting
run: cargo fmt --all -- --check

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Clippy check
run: cargo clippy --all-features --workspace -- -D warnings

security-audit:
name: Security Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install cargo-audit
run: cargo install cargo-audit
- name: Run security audit
run: cargo audit

cross-platform:
name: Cross-platform tests
needs: [check, test] # Only run if initial tests pass
strategy:
matrix:
os: [windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Run tests
run: cargo test --lib --all-features --workspace

docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Check documentation
env:
RUSTDOCFLAGS: "-D warnings"
run: cargo doc --no-deps --all-features --workspace

coverage:
name: Code coverage
runs-on: ubuntu-latest
services:
redis:
image: redis
ports:
- 6379:6379
steps:
- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add clippy
- uses: actions-rs/cargo@v1
components: llvm-tools-preview

- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov

- name: Generate code coverage
run: cargo llvm-cov --workspace --lcov --output-path lcov.info

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
command: clippy
args: -- -D warnings
files: lcov.info
fail_ci_if_error: true
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ members = [
]

[workspace.package]
version = "0.5.0"
version = "0.4.5"
edition = "2021"
license = "MIT"
authors = ["oiwn"]
Expand Down
2 changes: 1 addition & 1 deletion capp-config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub trait Configurable {
Ok(config)
}

/// Load Vec<String> from file with path `file path`
/// Load `Vec<String>`` from file with path `file path`
fn load_text_file_lines(
file_path: impl AsRef<path::Path>,
) -> Result<Vec<String>, ConfigError> {
Expand Down
6 changes: 3 additions & 3 deletions capp-config/src/healthcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use tokio::time::{timeout, Duration};
/// There are a few hosts that are commonly used to check it
/// because they are typically reliable and have high uptime. i
/// Examples:
/// - Google's primary domain: https://www.google.com
/// - Cloudflare's DNS resolver: https://1.1.1.1
/// - Quad9's DNS resolver: https://9.9.9.9
/// - Google's primary domain: <https://www.google.com>
/// - Cloudflare's DNS resolver: <https://1.1.1.1>
/// - Quad9's DNS resolver: <https://9.9.9.9>
pub async fn internet(http_url: &str) -> bool {
let client = Client::new();
let request_future = client.get(http_url).send();
Expand Down
2 changes: 1 addition & 1 deletion capp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "capp"
version = "0.4.4"
version = "0.4.5"
edition = "2021"
license = "MIT"
authors = ["oiwn"]
Expand Down
2 changes: 2 additions & 0 deletions capp/src/manager/handler.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg_attr(doctest, doc = "")]
//! This module defines the `TaskHandler` trait, which provides a generic interface
//! for asynchronous task processing. It allows for flexible implementation of
//! request handling with associated types for requests, responses, and errors.
Expand All @@ -23,6 +24,7 @@ use std::sync::Arc;
///
/// ```no_run
/// use async_trait::async_trait;
/// use capp::prelude::TaskHandler;
///
/// struct MyHandler;
///
Expand Down
1 change: 1 addition & 0 deletions capp/src/manager/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ impl<'a> SharedStats<'a> {
}
}

#[allow(clippy::needless_lifetimes)]
impl<'a> Default for SharedStats<'a> {
fn default() -> Self {
Self::new()
Expand Down

0 comments on commit c42bd0f

Please sign in to comment.