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

A better story for canary jobs (yellow CI) #33

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Conversation

jonhoo
Copy link
Collaborator

@jonhoo jonhoo commented Jul 16, 2019

This PR does two things.

First, it adds a new smoke test to the mix: cargo check -- -D warnings, which will error on any warning from rustc.

Second, it makes it easy to opt out of all canaries (basically anything that is allow_fail) by setting

parameters:
  canaries: false

This will currently disable:

  • rustfmt on beta
  • clippy on beta
  • the new -D warnings test
  • test on nightly

This parameter is intended for users that worry about long-running or highly parallel CI, yellow CI ("partially successful").

azure/style.yml Outdated Show resolved Hide resolved
azure/cargo-clippy.yml Outdated Show resolved Hide resolved
azure/style.yml Outdated Show resolved Hide resolved
azure/style.yml Outdated Show resolved Hide resolved
jonhoo added 2 commits July 16, 2019 11:20
Enabling _all_ clippy warnings is too hardcore
They're not really smoke tests since they don't pre-empt other tests
from running. Also, canaries are yellow, just like your CI will be.

This also turns cargo +beta test into an allow_fail, because it is also
a canary.
@jonhoo jonhoo changed the title A better story for smoke tests A better story for canary jobs (yellow CI) Jul 16, 2019
${{ if ne(parameters.err_on_warn, 'true') }}:
displayName: cargo check
${{ if ne(parameters.rust, 'stable') }}:
${{ if eq(parameters.err_on_warn, 'true') }}:
displayName: "env RUSTFLAGS=-Dwarnings cargo +${{ parameters.rust }} check"
displayName: "cargo +${{ parameters.rust }} check -Dwarnings"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we allow deprecated? It'll make things more stable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is already allow_fail, so I'd be inclined to still give deprecation warnings. They're things you should probably fix, just like other warnings.

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. This template does not have an allow_fail
  2. This assumes that the caller will always pass allow_fail with err_on_warn. In my use case, I do not want to be doing that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, good catch! Fixed 1 in latest commit.

As for 2, it doesn't really assume that. If you specify err_on_warn without allow_fail, you are specifically saying "I want to treat warnings as CI errors". Seems reasonable for that to be a valid option?

Copy link
Contributor

Choose a reason for hiding this comment

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

While so far I've gotten away with deprecated being enabled, you've brought up the concern over dependencies breaking people. If we want to take that seriously and support people who want a pinned warnings check, then we'd need to disable that warning.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My thinking here was that either you care about warnings, or you do not (this is err_on_warn). If you do, you either want them to cause red CI or you want them to cause yellow CI (this is allow_fail). We could add a third branch point which is "care about all but warnings caused by changes in dependencies" I suppose (what would it be called)? My guess is that that option is less common, but I have limited data on that.

Copy link
Contributor

Choose a reason for hiding this comment

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

My care abouts

  • Warnings make CI red
  • Transient state (like dependencies deprecating things when you don't have a Cargo.lock checked in) should not make my CI red
    • Personally, I've never had a dependency make something deprecated so I've not worried about that state before. This is more in theoretically possible land
  • I should be able to maintain my MSRV ie deprecation warnings for Rust can only be emitted by the MSRV or else I can't get a "non-red" to approve my submissions.

As long as those conditions are met, I'm fine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay, so, I think this satisfies all of those. Specifically, the default stages.yml will never make your CI red from warnings, it will only ever make it yellow. You can choose to directly depend on cargo-check.yml, and then you can choose whether you want warnings to cause red CI (err_on_warn: true + allow_fail: false), yellow CI (err_on_warn: true + allow_fail: true), or green CI (err_on_warn: false + allow_fail: false; the default).

Thus, anything that'd make your CI red would be by choice in setting up your pipeline.

Now, what this PR does not give you the ability to do is to run CI and have it fail on warnings that are not due to dependencies. I think that's specifically something you would like, but I also think that's something that's better handled in a new PR where we can explicitly figure out which warnings that would require allowing.

So, with all that said, my inclination would be to merge and then open an issue tracking "red CI from non-dependency warnings".

@jonhoo jonhoo requested a review from epage July 16, 2019 16:38
@djc
Copy link
Contributor

djc commented Jul 23, 2019

FWIW, I like the idea of (optionally) erroring stable CI for warnings. I think denying warnings at compile time is too annoying for my development experience, but I want code to be warning-free before it hits master.

@jonhoo
Copy link
Collaborator Author

jonhoo commented Jul 23, 2019

@djc there are two tricky parts about this:

  • Commits that did not emit warnings in the past may start emitting warnings in future versions of stable, which would cause a CI failure in, say, an unrelated PR.
  • Semver-compatible changes in dependencies (macro changes and deprecations in particular) can cause a previously-fine commit to suddenly stop passing if you don't check in Cargo.lock.

These taken together mean that failing CI on warnings, even on stable is risky business. The open discussion above is basically about what policy to take on this. It might be possible to have a "error on warnings with a pinned Rust version + allow particular warnings related to dependencies", but it's finicky and somewhat brittle.

@codecov-io
Copy link

codecov-io commented Jul 23, 2019

Codecov Report

Merging #33 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #33   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           1      1           
  Lines           8      8           
=====================================
  Hits            8      8

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9e8e64f...4e6377a. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants