Use multiple rubocop formats in Travis build #18
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We initially used the default
progress
formatter when we first started building with Travis for our CI. When we then integrated with SonarCloud we switched the format to output a JSON file as that was what it needed. This meant if we got any rubocop issues it was no longer possible to see them in the build output. You would have to check SonarCloud.Recently we have been getting a few projects fail because
bundle exec rubocop --format=json --out=rubocop-result.json
was returning exit code 1. As we couldn't immediately recreate the issue locally we assumed something might be broken with rubocop or our setup and chalked it up for further investigation. At the same time, we made sure our project defra-ruby-style was using the latest version of rubocop and pushed a new release. This triggered a number of broken builds across our projects which forced us to investigate the whole issue now.What came to light was
bundle exec rubocop --format=json --out=rubocop-result.json
returning exit code 1 was valid. It was our local passing runs that were invalidOn this basis, we're going through all our repos and updating the Travis config to use an updated rubocop command
bundle exec rubocop --format progress --format json --out rubocop-result.json
This will mean we'll not only provide what SonarCloud needs, but we'll see immediately if the failure is because rubocop thinks there has been a violation. Hopefully, this will stop us getting confused in future!