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

Use multiple rubocop formats in Travis build #18

Merged
merged 2 commits into from
Apr 24, 2020

Conversation

Cruikshanks
Copy link
Member

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

  • rubocop does allow multiple formatters to be specified
  • bundle exec rubocop --format=json --out=rubocop-result.json returning exit code 1 was valid. It was our local passing runs that were invalid

On 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!

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](https://github.com/DEFRA/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](DEFRA/waste-carriers-engine#806).

What came to light was

- rubocop does allow multiple formatters to be specified
- `bundle exec rubocop --format=json --out=rubocop-result.json` returning exit code 1 was valid. It was our local passing runs that were invalid

On this basis, we're going through all our repos and updating the Travis config to use an updated rubocop command

```bash
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!
@Cruikshanks Cruikshanks added the housekeeping Changes such as refactoring label Apr 24, 2020
@Cruikshanks Cruikshanks self-assigned this Apr 24, 2020
@Cruikshanks Cruikshanks marked this pull request as ready for review April 24, 2020 12:18
@Cruikshanks Cruikshanks merged commit 094c37f into master Apr 24, 2020
@Cruikshanks Cruikshanks deleted the use-multiple-rubocop-formats-in-build branch April 24, 2020 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
housekeeping Changes such as refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants