toshimaru/RailsTwitterClone

View on GitHub
.github/workflows/rubocop.yml

Summary

Maintainability
Test Coverage
name: RuboCop

on: [pull_request]

env:
  BUNDLE_ONLY: rubocop

jobs:

  rubocop:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - name: Set up Ruby
      uses: ruby/setup-ruby@v1
      with:
        ruby-version: 3.3
        bundler-cache: true
        cache-version: rubocop-v2
    - name: Run RuboCop
      run: bundle exec rubocop --parallel -f progress -f html -o tmp/rubocop/report.html
    - uses: actions/upload-artifact@v4
      with:
        name: rubocop-report
        path: tmp/rubocop/report.html

  rubocop-code-scanning:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
    steps:
    - uses: actions/checkout@v4
    - name: Set up Ruby
      uses: ruby/setup-ruby@v1
      with:
        ruby-version: 3.3
        bundler-cache: true
        cache-version: rubocop-v2
    - name: Run RuboCop with Code Scanning
      run: |
        bash -c "
          bundle exec rubocop --require code_scanning --format CodeScanning::SarifFormatter -o rubocop.sarif
          [[ $? -ne 2 ]]
        "
    - name: Upload Sarif output
      uses: github/codeql-action/upload-sarif@v3
      with:
        sarif_file: rubocop.sarif

  reviewdog:
    runs-on: ubuntu-latest
    steps:
    - uses: reviewdog/action-setup@v1
    - uses: actions/checkout@v4
    - name: Set up Ruby
      uses: ruby/setup-ruby@v1
      with:
        ruby-version: 3.3
        bundler-cache: true
        cache-version: rubocop-v2
    - name: Run rubocop & reviewdog
      env:
        REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      run: |
        bundle exec rubocop --parallel | reviewdog -reporter=github-pr-review -f=rubocop -filter-mode=nofilter