Skip to content

Auto-push formatted code - #2

Closed
jneeven wants to merge 6 commits into
lgeiger:masterfrom
jneeven:master
Closed

jneeven wants to merge 6 commits into
lgeiger:masterfrom
jneeven:master

Conversation

@jneeven

@jneeven jneeven commented Sep 30, 2019 •

Copy link
Copy Markdown

Implements #1, and should be seen as a minimal working product rather than finalized code. I got it working with the included example_workflow.yml file. Please ignore the many commits and only look at the end result.

Improvements are very welcome!

Readme Update and add some safety to git commands
@cclauss

cclauss commented Oct 31, 2019

Copy link
Copy Markdown

It has been a month... What is the status of this PR?

@lgeiger Will you review/merge?

If not, @jneeven would you be willing to create a new Action in the Marketplace?

@jneeven

jneeven commented Oct 31, 2019

Copy link
Copy Markdown
Author

@cclauss sure, would you be willing to do some testing beforehand? I merged a pull request from @Ahuge and was seeing some issues in one of my projects, but don't have time to look into the details right now (I think that it crashed on installing black or something). If you could verify that it works, I'd be happy to put it on the marketplace (though it is far from optimal yet).

@Ahuge

Ahuge commented Oct 31, 2019

Copy link
Copy Markdown

Black updated and now requires the regex package. So we need gcc now.
https://github.com/jneeven/black-action/compare/master...Ahuge:master

I followed a PR from #4

@shahzebsiddiqui

Copy link
Copy Markdown

I can't get my black workflow to autoformat python code. It looks like it tried to format but doesn't intercept this in precommit. Isn't there supposed to be a commit by some bot to make this happen otherwise how will change be applied.
https://github.com/HPC-buildtest/buildtest-framework/blob/master/.github/workflows/black.yml

@shahzebsiddiqui

Copy link
Copy Markdown

So even if I push my code. The local branch has my code unformated. So a pull rebase doesn't change my code either. I can see when running black locally it formats all my code and then pushing it everything gets fixed. So it's not triggered properly on PR

@cclauss

cclauss commented Feb 21, 2020 •

Copy link
Copy Markdown

Look at the commits in this PR... TheAlgorithms/Python#1779

The change to the first file was made by me in the first commit. The changes to the other three files was made in the second commit by the autoblack GitHub Action.

We use autoblack to add a second, automatic commit to a PR that black formats the code. This only succeeds if the author of the PR has write access to this repo.

@Ahuge

Ahuge commented Feb 21, 2020 •

Copy link
Copy Markdown

Yeah I've got a fork that has things working too if you need. https://github.com/Ahuge/black-action

name: Black Code Formatting on PR

on: [pull_request]

jobs:
    pr-lint:
        runs-on: ubuntu-latest
        steps:
            - uses: actions/checkout@v1
              name: Checkout
            - uses: Ahuge/[email protected]
              env:
                GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
                BLACK_ARGS: "."

@shahzebsiddiqui

Copy link
Copy Markdown

thanks @cclauss @Ahuge for quick response. I will certainly try out and see which one works. It would be nice to have it pushed to marketplace if it works.

shahzebsiddiqui referenced this pull request in researchapps/buildtest-framework Feb 21, 2020
@jneeven jneeven closed this Aug 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants