Skip to content

Commit

Permalink
Fix os interop
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-f-cruz committed Dec 27, 2024
1 parent 96956f4 commit 14cf2b5
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions .github/workflows/python-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,32 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Read Python versions
id: set-matrix
run: |
if [[ "$RUNNER_OS" == "Windows" ]]; then
# Windows: Use PowerShell to read the file
if (-Not (Test-Path ".python-version")) {
- name: Set Python versions matrix
run: |
if [[ "$RUNNER_OS" == "Windows" ]]; then
# Windows: Use PowerShell to read the file
pwsh -Command '
if (-Not (Test-Path ".python-version")) {
Write-Error ".python-version file not found"
exit 1
}
$pythonVersions = Get-Content .python-version -Raw | -split ','
$matrixOutput = $pythonVersions | ForEach-Object { $_.Trim() }
$jsonOutput = $matrixOutput -join '","'
$jsonOutput = "[\"$jsonOutput\"]"
echo "::set-output name=versions::$jsonOutput"
else
# Linux/macOS: Use Bash to read the file
if [ ! -f .python-version ]; then
echo ".python-version file not found"
exit 1
fi
PYTHON_VERSIONS=$(cat .python-version | tr ',' '\n' | xargs)
echo "::set-output name=versions::$(echo \"$PYTHON_VERSIONS\" | jq -R 'split(\" \")')"
}
$pythonVersions = Get-Content .python-version -Raw | -split ","
$matrixOutput = $pythonVersions | ForEach-Object { $_.Trim() }
$jsonOutput = $matrixOutput -join "\",\""
$jsonOutput = "[\"$jsonOutput\"]"
Write-Output "::set-output name=versions::$jsonOutput"
'
else
# Linux/macOS: Use Bash to read the file
if [ ! -f .python-version ]; then
echo ".python-version file not found"
exit 1
fi
shell: bash
PYTHON_VERSIONS=$(cat .python-version | tr ',' '\n' | xargs)
echo "::set-output name=versions::$(echo \"$PYTHON_VERSIONS\" | jq -R 'split(\" \")')"
fi
shell: bash


linters:
needs: setup-matrix
Expand Down

0 comments on commit 14cf2b5

Please sign in to comment.