Skip to content

Commit 9e4ebcf

Browse files
tomschrscls19fr
authored and
scls19fr
committed
Extend #186: Add GitHub Action for black formatter (#200)
The GH Action does basically this: 1. Setup Python 3.7 2. Install dependencies (mainly black) 3. Run black and create a diff file 4. Upload the diff as artifact Currently, it does not any pip caching (I had some problems with that; it didn't work reliably).
1 parent 05948ec commit 9e4ebcf

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Black Formatting
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v1
11+
- name: Output env variables
12+
run: |
13+
echo "GITHUB_WORKFLOW=${GITHUB_WORKFLOW}"
14+
echo "GITHUB_ACTION=$GITHUB_ACTION"
15+
echo "GITHUB_ACTIONS=$GITHUB_ACTIONS"
16+
echo "GITHUB_ACTOR=$GITHUB_ACTOR"
17+
echo "GITHUB_REPOSITORY=$GITHUB_REPOSITORY"
18+
echo "GITHUB_EVENT_NAME=$GITHUB_EVENT_NAME"
19+
echo "GITHUB_EVENT_PATH=$GITHUB_EVENT_PATH"
20+
echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE"
21+
echo "GITHUB_SHA=$GITHUB_SHA"
22+
echo "GITHUB_REF=$GITHUB_REF"
23+
echo "GITHUB_HEAD_REF=$GITHUB_HEAD_REF"
24+
echo "GITHUB_BASE_REF=$GITHUB_BASE_REF"
25+
echo "::debug::---Start content of file $GITHUB_EVENT_PATH"
26+
cat $GITHUB_EVENT_PATH
27+
echo "\n"
28+
echo "::debug::---end"
29+
30+
- name: Set up Python 3.7
31+
uses: actions/setup-python@v1
32+
with:
33+
python-version: 3.7
34+
35+
- name: Install dependencies
36+
run: |
37+
python -m pip install --upgrade pip black
38+
39+
- name: Run black
40+
id: black
41+
run: |
42+
black . > project.diff
43+
echo "::set-output name=rc::$?"
44+
45+
- name: Upload diff artifact
46+
uses: actions/upload-artifact@v1
47+
with:
48+
name: black-project-diff
49+
path: project.diff

0 commit comments

Comments
 (0)