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

Run Rubocop in parallel with tests #842

Merged
merged 11 commits into from
Apr 15, 2020
Merged

Run Rubocop in parallel with tests #842

merged 11 commits into from
Apr 15, 2020

Conversation

marcotc
Copy link
Member

@marcotc marcotc commented Oct 18, 2019

We only need to run rubocop once in our CI, but today we run it for each Ruby version, serially with tests. This slows down total CI time by ~26s.

It also gives us a clearer view of what failed (tests or linting?), as today lint failures will get reported as test failures.

This PR moves rubocop to a separate lint step.
This step runs in parallel with all tests and is a required step for deploy prerelease Gem and deploy release steps.

@marcotc marcotc added the dev/testing Involves testing processes (e.g. RSpec) label Oct 18, 2019
@marcotc marcotc requested a review from a team October 18, 2019 21:31
@marcotc marcotc self-assigned this Oct 18, 2019
@delner
Copy link
Contributor

delner commented Oct 21, 2019

Might we want to run it for each version of Ruby? It's possible that different versions of Ruby have different rules, specific to features they implement. Ideally this would never happen, but it has been the case where we've done Ruby version specific patching before.

@marcotc
Copy link
Member Author

marcotc commented Oct 21, 2019

@delner that makes sense.
I was thinking running only for our configured TargetRubyVersion (2.1 in our case) would give us the same results as running on other versions too.

I can test this on all version we support and report back.

@marcotc
Copy link
Member Author

marcotc commented Oct 22, 2019

@delner I double checked and because we specify TargetRubyVersion, Rubocop will always run the same set of rules regardless of the version of Ruby processing our .rubocop.yml.

To make sure all was true for our project, I ran rubocop --show-cops on all our supported Ruby versions and they all yielded the same output.

With this in mind, I think it's best to run the latest version of Rubocop, keeping a fixed TargetRubyVersion that matches our minimum required Ruby version. This ensures we have access to recent bug fixes for Rubocop.
To use the currently latest version Rubocop we need Ruby >= 2.3.
I'm updating the container running our Rubocop check to use the latest version of Ruby we support, to ensure we can easily upgrade Rubocop when desired.

delner
delner previously approved these changes Oct 25, 2019
Copy link
Contributor

@delner delner left a comment

Choose a reason for hiding this comment

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

Moving linting into its own step is fine. Just one comment; address or merge at your discretion.

<<: *config-2_6
name: lint
requires:
- build-2.6
Copy link
Contributor

Choose a reason for hiding this comment

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

Only concern here is the linting rules for 2.6 might be different than other versions (e.g. new syntax is introduced that is preferred to older versions.) This concern generally applies moving forward to all versions of Ruby, as the same thing could happen in any future version.

Not a huge deal to me, just a potential gap I see.

Copy link
Member Author

Choose a reason for hiding this comment

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

Setting TargetRubyVersion to 2.1, like we do, prevents Rubocop from considering any rules created for versions greater than 2.1.

Effectively we "locked" Rubocop in the 2.1 era for cops.
Also, we are locked to a specific version of Rubocop, 0.49.1, so that gem's code is always consistent for us.

@marcotc marcotc changed the base branch from test/parallel-ci to master December 12, 2019 00:25
@marcotc marcotc requested a review from delner December 12, 2019 00:34
@marcotc
Copy link
Member Author

marcotc commented Dec 12, 2019

@delner, I've rebased this PR with master, now that the CircleCI refactor has been merged. Could you take a look at this again?

@delner
Copy link
Contributor

delner commented Feb 5, 2020

@marcotc Can you rebase this again? I'll approve and merge then.

@marcotc
Copy link
Member Author

marcotc commented Feb 5, 2020

Done, thank you @delner!

delner
delner previously approved these changes Apr 15, 2020
Copy link
Contributor

@delner delner left a comment

Choose a reason for hiding this comment

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

👍

@marcotc marcotc requested a review from delner April 15, 2020 21:51
@marcotc marcotc merged commit 79bba99 into master Apr 15, 2020
@marcotc marcotc deleted the test/ci-separate-lint branch April 15, 2020 21:51
@marcotc marcotc added this to the 0.35.0 milestone Apr 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev/testing Involves testing processes (e.g. RSpec)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants