File tree Expand file tree Collapse file tree 1 file changed +44
-1
lines changed
Expand file tree Collapse file tree 1 file changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -64,11 +64,54 @@ jobs:
6464 . venv/bin/activate
6565 pre-commit install-hooks
6666
67+ black :
68+ runs-on : ubuntu-latest
69+ needs : prepare
70+ steps :
71+ - name : Check out committed code
72+ uses : actions/checkout@v2
73+ - name : Set up Python ${{ env.DEFAULT_PYTHON }}
74+ id : python
75+ uses : actions/setup-python@v2
76+ with :
77+ python-version : ${{ env.DEFAULT_PYTHON }}
78+ - name : Pre-black
79+ uses : psf/black@stable
80+ - name : Restore base Python ${{ env.DEFAULT_PYTHON }} virtual environment
81+ id : cache-venv
82+ uses : actions/cache@v2
83+ with :
84+ path : venv
85+ key : >-
86+ ${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
87+ steps.python.outputs.python-version }}-${{
88+ hashFiles('requirements_test.txt') }}-${{
89+ hashFiles('setup.py') }}
90+ - name : Fail job if Python cache restore failed
91+ if : steps.cache-venv.outputs.cache-hit != 'true'
92+ run : |
93+ echo "Failed to restore Python ${{ env.DEFAULT_PYTHON }} virtual environment from cache"
94+ exit 1
95+ - name : Install Black
96+ run : pip install black
97+ - name : Run black --check .
98+ run : black --check .
99+ - name : If needed, commit black changes to the pull request
100+ if : failure()
101+ run : |
102+ black .
103+ git config --global user.name 'autoblack'
104+ git config --global user.email '[email protected] ' 105+ git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
106+ git checkout $GITHUB_HEAD_REF
107+ git commit -am "fixup: Format Python code with Black"
108+ git push
109+
67110
68111 commitcheck :
69112 runs-on : ubuntu-latest
70113 name : Check commit
71- needs : prepare
114+ needs : black
72115 steps :
73116 - name : Check out committed code
74117 uses : actions/checkout@v2
You can’t perform that action at this time.
0 commit comments