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

Add GHA CICD #120

Merged
merged 26 commits into from
May 24, 2020
Merged

Add GHA CICD #120

merged 26 commits into from
May 24, 2020

Conversation

rivy
Copy link
Contributor

@rivy rivy commented Mar 10, 2020

This is a GitHub Actions workflow for CICD that I created for a couple of other repositories.

  • adds GitHub-Actions CICD workflow (includes arm-linux, x86-linux, macos, and windows builds/testing)
  • includes automatic deployment to Github Releases when commit is version tagged (see example at https://github.com/rivy/rs.pastel/releases/tag/v0.7.0.1; note: fully automatically generated)

I've also added in automated debian packaging / deployment (see example at https://github.com/rivy/rs.pastel/releases/tag/v0.7.0.2).

Additional targets are easily added as well.

Fixes: #119

@rivy
Copy link
Contributor Author

rivy commented Mar 10, 2020

I added in several commits fixing cargo clippy lint complaints so that the style test builds pass.

They are currently logically separated so that you can more easily evaluate the refactoring decisions, but I can easily squash them into one if you'd prefer.

@rivy
Copy link
Contributor Author

rivy commented Mar 10, 2020

Oh, also, it's 5 to 10 times faster than Travis or AppVeyor.
⚡️

Copy link
Owner

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

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

Thank you very much for your contribution!

In general, this looks great! 👍

That being said, I would really prefer the CI/CD file to be as simple as possible. At the moment, there is A LOT of code and some of it doesn't seem to be strictly necessary. There are also a lot of commented-out lines which I would prefer to be removed, if possible.

I know that you already put a lot of work into this, but I need to consider the fact that I might have to maintain this myself in the future. And for now, I'm not very familiar with GitHub Actions (although it sounds like a great idea to use this in the future).

Should we remove the AppVeyor/Travis CI files? Is there anything that is not supported in GitHub Actions?

.github/workflows/CICD.yml Outdated Show resolved Hide resolved
@rivy
Copy link
Contributor Author

rivy commented Mar 17, 2020

I think GHA is a complete solution and that AppVeyor and Travis can be discarded. But, I'd let this percolate for a few commits/PRs before removing them to make sure there's no problem or unmet need.

@sharkdp
Copy link
Owner

sharkdp commented Mar 17, 2020

This was a quick conversion from another repository.
I'll try to trim it down for you and update the PR tomorrow.

Thank you!

Oh, also, it's 5 to 10 times faster than Travis or AppVeyor.

That sounds fantastic :-)

@rivy
Copy link
Contributor Author

rivy commented Mar 18, 2020

Ok, I've slimmed the CICD code down (a bit). I think what's left is necessary, but please let me know if you disagree or any of it is unclear.

I replaced the commented Code Coverage section with a new alternate (working) version (using grcov) that tests *nix, macos, and windows (combining the coverage output; see https://codecov.io/gh/rivy/rs.pastel/commits).

I left a couple of "cleanup/polish" commits for the GHA:CI code because you might want to preserve them instead (especially, leaving the 'features' support might make a future self happier if you ever add any features).

I'm happy to squash down any/all of the cargo clippy complaint fix commits, as well, just leaving them separated so that you can review the changes associated with each complaint type (for discussion or alternate refactor).

Notably, all steps together, which now includes style checks and code coverage runs, take 8 minutes to complete (for comparison the Travis run takes 25 min, and the AppVeyor run was taking about 20 minutes).

The GHA:CI runs (from my repo) are available for review at https://github.com/rivy/rs.pastel/actions.

@rivy
Copy link
Contributor Author

rivy commented Mar 18, 2020

Looks like I have a bug in the way I'm testing MinSRV and that rust v1.35 doesn't like ...as_deref().
I'll fix both tomorrow.

@rivy
Copy link
Contributor Author

rivy commented Mar 18, 2020

... or tonight, I guess. 😄

To use .as_deref(), fixing a cargo clippy complaint, would raise the MinSRV to v1.40.

Instead, I'm using #[allow(clippy::option_as_ref_deref)] to fix the complaint. If you prefer using .as_deref() and raising the MinSRV to 1.40, let me know and I'll change it.

@sharkdp
Copy link
Owner

sharkdp commented Mar 20, 2020

Ok, I've slimmed the CICD code down (a bit). I think what's left is necessary, but please let me know if you disagree or any of it is unclear.

That still seems like a massive amount of code/configuration. We currently have a ~90 line file .travis.yml file and we would move to a 320 line CICID.yml file.

It seems to do a lot more than our .travis.yml file, but I would really appreciate if we could start small and build up from there.

For example, there are a whole lot of echo … lines in this CICID.yml file. Are they required?

@rivy
Copy link
Contributor Author

rivy commented Mar 23, 2020

I can remove the Style checks, the MinSRV build/test, and all code coverage which would take the line count down to 218 lines. But I think it's valuable functionality that shouldn't be removed.

The echo ... lines are how outputs are propagated to subsequent CICD steps. They are doubled in the Initialize workflow variables step so that the reviewer can evaluate/observe the final variable
values used by the build/test steps. I think they need to stay.

And, in looking at the Travis build, it's really about the same size as this CICD script (which has significantly more functionality and speed). The Travis build uses several scripts in the ./ci directory which add another 230 lines to the size of the build script, just bundled in a library directory.

I'm happy to run through what the CICD.yml is doing and why, in a step-wise manner, so that you can decide what you do and don't want to include. But, IMO, the current version has reasonable code size for the functionality (which is all useful).

@sharkdp
Copy link
Owner

sharkdp commented Apr 24, 2020

Thank you for your work. I'd like to get this merged!

I can remove the Style checks, the MinSRV build/test, and all code coverage which would take the line count down to 218 lines. But I think it's valuable functionality that shouldn't be removed.

For now, I would really prefer a version without style checks and without clippy checks. I really love both cargo fmt and cargo clippy, but I disagree with the fact that they need to be enforced in CI. It's enough for me to run them manually from time to time. I don't want each and every PR and push to the repo to potentially fail because of trivial things detected by some static analysis tool.

Don't get me wrong. I would love to have such checks if this would be a high-performance library or something security relevant, etc.. But it's just a innocent little command line application which would rather profit from having low maintenance PRs/pushes.

As for MinSRV build/test... I don't even know what that is?

The echo ... lines are how outputs are propagated to subsequent CICD steps. They are doubled in the Initialize workflow variables step so that the reviewer can evaluate/observe the final variable
values used by the build/test steps. I think they need to stay.

ok

And, in looking at the Travis build, it's really about the same size as this CICD script (with significantly more functionality and speed). The Travis build uses several scripts in the ./ci directory which add another 230 lines to the size of the build script, just bundled in a library directory.

Fair point!

src/ansi.rs Outdated Show resolved Hide resolved
src/distinct.rs Outdated
result.closest_pair.0
} else {
if self.rng.gen() {
#[allow(clippy::collapsible_if)]
Copy link
Owner

Choose a reason for hiding this comment

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

similar here

src/lib.rs Outdated
@@ -868,7 +871,7 @@ impl ColorScale {
let same_position = self
.color_stops
.iter_mut()
.find(|c| position.value() == c.position.value());
.find(|c| (position.value() - c.position.value()).abs() < std::f64::EPSILON);
Copy link
Owner

@sharkdp sharkdp Apr 24, 2020

Choose a reason for hiding this comment

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

no!! the == check on floats is actually desired here. Using an epsilon check would be wrong.

This is one of the reasons why I don't like to have clippy warnings checked by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Commit dropped (reverted).

src/parser.rs Show resolved Hide resolved
src/types.rs Outdated
@@ -15,7 +15,7 @@ impl Hue {

/// Return a hue value in the interval [0, 360].
pub fn value(self) -> Scalar {
if self.unclipped == 360.0 {
if (self.unclipped - 360.0).abs() < std::f64::EPSILON {
Copy link
Owner

@sharkdp sharkdp Apr 24, 2020

Choose a reason for hiding this comment

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

Same here. Please leave the == check in place. This can lead to wrong results (angles larger 360.0 degrees)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Commit dropped (reverted).

@rivy
Copy link
Contributor Author

rivy commented Apr 28, 2020

For now, I would really prefer a version without style checks and without clippy checks. I really love both cargo fmt and cargo clippy, but I disagree with the fact that they need to be enforced in CI. It's enough for me to run them manually from time to time. I don't want each and every PR and push to the repo to potentially fail because of trivial things detected by some static analysis tool.

Don't get me wrong. I would love to have such checks if this would be a high-performance library or something security relevant, etc.. But it's just a innocent little command line application which would rather profit from having low maintenance PRs/pushes.

Fair enough, I'll yank the "Style" jobs from the CI.

As for MinSRV build/test... I don't even know what that is?

Sorry for the jargon ... "MinSRV" == "minimum supported rust version". It is debatable whether yoiu want to have this as a signal you want to send to other devs. If you don't want it, I can yank it as well.

I'll plan to give this a look again tomorrow or the day after and update based on your feedback.

@sharkdp
Copy link
Owner

sharkdp commented Apr 28, 2020

Sorry for the jargon ... "MinSRV" == "minimum supported rust version".

Oh 😄

It is debatable whether yoiu want to have this as a signal you want to send to other devs

No - a test for min. supported Rust version is great. Thanks!

@rivy
Copy link
Contributor Author

rivy commented Apr 29, 2020

Ok, I've dropped the 'Style' job, and removed the commit altering the float comparisons.

I've included some other minor updates for code coverage and i686-pc-windows-gnu builds as well.

I've grouped the *allow* commits together and I can drop them wholesale with the caveat that clippy will complain. The 15fb1fb commit can be dropped with no clippy complaint if I simultaneously raise the MinSRV to 1.40.0, which can be done easily.

All jobs are passing.

Let me know how you want me to handle the *allow* ... commits, and then I'll squash the commits (plan would be to squash down to about two or three commits), and re-force-push the PR.

@sharkdp
Copy link
Owner

sharkdp commented Apr 29, 2020

I've grouped the *allow* commits together and I can drop them wholesale with the caveat that clippy will complain.

Let's leave the allow parts in. I guess I just have to get used to it.

The 15fb1fb commit can be dropped with no clippy complaint if I simultaneously raise the MinSRV to 1.40.0, which can be done easily.

I'm fine with raising to 1.40, thanks!

I'll squash the commits (plan would be to squash down to about two or three commits)

You don't have to, if it's up to me. I like your fine-grained commits 👍

@rivy
Copy link
Contributor Author

rivy commented May 1, 2020

I'll have an updated PR pushed later tonight.

rivy added 13 commits May 2, 2020 14:38
… * MinSRV to '1.40.0'

- `.as_deref()` was stabilized in rust v1.40.0; * requires MinSRV => '1.40.0'

- ref: <https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1400-2019-12-19>
…nightly toolchain

## [why]

Code coverage must currently use some unstable features in nightly rust builds. The
nightly builds are, by definition, unstable and subject to frequent breaking changes.
To prevent CI build breakage, the toolchain is pinned to a specific known working set.

Note: (maint!) this will require periodic review until code coverage is more fully
implemented/integrated into Rust and moved into the stable channel.

- refs: <mozilla/grcov#427>, <newsboat/newsboat#916>
@rivy
Copy link
Contributor Author

rivy commented May 2, 2020

Ok, it's up.

  • rebased onto master
  • local (successful) GHA test run
  • minor change to Code Coverage

toolchain has to be a nightly; pinned to minimize disruptions (as occurred just recently); will be a maintenance issue going forward; convert to "stable" when rust starts to include the necessary support in that toolchain (follow grcov repo for ongoing state)

  • cleanup/polish of issues discussed above

@rivy rivy requested a review from sharkdp May 2, 2020 19:51
Copy link
Owner

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

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

@rivy Thank you so much for all of this work! Is there anything else I need to set up in order to make the automatic deployment work?

@sharkdp sharkdp merged commit a45a7f5 into sharkdp:master May 24, 2020
@sharkdp
Copy link
Owner

sharkdp commented May 24, 2020

I'm just now starting to realize how cool this is 😎

@rivy
Copy link
Contributor Author

rivy commented May 24, 2020

@rivy Thank you so much for all of this work! Is there anything else I need to set up in order to make the automatic deployment work?

No, it should just auto-deploy to releases section any time you push a "version tag", meaning any tag starting with a number (with an optional leading v), to the repository. The regex match is [Vv]?[0-9].*.

If it doesn't work, ping me and I'll look at it.

@sharkdp
Copy link
Owner

sharkdp commented May 24, 2020

No, it should just auto-deploy to releases section any time you push a "version tag", meaning any tag starting with a number (with an optional leading v). The regex match is [Vv]?[0-9].*.

If it doesn't work, ping me and I'll look at it.

Thank you! I'll try to tag a new release soon.

@rivy
Copy link
Contributor Author

rivy commented May 24, 2020

If you have trouble with code coverage breaking the build, I submitted a new PR to alleviate that issue (#126).

@sharkdp
Copy link
Owner

sharkdp commented May 25, 2020

The release process worked just fine. Thanks again.

@rivy rivy deleted the add.gha-cicd branch May 25, 2020 22:14
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

2 participants