Skip to content

Commit

Permalink
Support running inside windows self-hosted runner (#43)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
AngelMF authored Oct 30, 2023
1 parent d499194 commit 530374b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
8 changes: 6 additions & 2 deletions action.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down
7 changes: 6 additions & 1 deletion setup/venv.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 530374b

Please sign in to comment.