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

Stable and slim #1

Merged
merged 8 commits into from Apr 16, 2018
Merged

Stable and slim #1

merged 8 commits into from Apr 16, 2018

Conversation

killercup
Copy link
Collaborator

@killercup killercup commented Apr 15, 2018

This is a pretty general refactoring of the code.

The goal of this PR is to make this a crate that is useful in more general contexts. For this, I've:

  • put the nightly-only external_doc feature behind a feature flag
  • changed how clippy is used on CI by installing cargo-clippy in a new travis builder
  • removed failure and unindent as dependencies
  • replaced console with termcolor which is known to work on Windows

For more information, see the individual commit messages.

Semver Changes

This does not change observable behavior.

Also adds a nightly feature flag that will automatically be picked up by
docs.rs to build nice docs.
You can run `cargo clippy` locally to get the same effect. I've also
taken the liberty to nail down the rustfmt version to use, so we can
update it explicitly. (This is the same CI setup that assert_cli uses.)
Improves compile times :trollface:
This should make it compatible with windows consoles.
@killercup
Copy link
Collaborator Author

(wrote this as a comment to prevent it from becoming part of the merge commit message)

Checklist

  • tests pass -- well, I've change the CI script. Let's see what happens. Update: Did you set up travis yet?

@yoshuawuyts
Copy link
Collaborator

@killercup niceee!

Some quick notes:

  • loving the general refactor; didn't know this was possible, and digging it a lot.
  • travis is setup now!
  • not too sure about the clippy pinning; I kind of like always having the latest, despite the possibility it might fail sporadically. Also allows people to run Clippy locally, as opposed to only through CI - if possible I'd like to keep it as-is for now.

Overall really liking it!


use console::style;
use failure::Error;
#![cfg_attr(feature = "nightly", deny(missing_docs))]
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be enabled on every channel I reckon

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can't enable missing_docs on stable because then it'll complain about missing module docs! (As loading the Readme is only done in nightly.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ahaha, yeah alright - fair enough! There's hacks we could do, but let's not do them.


/// Catch any error handlers that occur, and
// Cargo env vars available:
// https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-crates
pub fn catch_unwind<F: FnOnce() -> Result<(), Error>>(f: F) {
pub fn catch_unwind<F: FnOnce() -> Result<(), Box<Error>>>(f: F) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Curious: why did you opt to replace failure::Error with Box<Error>? The former should guarantee we always get a stack trace, which I figured would be useful for the reporting.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, is this why you used failure? I'm not sure that's what's happening: Failure will only give you stack traces for errors that occur in the catch_unwind code -- everything else is part of the panic_info, right?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah, that's totally true! - the way I'm envisioning this though is that this would run in the outer most scope of fn main() to catch everything that happens inside of it. And then like with quicli it also handles errors that have been returned. Does that make sense?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmmm. I see what you mean, but I don't think this is how it works. Failure's backtrace will only collect traces when an error is actually propagated -- but when you panic!, that doesn't happen (instead, Rust will unwind the stack; unless you set `panic = "abort").

I'm not an authority on how to really solve this, though!

@killercup
Copy link
Collaborator Author

not too sure about the clippy pinning; I kind of like always having the latest, despite the possibility it might fail sporadically.

I can change it to always install the latest version on the latest nightly and make this an allowed failure on Travis if you want. (I'd personally prefer the stability because allowed failures tend to go unnoticed.)

Also allows people to run Clippy locally, as opposed to only through CI - if possible I'd like to keep it as-is for now.

You can do cargo install clippy locally and then run cargo clippy -- also works on project without any clippy setup :)

@yoshuawuyts
Copy link
Collaborator

You can do cargo install clippy locally and then run cargo clippy -- also works on project without any clippy setup :)

Haha, yeah - but I reallllly just want to run it whenever cargo test is done, so that people only need to think of a single command during development. I'm thinking this will be the type of module we write once, and then it's done. Maybe some minor maintenance over the years, but nothing major.

The less work there is in a toolchain, the better 😁

@killercup
Copy link
Collaborator Author

Haha, yeah - but I reallllly just want to run it whenever cargo test is done, so that people only need to think of a single command during development.

I'd love to have that as well! Alas, that is in stark conflict with "this still compiles in a year" right now :(

It's a trade-off. Just tell me what you want to have and I'll implement it.

@epage
Copy link
Collaborator

epage commented Apr 15, 2018

I recommend pinning clippy in the CI. I have found that contributors get frustrated when a CI arbitrarily breaks on them and pinning as a big help for this. Pinning also makes it possible to cache your clippy install to reduce CI times and load on these CI servers that are gifted to us. For more, see https://crate-ci.github.io/pr/clippy.html

.travis.yml Outdated
- rust: nightly-2018-04-13
env: CLIPPY_VERS="0.0.193"
before_script: |
[[ "$(cargo +nightly-2018-04-13 clippy --version)" != "$CLIPPY_VERS" ]] && \
Copy link
Collaborator

Choose a reason for hiding this comment

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

This actually isn't needed. I know I recommended it in the past for assert_cli but have learned more about travis as part of documenting it for crate-ci.

Travis will ignore the caches on environment variable changes and since the version is kept in an environment variable, it will auto-clear.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, interesting! Should be depend on Travis' behavior here, though? At least this way it should also work for other CI systems, right?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Except the file is travis specific. As we document other CIs, we can note the special things that might need to be done in them. Overall, I like Travis' approach; I wish I had that on Jenkins at work.

@yoshuawuyts
Copy link
Collaborator

@killercup sure, let's go with what you proposed - it seems most folks in this thread seem in favor of that, so good with me!

@yoshuawuyts yoshuawuyts mentioned this pull request Apr 15, 2018
and choose a nightly that actually exists.
@killercup
Copy link
Collaborator Author

killercup commented Apr 16, 2018

Yay, CI works!

@killercup
Copy link
Collaborator Author

Fixed the clippy issue. Let me know what else you need me to change.

spacekookie pushed a commit to spacekookie/human-panic that referenced this pull request Apr 16, 2018
This commit cleans up the code quite significantly and gates certain features
behind `nightly` macros to still allow complication on stable Rust.
@spacekookie spacekookie mentioned this pull request Apr 16, 2018
@yoshuawuyts yoshuawuyts merged commit b90ea3b into rust-cli:master Apr 16, 2018
epage added a commit to epage/human-panic that referenced this pull request May 19, 2023
chore(deps): update msrv to v1.65.0
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.

None yet

3 participants