A Github action that creates annotations are created for errors, warnings, and convention offenses in a JSON Rubocp output file.
Based on https://github.com/duderman/rubocop-annotate-action
Why process Rubocop output intead of running an action that both runs Rubocop and generates annotations?
You can run any version of Rubocop with any configuration you like, with any plugins, and any version of Ruby
All this action cares about is that you have a JSON file that is full of Rubocop output.
- Required
- The name of the JSON file that will be parsed.
- Default
rubocop.json
.
name: Rubocop
on: push
jobs:
rubocop:
name: Rubocop
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-ruby@v1
with:
ruby-version: '2.7'
- run: gem install rubocop --no-doc
- name: Run Rubocop and create a JSON output file named "rubocop.json"
run: rubocop --format progress --format json --out rubocop.json
- name: Create annotations from Rubocop offenses found in rubocop.json if there is a failure in the steps above
uses: weedySeaDragon/rubocop-annotate-action@v0.3.0
with:
path: rubocop.json
if: ${{ failure() }}