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-fixing on pull requests is not committing #18

Closed
davidsassen opened this issue Feb 12, 2020 · 2 comments
Closed

Auto-fixing on pull requests is not committing #18

davidsassen opened this issue Feb 12, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@davidsassen
Copy link

I'm attempting to run an auto-fixing Black linter, and it changes files but then fails to actually commit them.

name: Run Linters

on:
  pull_request:
    paths:
      - 'c***p/**.py'

jobs:
  run-python-linter:
    name: Run Python Linter
    runs-on: ubuntu-latest

    steps:
      - name: Check out Git repository
        uses: actions/checkout@v2

      - name: Set up Python
        uses: actions/setup-python@v1
        with:
          python-version: 3.7

      - name: Install Python dependencies
        run: pip install black

      - name: Run linters
        uses: samuelmeuli/lint-action@v1
        with:
          github_token: ${{ secrets.github_token }}

          black: true
          black_args: -t py37 -l 120 --exclude "/*scripts*"
          black_dir: c****d
          auto_fix: true
          commit_message: Fix code style issues with ${linter}

When I push to a branch that is in pull request, I get the following:

Will use Black to check the files with extensions py
Linting and auto-fixing files in /home/runner/work/Base/B***ad with Black…
reformatted /home/runner/work/Base/Base/c***views.py
All done! ✨ 🍰 ✨
1 file reformatted, 170 files left unchanged.
Black found no issues (success)

SHA of last commit is "704312c7d00bc047a4a552f56760a3f6f8e7dd2a"
Creating GitHub check with 0 annotations for Flake8…
Creating GitHub check with 0 annotations for Black…

I've starred out some file names and directories, sorry for the silly paranoia but it is a private corporate repository. Nonetheless, everything seems to be operating fine, it's finding a file that is indeed out of whack and is reformatting it - it just doesn't seem to recognize that there have been Git changes. I'm guessing this is because of the change to check for changes before committing? When I run Black and then "git diff-index --cached HEAD" on my own machine, it tells me there aren't changes even though there are. Is it possible that the "--cached" option is causing problems?

A potential confounding issue is that the pull request is the one that actually includes the linter workflow.

@samuelmeuli samuelmeuli added the bug Something isn't working label Feb 12, 2020
@samuelmeuli
Copy link
Collaborator

Thanks for reporting the issue! I've just pushed a fix, please let me know whether this is resolved for you with the next release :)

@davidsassen
Copy link
Author

Works great now, thanks very much for the quick fix.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants