-
Notifications
You must be signed in to change notification settings - Fork 4
51 lines (41 loc) · 1.43 KB
/
black.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
name: Black Formatting
on: [push, pull_request]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Black:
# The type of runner that the job will run on
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# Setup python version
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.8"
# Install pip and packages
- name: Install pip
run: python -m pip install --upgrade pip
- name: Install black
run: pip install black
# Format with black
- name: Format with black
run: |
black .
# Diff check
- name: Check git diff
# Output the diff in ${GITHUB_WORKSPACE}
run: git diff > black_formatting_diff.patch
# Exit if diff
- name: Set job exit status
run: "[ ! -s black_formatting_diff.patch ]"
# Artifacts
- name: Upload formatting diff
uses: actions/upload-artifact@v2
with:
# We are in ${GITHUB_WORKSPACE}
# ${GITHUB_SHA} won't work: use ${{ github.sha }}
name: black_formatting_diff-${{ github.sha }}
path: black_formatting_diff.patch
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}