[github action] display black result in job summary (#3688)
* send output to $GITHUB_STEP_SUMMARY * update CHANGES.md * update CHANGES.md with PR number * implement PR feedback * fix pre-commit issues (prettier/trailing whitespace)
This commit is contained in:
parent
64887aab03
commit
c97b9c55b4
@ -45,6 +45,8 @@
|
|||||||
|
|
||||||
<!-- For example, Docker, GitHub Actions, pre-commit, editors -->
|
<!-- For example, Docker, GitHub Actions, pre-commit, editors -->
|
||||||
|
|
||||||
|
- Update GitHub Action to display black output in the job summary (#3688)
|
||||||
|
|
||||||
### Documentation
|
### Documentation
|
||||||
|
|
||||||
<!-- Major changes to documentation and policies. Small docs changes
|
<!-- Major changes to documentation and policies. Small docs changes
|
||||||
|
@ -33,11 +33,12 @@ branding:
|
|||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
steps:
|
steps:
|
||||||
- run: |
|
- name: black
|
||||||
|
run: |
|
||||||
if [ "$RUNNER_OS" == "Windows" ]; then
|
if [ "$RUNNER_OS" == "Windows" ]; then
|
||||||
python $GITHUB_ACTION_PATH/action/main.py
|
python $GITHUB_ACTION_PATH/action/main.py | tee -a $GITHUB_STEP_SUMMARY
|
||||||
else
|
else
|
||||||
python3 $GITHUB_ACTION_PATH/action/main.py
|
python3 $GITHUB_ACTION_PATH/action/main.py | tee -a $GITHUB_STEP_SUMMARY
|
||||||
fi
|
fi
|
||||||
env:
|
env:
|
||||||
# TODO: Remove once https://github.com/actions/runner/issues/665 is fixed.
|
# TODO: Remove once https://github.com/actions/runner/issues/665 is fixed.
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
describe_name = line[len("describe-name: ") :].rstrip()
|
describe_name = line[len("describe-name: ") :].rstrip()
|
||||||
break
|
break
|
||||||
if not describe_name:
|
if not describe_name:
|
||||||
print("::error::Failed to detect action version.", flush=True)
|
print("::error::Failed to detect action version.", file=sys.stderr, flush=True)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
# expected format is one of:
|
# expected format is one of:
|
||||||
# - 23.1.0
|
# - 23.1.0
|
||||||
@ -53,15 +53,25 @@
|
|||||||
)
|
)
|
||||||
if pip_proc.returncode:
|
if pip_proc.returncode:
|
||||||
print(pip_proc.stdout)
|
print(pip_proc.stdout)
|
||||||
print("::error::Failed to install Black.", flush=True)
|
print("::error::Failed to install Black.", file=sys.stderr, flush=True)
|
||||||
sys.exit(pip_proc.returncode)
|
sys.exit(pip_proc.returncode)
|
||||||
|
|
||||||
|
|
||||||
base_cmd = [str(ENV_BIN / "black")]
|
base_cmd = [str(ENV_BIN / "black")]
|
||||||
if BLACK_ARGS:
|
if BLACK_ARGS:
|
||||||
# TODO: remove after a while since this is deprecated in favour of SRC + OPTIONS.
|
# TODO: remove after a while since this is deprecated in favour of SRC + OPTIONS.
|
||||||
proc = run([*base_cmd, *shlex.split(BLACK_ARGS)])
|
proc = run(
|
||||||
|
[*base_cmd, *shlex.split(BLACK_ARGS)],
|
||||||
|
stdout=PIPE,
|
||||||
|
stderr=STDOUT,
|
||||||
|
encoding="utf-8",
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
proc = run([*base_cmd, *shlex.split(OPTIONS), *shlex.split(SRC)])
|
proc = run(
|
||||||
|
[*base_cmd, *shlex.split(OPTIONS), *shlex.split(SRC)],
|
||||||
|
stdout=PIPE,
|
||||||
|
stderr=STDOUT,
|
||||||
|
encoding="utf-8",
|
||||||
|
)
|
||||||
|
print(proc.stdout)
|
||||||
sys.exit(proc.returncode)
|
sys.exit(proc.returncode)
|
||||||
|
Loading…
Reference in New Issue
Block a user