]> git.madduck.net Git - etc/vim.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

[github action] display black result in job summary (#3688)
authorMatthieu Simon <matthieu@bluegreen.sh>
Mon, 15 May 2023 21:35:39 +0000 (23:35 +0200)
committerGitHub <noreply@github.com>
Mon, 15 May 2023 21:35:39 +0000 (14:35 -0700)
* 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)

CHANGES.md
action.yml
action/main.py

index c7ecc396214b3841623e65c50a1991159c468eac..f9bec185ff5839de48230930ead550a8b8cb06a8 100644 (file)
@@ -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
 
 <!-- Major changes to documentation and policies. Small docs changes
 ### Documentation
 
 <!-- Major changes to documentation and policies. Small docs changes
index 35705e994146eb8fbb0ca12ad59a9cca52d46f47..282fca43deac486dbf4145c3c8c812fdd94b7ba6 100644 (file)
@@ -33,11 +33,12 @@ branding:
 runs:
   using: composite
   steps:
 runs:
   using: composite
   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
       env:
         # TODO: Remove once https://github.com/actions/runner/issues/665 is fixed.
         fi
       env:
         # TODO: Remove once https://github.com/actions/runner/issues/665 is fixed.
index 23c3a652194f20049eec3183f93067443b594507..1911cfd7a013ab816929b35fd98a43e5ab0f4809 100644 (file)
@@ -32,7 +32,7 @@ else:
                 describe_name = line[len("describe-name: ") :].rstrip()
                 break
     if not describe_name:
                 describe_name = line[len("describe-name: ") :].rstrip()
                 break
     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)
     # expected format is one of:
     # - 23.1.0
         sys.exit(1)
     # expected format is one of:
     # - 23.1.0
@@ -53,15 +53,25 @@ pip_proc = run(
 )
 if pip_proc.returncode:
     print(pip_proc.stdout)
 )
 if pip_proc.returncode:
     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)
 
 
 base_cmd = [str(ENV_BIN / "black")]
 if BLACK_ARGS:
     # TODO: remove after a while since this is deprecated in favour of SRC + OPTIONS.
     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:
 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)