-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: fix linting warnigns and add testing workflow
- Loading branch information
1 parent
61b256f
commit e1eb867
Showing
15 changed files
with
256 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[alias] | ||
cov = "llvm-cov" | ||
cov-lcov = "llvm-cov --lcov --output-path=./.coverage/lcov.info" | ||
cov-html = "llvm-cov --html" | ||
time = "build --timings --all-targets" | ||
|
||
[build] | ||
rustflags = [ | ||
"-D", | ||
"warnings", | ||
"-D", | ||
"future-incompatible", | ||
"-D", | ||
"let-underscore", | ||
"-D", | ||
"nonstandard-style", | ||
"-D", | ||
"rust-2018-compatibility", | ||
"-D", | ||
"rust-2018-idioms", | ||
"-D", | ||
"rust-2021-compatibility", | ||
"-D", | ||
"unused", | ||
] | ||
|
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@josecelano |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: github-actions | ||
directory: / | ||
schedule: | ||
interval: daily | ||
target-branch: "develop" | ||
labels: | ||
- "Continuous Integration" | ||
- "Dependencies" | ||
|
||
- package-ecosystem: cargo | ||
directory: / | ||
schedule: | ||
interval: daily | ||
target-branch: "develop" | ||
labels: | ||
- "Build | Project System" | ||
- "Dependencies" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
name: Testing | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
format: | ||
name: Formatting | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- id: checkout | ||
name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- id: setup | ||
name: Setup Toolchain | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
toolchain: nightly | ||
components: rustfmt | ||
|
||
- id: cache | ||
name: Enable Workflow Cache | ||
uses: Swatinem/rust-cache@v2 | ||
|
||
- id: format | ||
name: Run Formatting-Checks | ||
run: cargo fmt --check | ||
|
||
check: | ||
name: Static Analysis | ||
runs-on: ubuntu-latest | ||
needs: format | ||
|
||
strategy: | ||
matrix: | ||
toolchain: [nightly, stable] | ||
|
||
steps: | ||
- id: checkout | ||
name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- id: setup | ||
name: Setup Toolchain | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
toolchain: ${{ matrix.toolchain }} | ||
components: clippy | ||
|
||
- id: cache | ||
name: Enable Workflow Cache | ||
uses: Swatinem/rust-cache@v2 | ||
|
||
- id: tools | ||
name: Install Tools | ||
uses: taiki-e/install-action@v2 | ||
with: | ||
tool: cargo-machete | ||
|
||
- id: check | ||
name: Run Build Checks | ||
run: cargo check --tests --benches --examples --workspace --all-targets --all-features | ||
|
||
- id: lint | ||
name: Run Lint Checks | ||
run: cargo clippy --tests --benches --examples --workspace --all-targets --all-features -- -D clippy::correctness -D clippy::suspicious -D clippy::complexity -D clippy::perf -D clippy::style -D clippy::pedantic | ||
|
||
- id: docs | ||
name: Lint Documentation | ||
env: | ||
RUSTDOCFLAGS: "-D warnings" | ||
run: cargo doc --no-deps --bins --examples --workspace --all-features | ||
|
||
- id: clean | ||
name: Clean Build Directory | ||
run: cargo clean | ||
|
||
- id: deps | ||
name: Check Unused Dependencies | ||
run: cargo machete | ||
|
||
|
||
unit: | ||
name: Units | ||
runs-on: ubuntu-latest | ||
needs: check | ||
|
||
strategy: | ||
matrix: | ||
toolchain: [nightly, stable] | ||
|
||
steps: | ||
- id: checkout | ||
name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- id: setup | ||
name: Setup Toolchain | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
toolchain: ${{ matrix.toolchain }} | ||
components: llvm-tools-preview | ||
|
||
- id: cache | ||
name: Enable Job Cache | ||
uses: Swatinem/rust-cache@v2 | ||
|
||
- id: tools | ||
name: Install Tools | ||
uses: taiki-e/install-action@v2 | ||
with: | ||
tool: cargo-llvm-cov, cargo-nextest | ||
|
||
- id: test-docs | ||
name: Run Documentation Tests | ||
run: cargo test --doc | ||
|
||
- id: test | ||
name: Run Unit Tests | ||
run: cargo test --tests --benches --examples --workspace --all-targets --all-features |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
.env | ||
**/*.rs.bk | ||
/.coverage/ | ||
/.idea/ | ||
/.vscode/launch.json | ||
/flamegraph.svg | ||
/target | ||
callgrind.out | ||
perf.data* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"recommendations": [ | ||
"streetsidesoftware.code-spell-checker", | ||
"rust-lang.rust-analyzer", | ||
"tamasfe.even-better-toml" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"[rust]": { | ||
"editor.formatOnSave": true | ||
}, | ||
"[ignore]": { "rust-analyzer.cargo.extraEnv" : { | ||
"RUSTFLAGS": "-Z profile -C codegen-units=1 -C inline-threshold=0 -C link-dead-code -C overflow-checks=off -C panic=abort -Z panic_abort_tests", | ||
"RUSTDOCFLAGS": "-Z profile -C codegen-units=1 -C inline-threshold=0 -C link-dead-code -C overflow-checks=off -C panic=abort -Z panic_abort_tests", | ||
"CARGO_INCREMENTAL": "0", | ||
"RUST_BACKTRACE": "1" | ||
}}, | ||
"rust-analyzer.checkOnSave": true, | ||
"rust-analyzer.check.command": "clippy", | ||
"rust-analyzer.check.allTargets": true, | ||
"rust-analyzer.check.extraArgs": [ | ||
"--", | ||
"-D", | ||
"clippy::correctness", | ||
"-D", | ||
"clippy::suspicious", | ||
"-W", | ||
"clippy::complexity", | ||
"-W", | ||
"clippy::perf", | ||
"-W", | ||
"clippy::style", | ||
"-W", | ||
"clippy::pedantic" | ||
], | ||
"evenBetterToml.formatter.allowedBlankLines": 1, | ||
"evenBetterToml.formatter.columnWidth": 130, | ||
"evenBetterToml.formatter.trailingNewline": true, | ||
"evenBetterToml.formatter.reorderKeys": true, | ||
"evenBetterToml.formatter.reorderArrays": true, | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
//! ```text | ||
//! cargo run --bin custom-mocks-in-rust | ||
|
||
use std::{rc::Rc, sync::Arc}; | ||
//! ``` | ||
use std::rc::Rc; | ||
|
||
use testing_in_rust::example01::{ | ||
events::TrackerEventSender, handlers::handle_connect, tracker::Tracker, | ||
}; | ||
|
||
fn main() { | ||
let event_sender = Rc::new(TrackerEventSender {}); | ||
let tracker = Arc::new(Tracker::new(event_sender)); | ||
let tracker = Rc::new(Tracker::new(event_sender)); | ||
|
||
handle_connect(tracker) | ||
handle_connect(&tracker); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
use std::sync::Arc; | ||
use std::rc::Rc; | ||
|
||
use crate::example01::tracker::Tracker; | ||
|
||
/// Controller for the UDP connect request | ||
pub fn handle_connect(tracker: Arc<Tracker>) { | ||
/// | ||
/// # Panics | ||
/// | ||
/// Will panic if the tracker can't connect. | ||
pub fn handle_connect(tracker: &Rc<Tracker>) { | ||
tracker.connect().unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters