Giter Site home page Giter Site logo

Takes too long about action-rubocop HOT 5 CLOSED

reviewdog avatar reviewdog commented on July 18, 2024
Takes too long

from action-rubocop.

Comments (5)

karlentwistle avatar karlentwistle commented on July 18, 2024 7

Firstly I wanted to say I love this project. It's fantastic!


Is it normal that it takes so long if I just add the yml to the workflow?

@paulomcnally, I'm guessing you have quite a large codebase? We managed to work around this issue by only having RuboCop lint files that have changed in the current pull request. The entire workflow is as follows:

name: reviewdog
on: [pull_request]
jobs:
  rubocop:
    name: runner / rubocop
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

      - name: Retrive and store changed ruby files
        run: echo "INPUT_RUBOCOP_FLAGS=$(git diff --name-only --diff-filter=ACMRTUXB origin/master | grep  -E "(\.rb$)" | tr '\n' ' ')" >> $GITHUB_ENV

      - uses: ruby/setup-ruby@v1
        if: ${{ env.INPUT_RUBOCOP_FLAGS }}

      - name: Linting following files
        run: echo $INPUT_RUBOCOP_FLAGS
        if: ${{ env.INPUT_RUBOCOP_FLAGS }}

      - name: rubocop
        uses: BiggerPockets/action-rubocop@0b9fdc012b541882a0d8b74cc74ebbbab200bb30
        with:
          rubocop_version: gemfile
          rubocop_extensions: rubocop-rails:gemfile
        if: ${{ env.INPUT_RUBOCOP_FLAGS }}

The only complication was needing to fork this repo so we could stop INPUT_RUBOCOP_FLAGS from being overwritten BiggerPockets@0b9fdc0

I thought I'd share in case it's helpful to anyone else. It got our linting times down from about 8 minutes to around 6 seconds.

Also, if there is a better way to do this, please let me know.

from action-rubocop.

dbackeus avatar dbackeus commented on July 18, 2024 2

We managed to work around this issue by only having RuboCop lint files that have changed in the current pull request

Seems like this should be the default behaviour, or at least a simple option to enable?

Getting a linting failure because of code not touched in a given PR is not how we would like the action to behave.

from action-rubocop.

igray avatar igray commented on July 18, 2024 1

If it helps anyone else, this is very similar to the above, but does not require a fork:

name: reviewdog
on: [pull_request]
jobs:
  rubocop:
    name: runner / rubocop
    runs-on: ubuntu-latest

    steps:
      - name: Check out code
        uses: actions/checkout@v4
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: 3.0.6

      - name: Fetch mainline branch for comparison (required for next step)
        run: git fetch origin main

      - name: Retrieve and store changed ruby files
        id: changed-files
        run: echo "CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB FETCH_HEAD | grep -E "(\.rb$)" | tr '\n' ' ')" >> $GITHUB_OUTPUT

      - name: Linting the following files
        env:
          CHANGED_FILES: ${{ steps.changed-files.outputs.CHANGED_FILES }}
        run: echo $CHANGED_FILES

      - name: rubocop
        uses: reviewdog/action-rubocop@v2
        with:
          rubocop_flags: ${{ steps.changed-files.outputs.CHANGED_FILES }}
          rubocop_version: gemfile
          rubocop_extensions: rubocop-rails:gemfile rubocop-rspec:gemfile rubocop-performance:gemfile
          reporter: github-pr-review

from action-rubocop.

dbackeus avatar dbackeus commented on July 18, 2024 1

Also in case it helps, we ended up creating an alternative rubocop action at https://github.com/reclaim-the-stack/rubocop-action

This one only runs on changed files by default. It also has a very clean inline commenting approach which fully deletes comments after offences are resolved. Ie. it doesn't leave any noise behind in the PR.

from action-rubocop.

mgrachev avatar mgrachev commented on July 18, 2024

Hi! Could you provide a log to check the problem?

from action-rubocop.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.