From 530374b67a3e8b3972d2caae7ee9a1d3dd486329 Mon Sep 17 00:00:00 2001 From: AngelMF Date: Mon, 30 Oct 2023 15:04:30 -0700 Subject: [PATCH] Support running inside windows self-hosted runner (#43) * Add couple lines in action.py, action.yml and venv.bash to support running inside windows self-hosted runner * Fixed new lines based on William Woodruff feedback --- action.py | 8 ++++++-- action.yml | 2 +- setup/venv.bash | 7 ++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/action.py b/action.py index dd624ad..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 diff --git a/action.yml b/action.yml index 39e9d3d..e5b3aec 100644 --- a/action.yml +++ b/action.yml @@ -71,7 +71,7 @@ runs: # NOTE: Sourced, not executed as a script. source "${{ github.action_path }}/setup/venv.bash" - ${{ github.action_path }}/action.py "${{ inputs.inputs }}" + 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 3e60645..cdde0cc 100644 --- a/setup/venv.bash +++ b/setup/venv.bash @@ -17,7 +17,12 @@ 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 - source "${GHA_PIP_AUDIT_VIRTUAL_ENVIRONMENT}/bin/activate" + if [[ "$(uname)" == MSYS_NT* || "$(uname)" == MINGW* ]]; then + # execute in windows + source "${GHA_PIP_AUDIT_VIRTUAL_ENVIRONMENT}/scripts/activate" + else + source "${GHA_PIP_AUDIT_VIRTUAL_ENVIRONMENT}/bin/activate" + fi else die "Fatal: virtual environment is not a directory" fi