Skip to content

Quote $PYTHON_BIN in deprecated composite action - #646

Merged
EnricoMi merged 1 commit into
EnricoMi:masterfrom
ArloL:patch-1
Mar 10, 2025
Merged

EnricoMi merged 1 commit into
EnricoMi:masterfrom
ArloL:patch-1

Conversation

@ArloL

@ArloL ArloL commented Mar 10, 2025 •

Copy link
Copy Markdown
Contributor

This applies #587 to the deprecated composite action. Fixes the deprecated composite action for hosts where Python is installed in paths containing spaces, Windows is most likely affected.

@EnricoMi

Copy link
Copy Markdown
Owner

What is your use case that requires the composite action and not the other OS-specific actions?

@ArloL

ArloL commented Mar 10, 2025

Copy link
Copy Markdown
Contributor Author

Short story:
I don't have one really. We now migrated to windows/bash. This just caused a little more confusion than was necessary and I want to prevent others from this - since the fix is very easy.

Long story:
We have a repository of shared workflows used in ~160 repos. The versions of the action were all over the place (e.g. composite@2c22e159ac28914d942580607e51a7bc627a7150). I made them consistent by updating all references to @v2.18.0. At this point I knew nothing of the deprecation so I kept composite. The change got pushed out. I was sick a few days. It broke builds. A colleague had to test where this came from. The windows build in question takes like 30 minutes with only one runner available (yeah, I know). At some point my colleague figured out it was the update to v2.18.0 and reverted back. Now I'm back and started analyzing what happened. First I thought it was the python environment - nothing changed there. Then I thought it was maybe a breaking change and went through the release notes. Learnt of the deprecation. Then I used the windows version - which didn't work due to pwsh not being available. Then I found the windows/bash version and used that. It worked. Then I was curious to figure out what happened in the composite that broke the build and and narrowed it down to this quoting issue and thought: well it is deprecated … buut the fix is so easy and this caused me so much pain updating that I might as well make a PR. So here we are ☺️

@EnricoMi

EnricoMi commented Mar 10, 2025 •

Copy link
Copy Markdown
Owner

Thanks for the insights. I will improve the README.md to point to the Windows bash variant at the very top. And I will make the migration steps from composite for Windows to Windows bash action explicit. #647

@EnricoMi

Copy link
Copy Markdown
Owner

Have you tested this change in your side? They may be other hick-ups further down the code.

@EnricoMi

EnricoMi commented Mar 10, 2025 •

Copy link
Copy Markdown
Owner

Regarding the deprecation: it would be great to document why the composite action is deprecated. Is it too much maintenance effort? Too much to test?

Yeah, it is mainly maintaining duplicated code. The only benefit of the composite action is that it can be run on arbitrary OS, but that could be achieved with the OS-specific actions and a if: runner.os == 'Windows'.

Example: #647

@ArloL

ArloL commented Mar 10, 2025

Copy link
Copy Markdown
Contributor Author

I did not test it. A glance at diff composite/action.yml windows/bash/action.yml looks good to me

154,159d153
<     - name: Deprecation warning
<       run: |
<         # Print deprecation warning
<         echo "::warning::Running this action via 'uses: EnricoMi/publish-unit-test-result-action/composite@v2 is deprecated! For details, see: https://github.com/EnricoMi/publish-unit-test-result-action/tree/v2#running-as-a-composite-action"
<       shell: bash
< 
198,215d191
<     - name: Detect OS
<       id: os
<       run: |
<         # Detect OS
<         case "$RUNNER_OS" in
<           Linux*)
<             echo "pip-cache=~/.cache/pip" >> "$GITHUB_OUTPUT"
<             ;;
<           macOS*)
<             echo "pip-cache=~/Library/Caches/pip" >> "$GITHUB_OUTPUT"
<             ;;
<           Windows*)
<             echo "pip-cache=~\\AppData\\Local\\pip\\Cache" >> "$GITHUB_OUTPUT"
<             echo "pip-options=--user" >> "$GITHUB_OUTPUT"
<             ;;
<         esac
<       shell: bash
< 
221c197
<         path: ${{ steps.os.outputs.pip-cache }}
---
>         path: '~\AppData\Local\pip\Cache'
227,228d202
<       env:
<         PIP_OPTIONS: ${{ steps.os.outputs.pip-options }}
239c213
<           if ! "$PYTHON_BIN" -m pip install $PIP_OPTIONS virtualenv && [ -n "$PIP_OPTIONS" ]
---
>           if ! "$PYTHON_BIN" -m pip install --user virtualenv
241c215
<             echo "Installing virtualenv package with PIP options '$PIP_OPTIONS' failed, now trying without"
---
>             echo "Installing virtualenv package with PIP options '--user' failed, now trying without"
257,262c231
<         case "$RUNNER_OS" in
<           Linux*|macOS*)
<             PYTHON_VENV="enricomi-publish-action-venv/bin/python";;
<           Windows*)
<             PYTHON_VENV="enricomi-publish-action-venv\\Scripts\\python";;
<         esac
---
>         PYTHON_VENV="enricomi-publish-action-venv\\Scripts\\python"
274c243
<         "$PYTHON_VENV" -m pip install -r "$GITHUB_ACTION_PATH/../python/requirements-$DEPENDENCIES_VERSION.txt"
---
>         "$PYTHON_VENV" -m pip install -r "$GITHUB_ACTION_PATH/../../python/requirements-$DEPENDENCIES_VERSION.txt"
283c252
<         "$PYTHON_VENV" "$GITHUB_ACTION_PATH/../python/publish_test_results.py"
---
>         "$PYTHON_VENV" "$GITHUB_ACTION_PATH/../../python/publish_test_results.py"
336c305
<         path: ${{ steps.os.outputs.pip-cache }}
---
>         path: '~\AppData\Local\pip\Cache'

@github-actions

Copy link
Copy Markdown

Test Results (reference)

   180 files  ±0     180 suites  ±0   44m 37s ⏱️ +46s
   438 tests ±0     438 ✅ ±0      0 💤 ±0  0 ❌ ±0 
78 840 runs  ±0  77 202 ✅ ±0  1 638 💤 ±0  0 ❌ ±0 

Results for commit 1068c4f. ± Comparison against base commit 11089df.

@EnricoMi EnricoMi left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@EnricoMi EnricoMi changed the title fix(composite): quote $PYTHON_BIN Quote $PYTHON_BIN in deprecated composite action Mar 10, 2025
@EnricoMi EnricoMi changed the title Quote $PYTHON_BIN in deprecated composite action Quote $PYTHON_BIN in deprecated composite action Mar 10, 2025
@EnricoMi
EnricoMi merged commit 6cc8c3c into EnricoMi:master Mar 10, 2025
@ArloL
ArloL deleted the patch-1 branch March 10, 2025 21:31
@EnricoMi

EnricoMi commented Apr 1, 2025

Copy link
Copy Markdown
Owner

This has been released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants