Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auto_fix: true fails when there are no changes to commit #140

Open
brennanwilkes opened this issue Dec 27, 2020 · 8 comments
Open

auto_fix: true fails when there are no changes to commit #140

brennanwilkes opened this issue Dec 27, 2020 · 8 comments
Labels
bug Something isn't working

Comments

@brennanwilkes
Copy link

  Verifying setup for ESLint…
  Verified ESLint setup
  Will use ESLint to check the files with extensions js
  Linting and auto-fixing files in /home/runner/work/***/*** with ESLint…
  ESLint found 6 errors (failure)
  Changes found with Git
  Committing changes
  Error: Error: Command failed: git commit -am "Fix code style issues with ESLint"
  /home/runner/work/_actions/wearerequired/lint-action/v1/dist/index.js:1108
  	throw new Error(`Exiting because of unhandled promise rejection`);
  	^
  
  Error: Exiting because of unhandled promise rejection
      at process.<anonymous> (/home/runner/work/_actions/wearerequired/lint-action/v1/dist/index.js:1108:8)
      at process.emit (events.js:210:5)
      at processPromiseRejections (internal/process/promises.js:201:33)
      at processTicksAndRejections (internal/process/task_queues.js:94:32)```
@ocean90 ocean90 added the bug Something isn't working label Jan 4, 2021
@ocean90
Copy link
Member

ocean90 commented Jan 4, 2021

Hi, thanks for the report. That's odd since changes were detected. Can you provide more details about your setup please?

@ghost
Copy link

ghost commented Jan 15, 2021

I see the same issue on a number of our repos using Swiftlint as the linter.

@ghost
Copy link

ghost commented Jan 22, 2021

@brennanwilkes FWIW, I had success seeing that my runner actually had a modified file outside the linter directory which caused this error for me.

Enabling debug as described here: https://docs.github.com/en/actions/managing-workflow-runs/enabling-debug-logging showed me the file and I was able to git rm and gitignore the file since it was only an "unneeded" file

@wh1t3h47
Copy link

The same thing happens with my setup: https://github.com/wh1t3h47/teste-desenvolvimento-web/runs/3198622148
It detects changes when there are none

@wh1t3h47
Copy link

wh1t3h47 commented Aug 1, 2021

Hello, I enabled debugging as described by @ghost (thank you a lot!)
So I found out the issue with my repository, the problem is that yarn.lock is modified when lint-action runs, so it detects a change, but it fails to commit. I think the action writes to the file, but doesn't change anything in its content...

A possible workaround for this is enabling an empty commit, I know you can pass that option to git - I used to do it when I needed to test pre-commit hooks, as they lint the code and remove my change when I add some spaces to the code.

In my case, what I did was just remove the yarn lockfile before linting (using the yml file), I don't know if this holds any consequence, but I don't think so, as the action shouldn't be messing with dependencies, only having them installed to run.

My suggestion is that you add in the example a workflow that checks for lockfiles (npm, yarn) and unstages them before commiting, this would help people that may have issues with the lint-action

@AnthonyLzq
Copy link

@wh1t3h47, thank you so much for your suggestion, I have added that to my workflow and everything works like a charm.
For those who are interested in a possible approach, here is my lint.yml:

name: Lint

on: [push, pull_request]

jobs:
  run-linters:
    name: Run linters
    runs-on: ubuntu-latest

    steps:
      - name: Check out Git repository
        uses: actions/checkout@v2
        
      - name: Set up Node.js
        uses: actions/setup-node@v1
        with:
          node-version: 16.x

      - name: Install Node.js dependencies
        run: npm install

      - name: Revert changes into the package-lock.json file
        run: git checkout -- package-lock.json

      - name: Run linters
        uses: wearerequired/lint-action@v1
        with:
          auto_fix: true
          eslint: true
          eslint_dir: lib
          eslint_extensions: js

@apgapg
Copy link

apgapg commented Feb 24, 2022

@AnthonyLzq Can we just do git reset --hard just after npm i step and before linter step?

@AnthonyLzq
Copy link

AnthonyLzq commented Feb 24, 2022

Wait, I don't think so, since you haven't commit yet. Git checkout or restore will return to the previous state of your package-lock.json file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants