-
Notifications
You must be signed in to change notification settings - Fork 31
43 lines (35 loc) · 1.31 KB
/
black-format-code.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
# SPDX-FileCopyrightText: 2017-2024 Contributors to the OpenSTEF project <[email protected]> # noqa E501
#
# SPDX-License-Identifier: MPL-2.0
# Copied from https://github.com/rickstaa/action-black
# GitHub Action that uses Black to reformat the Python code in an incoming pull request.
# If all Python code in the pull request is compliant with Black then this Action
# does nothing. Otherwise, Black is run and its changes are suggested in the
# incoming pull request. See
# https://github.com/rickstaa/action-black?tab=readme-ov-file#annotate-changes
# for a similar example.
name: Black Format Code
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11']
permissions:
# Give the default GITHUB_TOKEN write permission to the pull request
# so that reviewdog can create annotations.
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check formatting using black
uses: rickstaa/action-black@v1
id: action_black
with:
black_args: "."
- name: Annotate diff changes using reviewdog
if: steps.action_black.outputs.is_formatted == 'true'
uses: reviewdog/action-suggester@v1
with:
tool_name: blackfmt