wearerequired / lint-action

✨ GitHub Action for detecting and auto-fixing lint errors
MIT License
568 stars 136 forks source link

rubocop issue #701

Closed milani closed 1 year ago

milani commented 1 year ago

When I use the action like below:

name: Lint

on:
  pull_request:
    types:
      - opened
      - edited
      - synchronize

jobs:
  rubocop:
    runs-on: ubuntu-latest
    steps:
    - name: Git checkout
      uses: actions/checkout@v3

    - name: Set up ruby
      uses: ruby/setup-ruby@v1
      with:
        ruby-version: 3.2.2
        bundler-cache: true

    - name: Rubocop Linter
      uses: wearerequired/lint-action@v2
      with:
        git_name: 'Lint Autocorrect'
        git_email: 'lint-autocorrect@example.com'
        github_token: ${{ secrets.GITHUB_TOKEN }}
        rubocop: true
        auto_fix: false
        rubocop_command_prefix: bundle exec
        rubocop_args: "--fail-level r" # fail even for Refactor level cops

I receive an error:

Verifying setup for RuboCop…
  bundler: failed to load command: rubocop (/home/runner/work/example/example/vendor/bundle/ruby/3.2.0/bin/rubocop)

I verified that rubocop is installed by adding - run: bundle exec rubocop -v between setup-ruby and Rubocop Linter steps.

I believe this happens because setup-ruby installs gems in vendor directory:

/opt/hostedtoolcache/Ruby/3.2.2/x64/bin/bundle config --local path /home/runner/work/example/example/vendor/bundle
/opt/hostedtoolcache/Ruby/3.2.2/x64/bin/bundle config --local deployment true

and lint-action checks out the branch:

Switching to the "chore-rubocop-action" branch
 * branch            chore-rubocop-action -> FETCH_HEAD
 * [new branch]      chore-rubocop-action -> origin/chore-rubocop-action

So maybe vendor folder disappears here?

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.