-
Notifications
You must be signed in to change notification settings - Fork 246
68 lines (57 loc) · 1.87 KB
/
black.yaml
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Black Style Check
on:
pull_request:
paths:
- '**/*.py'
jobs:
black_check:
name: Check Python Code Style with Black
runs-on: ubuntu-latest
env:
BLACK_OPTIONS: "-l 99 -t py36 -t py37 -t py38 -t py39 -t py310 -t py311"
steps:
- name: Check out the code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.11
- name: Install Black
run: pip install black
- name: Check Code Style with Black
id: black
run: black --check .
- name: Comment on Pull Request (success)
if: steps.build.outcome == 'success'
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: pullRequest } = await github.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
});
await github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: 'Black has checked the code style, and no modifications are required.',
});
- name: Comment on Pull Request (failure)
if: steps.build.outcome != 'success'
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: pullRequest } = await github.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
});
await github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: 'Black has detected code style violations.',
});