Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build warning, fail CI if build has warnings #73

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}

- name: Build
run: cargo build --all --verbose
run: cargo build --all --verbose --features strict
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The feature is a neat idea but why not just -D warnings?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question... I originally implemented this by setting RUSTFLAGS=-D warnings and it looked like it built all of the dependencies with -D warnings too. (Then I copied the feature approach from here).

I didn't try passing -D directly to cargo though, I will try this and get back to you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, sorry for the long turnaround on following this up!

The best summary I've found (with links to some other resources) is the thread linked in the previous comment https://users.rust-lang.org/t/how-to-fail-a-build-with-warnings/2687

- name: Tests
run: cargo test --all --verbose

Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ rust-version = "1.78.0"

[features]
std = []
strict = [] # For CI builds, fails on warnings

[dependencies]
can-dbc = "6.0.0"
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
//! ```

#![deny(missing_docs)]
#![cfg_attr(feature = "strict", deny(warnings))]
#![deny(clippy::arithmetic_side_effects)]

use anyhow::{anyhow, ensure, Context, Result};
Expand Down
Loading