-
Notifications
You must be signed in to change notification settings - Fork 43
45 lines (36 loc) · 1.44 KB
/
black-format-code.yml
File metadata and controls
45 lines (36 loc) · 1.44 KB
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
# 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]
permissions: {}
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@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Check formatting using black
uses: rickstaa/action-black@d86849e16a3c498947d70be55198feb86d5d4f53 # 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@aa38384ceb608d00f84b4690cacc83a5aba307ff # v1
with:
tool_name: blackfmt