Debian Codegraph @

action.yml

raw
1 name: "Black"
2 description: "The uncompromising Python code formatter."
3 author: "Łukasz Langa and contributors to Black"
4 inputs:
5 options:
6 description:
7 "Options passed to Black. Use `black --help` to see available options. Default:
8 '--check --diff'"
9 required: false
10 default: "--check --diff"
11 src:
12 description: "Source to run Black. Default: '.'"
13 required: false
14 default: "."
15 jupyter:
16 description:
17 "Set this option to true to include Jupyter Notebook files. Default: false"
18 required: false
19 default: false
20 black_args:
21 description: "[DEPRECATED] Black input arguments."
22 required: false
23 default: ""
24 deprecationMessage:
25 "Input `with.black_args` is deprecated. Use `with.options` and `with.src` instead."
26 version:
27 description: 'Python Version specifier (PEP440) - e.g. "21.5b1"'
28 required: false
29 default: ""
30 use_pyproject:
31 description: Read Black version specifier from pyproject.toml if `true`.
32 required: false
33 default: "false"
34 summary:
35 description: "Whether to add the output to the workflow summary"
36 required: false
37 default: true
38 output-file:
39 description: >
40 Optional path to write Black output to a file in addition to stdout. Useful for
41 keeping GitHub Actions logs clean when using --diff or --check.
42 required: false
43 default: ""
44 branding:
45 color: "black"
46 icon: "check-circle"
47 runs:
48 using: composite
49 steps:
50 - name: black
51 run: |
52 # Even when black fails, do not close the shell
53 set +e
54
55 if [ "$RUNNER_OS" == "Windows" ]; then
56 runner="python"
57 else
58 runner="python3"
59 fi
60
61 out=$(${runner} $GITHUB_ACTION_PATH/action/main.py)
62 exit_code=$?
63
64 # Display the raw output in the step
65 echo "${out}"
66
67 if [ "${INPUT_SUMMARY}" == "true" ]; then
68 # Display the Markdown output in the job summary
69 echo "\`\`\`python" >> $GITHUB_STEP_SUMMARY
70 echo "${out}" >> $GITHUB_STEP_SUMMARY
71 echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
72 fi
73
74 # Exit with the exit-code returned by Black
75 exit ${exit_code}
76 env:
77 # TODO: Remove once https://github.com/actions/runner/issues/665 is fixed.
78 INPUT_OPTIONS: ${{ inputs.options }}
79 INPUT_SRC: ${{ inputs.src }}
80 INPUT_JUPYTER: ${{ inputs.jupyter }}
81 INPUT_BLACK_ARGS: ${{ inputs.black_args }}
82 INPUT_VERSION: ${{ inputs.version }}
83 INPUT_USE_PYPROJECT: ${{ inputs.use_pyproject }}
84 INPUT_SUMMARY: ${{ inputs.summary }}
85 OUTPUT_FILE: ${{ inputs.output-file }}
86 pythonioencoding: utf-8
87 shell: bash