Closed1

Use reviewdog/rubocop in GitHub Actions

nyancatnyancat

This scrap is about how to use reviewdog/action-rubocop: Run rubocop with reviewdog 🐶 in GitHub Actions.

The simplest way: with rubocop installation

.github/workflows/rubocop.yml
name: reviewdog
on: [pull_request]
permissions:
  contents: read
  pull-requests: write
jobs:
  rubocop:
    name: runner / rubocop
    runs-on: ubuntu-latest
    steps:
      - name: Check out code
        uses: actions/checkout@v3
      - uses: ruby/setup-ruby@v1
      - name: rubocop
        uses: reviewdog/action-rubocop@v2
        with:
          rubocop_version: gemfile
          rubocop_extensions: rubocop-performance:gemfile rubocop-rails:gemfile rubocop-rspec:gemfile
          reporter: github-pr-review # Default is github-pr-check

Another way: skip installing rubocop as it's already cached by bundler. Use skip_install and use_bundler options with bundler-cache: true of setup-ruby.

Cache ruby gems to speed up installation · Issue #83 · reviewdog/action-rubocop

.github/workflows/rubocop.yml
name: reviewdog
on: [pull_request]
permissions:
  contents: read
  pull-requests: write
jobs:
  rubocop:
    name: runner / rubocop
    runs-on: ubuntu-latest
    steps:
      - name: Check out code
        uses: actions/checkout@v3
      - uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true # runs 'bundle install' and caches installed gems automatically
      - name: rubocop
        uses: reviewdog/action-rubocop@v2
        with:
          rubocop_version: gemfile
          rubocop_extensions: rubocop-performance:gemfile rubocop-rails:gemfile rubocop-rspec:gemfile
          reporter: github-pr-review # Default is github-pr-check
          skip_install: true
          use_bundler: true
このスクラップは2023/09/19にクローズされました