-
Notifications
You must be signed in to change notification settings - Fork 24
44 lines (36 loc) · 1.14 KB
/
python-format.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
name: Check Black Formatting
on:
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: read
pull-requests: write
jobs:
black-formatting:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black==24.4.2
- name: Run Black formatting check
run: python3 -m black --check .
- name: Add PR review comment if formatting is incorrect
if: failure()
uses: actions/github-script@v4
with:
script: |
const { pull_request } = context.payload;
const comment = "Your code does not meet the Black formatting standards.\nPlease run `python3 -m pip install black==24.4.2 && python3 -m black .` to format your code.";
await github.issues.createComment({
issue_number: pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});