Skip to content

Commit

Permalink
Update example to use Bundler (#97)
Browse files Browse the repository at this point in the history
Since Rubocop has multiple gems, it's best to rely on Bundler to install them rather than not. Other popular gems like Rails use this same feature to optimize their rubocop workflows. https://github.com/rails/rails/blob/main/.github/workflows/rubocop.yml
  • Loading branch information
javierjulio authored Feb 28, 2024
1 parent 2f726ae commit 5340172
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,30 +100,44 @@ Optional. Run Rubocop with bundle exec. Default: `false`.

## Example usage

You can create [RuboCop Configuration](https://docs.rubocop.org/rubocop/configuration.html) and this action uses that config too.
This action will use your [RuboCop Configuration](https://docs.rubocop.org/rubocop/configuration.html) automatically.

In your `Gemfile`, ensure all Rubocop gems are in a named (e.g. rubocop) group:

```ruby
group :development, :rubocop do
gem 'rubocop', require: false
gem 'rubocop-rails', require: false
# ...
end
```

Create the following workflow. The `BUNDLE_ONLY` environment variable will tell Bundler to only install the specified group.

```yml
name: reviewdog
on: [pull_request]
on:
pull_request:
permissions:
contents: read
pull-requests: write
jobs:
rubocop:
name: runner / rubocop
runs-on: ubuntu-latest
env:
BUNDLE_ONLY: rubocop
steps:
- name: Check out code
uses: actions/checkout@v4
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0.0
- name: rubocop
uses: reviewdog/action-rubocop@v2
ruby-version: '3.3'
bundler-cache: true
- uses: reviewdog/action-rubocop@v2
with:
rubocop_version: gemfile
rubocop_extensions: rubocop-rails:gemfile rubocop-rspec:gemfile
reporter: github-pr-review # Default is github-pr-check
skip_install: true
use_bundler: true
```
## Sponsor
Expand Down

0 comments on commit 5340172

Please sign in to comment.