From f69ae5aeb46d1634d51ca112eade389fd80c7274 Mon Sep 17 00:00:00 2001 From: tieum Date: Sat, 13 May 2023 16:16:42 +0200 Subject: [PATCH 1/5] send output to $GITHUB_STEP_SUMMARY --- action.yml | 7 ++++--- action/main.py | 20 +++++++++++++++----- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/action.yml b/action.yml index 35705e99414..2de4d3f6901 100644 --- a/action.yml +++ b/action.yml @@ -33,11 +33,12 @@ branding: runs: using: composite steps: - - run: | + - name: black + run: | 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 - python3 $GITHUB_ACTION_PATH/action/main.py + python3 $GITHUB_ACTION_PATH/action/main.py | tee -a $GITHUB_STEP_SUMMARY fi env: # TODO: Remove once https://github.com/actions/runner/issues/665 is fixed. diff --git a/action/main.py b/action/main.py index 23c3a652194..81b06f1c009 100644 --- a/action/main.py +++ b/action/main.py @@ -32,7 +32,7 @@ describe_name = line[len("describe-name: ") :].rstrip() break if not describe_name: - print("::error::Failed to detect action version.", flush=True) + sys.stderr.write("::error::Failed to detect action version.") sys.exit(1) # expected format is one of: # - 23.1.0 @@ -53,15 +53,25 @@ ) if pip_proc.returncode: print(pip_proc.stdout) - print("::error::Failed to install Black.", flush=True) + sys.stderr.write("::error::Failed to install Black.") sys.exit(pip_proc.returncode) base_cmd = [str(ENV_BIN / "black")] if BLACK_ARGS: # 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: - 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) From a2544dcfcc8e41060456b7c786d1905cdf83f851 Mon Sep 17 00:00:00 2001 From: tieum Date: Sat, 13 May 2023 17:34:45 +0200 Subject: [PATCH 2/5] update CHANGES.md --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index c7ecc396214..eeb5b9e9610 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -44,6 +44,8 @@ ### Integrations +- Update GitHub Action to display black output in the job summary + ### Documentation From c18b1ac5a3c9439d02f5351af008e0fb851ff8fa Mon Sep 17 00:00:00 2001 From: tieum Date: Sat, 13 May 2023 18:14:59 +0200 Subject: [PATCH 3/5] update CHANGES.md with PR number --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index eeb5b9e9610..9c5b2919acd 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -44,7 +44,7 @@ ### Integrations -- Update GitHub Action to display black output in the job summary +- Update GitHub Action to display black output in the job summary (#3688) ### Documentation From 2e1ee1e706a6db13c003c5be209df92f37b3bc78 Mon Sep 17 00:00:00 2001 From: tieum Date: Sat, 13 May 2023 18:18:22 +0200 Subject: [PATCH 4/5] implement PR feedback --- action/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action/main.py b/action/main.py index 81b06f1c009..1911cfd7a01 100644 --- a/action/main.py +++ b/action/main.py @@ -32,7 +32,7 @@ describe_name = line[len("describe-name: ") :].rstrip() break if not describe_name: - sys.stderr.write("::error::Failed to detect action version.") + print("::error::Failed to detect action version.", file=sys.stderr, flush=True) sys.exit(1) # expected format is one of: # - 23.1.0 @@ -53,7 +53,7 @@ ) if pip_proc.returncode: print(pip_proc.stdout) - sys.stderr.write("::error::Failed to install Black.") + print("::error::Failed to install Black.", file=sys.stderr, flush=True) sys.exit(pip_proc.returncode) From 27b57016ccd90aba1474b7a15ab6f0e4c906a21d Mon Sep 17 00:00:00 2001 From: tieum Date: Sun, 14 May 2023 14:30:28 +0200 Subject: [PATCH 5/5] fix pre-commit issues (prettier/trailing whitespace) --- CHANGES.md | 2 +- action.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 9c5b2919acd..f9bec185ff5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -44,8 +44,8 @@ ### Integrations -- Update GitHub Action to display black output in the job summary (#3688) +- Update GitHub Action to display black output in the job summary (#3688) ### Documentation diff --git a/action.yml b/action.yml index 2de4d3f6901..282fca43dea 100644 --- a/action.yml +++ b/action.yml @@ -36,7 +36,7 @@ runs: - name: black run: | if [ "$RUNNER_OS" == "Windows" ]; then - python $GITHUB_ACTION_PATH/action/main.py | tee -a $GITHUB_STEP_SUMMARY + python $GITHUB_ACTION_PATH/action/main.py | tee -a $GITHUB_STEP_SUMMARY else python3 $GITHUB_ACTION_PATH/action/main.py | tee -a $GITHUB_STEP_SUMMARY fi