From fd4ac54152344037113993f2f88b49c94958f5dc Mon Sep 17 00:00:00 2001 From: amunguia Date: Thu, 26 Oct 2023 20:45:46 -0600 Subject: [PATCH] Fixed new lines based on William Woodruff feedback --- action.py | 17 +++++++++-------- action.yml | 6 +----- setup/venv.bash | 2 +- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/action.py b/action.py index 913853c..3eaffbd 100755 --- a/action.py +++ b/action.py @@ -12,11 +12,15 @@ from base64 import b64encode from pathlib import Path +sys.stdout.reconfigure(encoding="utf-8") + _HERE = Path(__file__).parent.resolve() _TEMPLATES = _HERE / "templates" -_GITHUB_STEP_SUMMARY = Path(os.getenv("GITHUB_STEP_SUMMARY")).open("a") -_GITHUB_OUTPUT = Path(os.getenv("GITHUB_OUTPUT")).open("a") +_GITHUB_STEP_SUMMARY = Path(os.getenv("GITHUB_STEP_SUMMARY")).open( + "a", encoding="utf-8" +) +_GITHUB_OUTPUT = Path(os.getenv("GITHUB_OUTPUT")).open("a", encoding="utf-8") _RENDER_SUMMARY = os.getenv("GHA_PIP_AUDIT_SUMMARY", "true") == "true" _DEBUG = os.getenv("RUNNER_DEBUG") is not None @@ -45,8 +49,7 @@ def _pip_audit(*args): def _fatal_help(msg): - msg = f"::error::❌ {msg}" - print(sys.stdout.buffer.write(msg.encode("utf-8"))) + print(f"::error::❌ {msg}") sys.exit(1) @@ -132,11 +135,9 @@ def _fatal_help(msg): _debug(status.stdout) if status.returncode == 0: - msg = "🎉 pip-audit exited successfully" - _summary(sys.stdout.buffer.write(msg.encode("utf-8"))) + _summary("🎉 pip-audit exited successfully") else: - msg = "❌ pip-audit found one or more problems" - _summary(sys.stdout.buffer.write(msg.encode("utf-8"))) + _summary("❌ pip-audit found one or more problems") output = "⚠️ pip-audit did not return any output" try: diff --git a/action.yml b/action.yml index ec29524..e5b3aec 100644 --- a/action.yml +++ b/action.yml @@ -71,11 +71,7 @@ runs: # NOTE: Sourced, not executed as a script. source "${{ github.action_path }}/setup/venv.bash" - if [[ "${{runner.os}}" == "Windows" ]]; then - python "${{ github.action_path }}/action.py" "${{ inputs.inputs }}" - else - ${{ github.action_path }}/action.py "${{ inputs.inputs }}" - fi + python "${{ github.action_path }}/action.py" "${{ inputs.inputs }}" env: GHA_PIP_AUDIT_SUMMARY: "${{ inputs.summary }}" GHA_PIP_AUDIT_NO_DEPS: "${{ inputs.no-deps }}" diff --git a/setup/venv.bash b/setup/venv.bash index 0250ba3..cdde0cc 100644 --- a/setup/venv.bash +++ b/setup/venv.bash @@ -17,7 +17,7 @@ fi # `python -m pip install ...` invocation might happen to choose. if [[ -n "${GHA_PIP_AUDIT_VIRTUAL_ENVIRONMENT}" ]] ; then if [[ -d "${GHA_PIP_AUDIT_VIRTUAL_ENVIRONMENT}" ]]; then - if [[ "$OSTYPE" == "msys" || "$(uname)" == MSYS_NT* || "$(uname)" == MINGW* ]]; then + if [[ "$(uname)" == MSYS_NT* || "$(uname)" == MINGW* ]]; then # execute in windows source "${GHA_PIP_AUDIT_VIRTUAL_ENVIRONMENT}/scripts/activate" else