-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Raymond Gasper
committed
May 22, 2020
1 parent
1d8b6f4
commit 555f6a9
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM python:3 | ||
|
||
RUN pip install black | ||
|
||
COPY entrypoint.sh /entrypoint.sh | ||
|
||
ENTRYPOINT ["/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Readme | ||
|
||
This is a github action that will run the [black python formatter](https://github.com/psf/black) on a PR, but only on the files changed in your PR. This helps avoid situations where one runs the formatter on an old code base and gets hundreds of files with warnings and hints. | ||
|
||
## Installation | ||
|
||
To install, create a GitHub Actions Workflow: | ||
|
||
```yaml | ||
name: Black | ||
|
||
# Run action on PRs to master | ||
on: | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
suggest: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so that black can inspect it | ||
- uses: actions/checkout@v2 | ||
- uses: rgasper/python-black-pull-request-action@master | ||
env: | ||
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} | ||
``` | ||
## Configuration | ||
By default, runs black with all default configurations except for `--line-length 130`, because 88 characters feels a bit small. This can be changed by assigning the argument in the Workflow. | ||
|
||
```yaml | ||
etc... | ||
- uses: rgasper/python-black-pull-request-action@master | ||
env: | ||
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
line-length: 1000 # please don't do this | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
# TODO make this actually work, probably just convert into pythong | ||
list_of_edited_files=`./git_diff_to_get_list_of_edited_files` | ||
black ${list_of_edited_files} |