crate-ci / azure-pipelines

Easy continuous integration for Rust projects with Azure Pipelines
MIT License
88 stars 24 forks source link

Add warning checks to the complete template #19

Open epage opened 5 years ago

epage commented 5 years ago

Doing a cargo check with RUSTFLAGS="-D warnings" will fail the build on warnings.

The problems is new warnings can be added and break the build, so like clippy in #18, we should use a pinned version of rustc.

jonhoo commented 5 years ago

I'm personally strongly against making warnings errors. It means that, for example, a minor version release for a dependency that deprecates a method can cause your build to fail, even though the version bump was semver compatible. If authors specifically want no warnings, they should opt into that with

#![deny(warnings)]

in their src/lib.rs (or equivalent)

epage commented 5 years ago

I'm strongly in favor of turning warnings into errors :)

jonhoo commented 5 years ago

Warnings as errors breaks safe semver updates, which is a deal-breaker for me (the example of dependency deprecations being one example, macros as you mention being another).

I'm not sure I know about the flag you mention so that new stable releases don't break your build with -D warnings?

I completely agree with you that your code should compile without warnings. The problem is that new warnings can appear without your code changing. For example, as discussed in another issue, this could absolutely cause a new contributor to see red CI unrelated to their current changes, such as if Cargo.lock is not checked in and CI uses a later minor version of a dependency that deprecates a method.

This all said, I think it might be okay to include a deny_warnings: true parameter to the cargo-check template (and thus also to stages) for people to opt in to it. I definitely think it should be false by default though.

epage commented 5 years ago

So I've never run into a dependency deprecating something, only stdlib which has been handled by warning on MSRV only.

A way of handling this is by instead doing

RUSTFLAGS="-D warnings -A deprecated"

Outside of macros, deprecated is the only way I know of for a dependency to break you via warnings, so I think this should be sufficient.

jonhoo commented 5 years ago

fwiw, #33 mostly addresses this by running a stage that treats all warnings as errors (including deprecations), but treat them as allowed failures (so they'll show up as yellow CI). I think that's a reasonable compromise?