Skip to content

Commit

Permalink
basic setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Raymond Gasper committed May 22, 2020
1 parent 1d8b6f4 commit 555f6a9
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Dockerfile
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"]
40 changes: 40 additions & 0 deletions README.md
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
```
4 changes: 4 additions & 0 deletions entrypoint.sh
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}

0 comments on commit 555f6a9

Please sign in to comment.