From 5559df10920a45510443bba23f0bfd24ea2049fd Mon Sep 17 00:00:00 2001 From: Ruben Arts Date: Fri, 16 Feb 2024 08:21:48 +0100 Subject: [PATCH 01/13] test: add pwsh and cmd as pixi shells --- .github/workflows/test.yml | 7 +++++++ README.md | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index af3692b..39a026e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -333,6 +333,13 @@ jobs: print(sys.version) print("Hello world") shell: pixi run python {0} + - run: | + python --version | grep -q "3.11" + shell: pixi run pwsh -File {0} + - if: matrix.os == 'windows-latest' + run: | + python --version | grep -q "3.11" + shell: pixi run cmd /c {0} post-cleanup-linux: runs-on: ubuntu-latest diff --git a/README.md b/README.md index 03891c1..3350888 100644 --- a/README.md +++ b/README.md @@ -212,6 +212,17 @@ You can even run python scripts like this: shell: pixi run python {0} ``` +Or using windows? Try `powershell` and `cmd`: +```yml +- run: | + python --version | grep -q "3.11" + shell: pixi run pwsh -File {0} # Works on all platforms +- if: matrix.os == 'windows-latest' + run: | + python --version | grep -q "3.11" + shell: pixi run cmd /c {0} # cmd is only available on Windows +``` + > [!NOTE] > Under the hood, the `shell: xyz {0}` option is implemented by creating a temporary script file and calling `xyz` with that script file as an argument. > This file does not have the executable bit set, so you cannot use `shell: pixi run {0}` directly but instead have to use `shell: pixi run bash {0}`. From a947576a1db1108cbbf7e5557b043da83495139d Mon Sep 17 00:00:00 2001 From: Ruben Arts Date: Fri, 16 Feb 2024 08:36:15 +0100 Subject: [PATCH 02/13] fix: use actual cmd and pwsh code. --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 39a026e..0cd4a79 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -334,11 +334,11 @@ jobs: print("Hello world") shell: pixi run python {0} - run: | - python --version | grep -q "3.11" - shell: pixi run pwsh -File {0} + python --version | Select-String "3.11" + shell: pixi run pwsh -Command {0} - if: matrix.os == 'windows-latest' run: | - python --version | grep -q "3.11" + python --version | findstr "3.11" shell: pixi run cmd /c {0} post-cleanup-linux: From 7b7e0b8ee160b2f54f9c2aa80acd4894bd699b1e Mon Sep 17 00:00:00 2001 From: Ruben Arts Date: Fri, 16 Feb 2024 09:46:01 +0100 Subject: [PATCH 03/13] fix: use more github like shell call for cmd --- .github/workflows/test.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0cd4a79..2320616 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -338,9 +338,13 @@ jobs: shell: pixi run pwsh -Command {0} - if: matrix.os == 'windows-latest' run: | - python --version | findstr "3.11" - shell: pixi run cmd /c {0} - + @echo off + python --version | findstr "3.11" > nul + if errorlevel 1 ( + echo Python 3.11 not found. + exit /b 1 + ) + shell: pixi run %ComSpec% /D /E:ON /V:OFF /S /C "CALL "{0}"" post-cleanup-linux: runs-on: ubuntu-latest strategy: From dcfb5d2267c124ec944bfc384d6a01fa7ca124f2 Mon Sep 17 00:00:00 2001 From: Ruben Arts Date: Fri, 16 Feb 2024 09:57:32 +0100 Subject: [PATCH 04/13] fix: use `cmd.exe` instead of %COMSPEC% --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2320616..75657d4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -344,7 +344,7 @@ jobs: echo Python 3.11 not found. exit /b 1 ) - shell: pixi run %ComSpec% /D /E:ON /V:OFF /S /C "CALL "{0}"" + shell: pixi run cmd.exe /D /E:ON /V:OFF /S /C "CALL "{0}"" post-cleanup-linux: runs-on: ubuntu-latest strategy: From 83b4e651051f35bb628e682d9353134e9d066b41 Mon Sep 17 00:00:00 2001 From: Ruben Arts Date: Fri, 16 Feb 2024 10:08:46 +0100 Subject: [PATCH 05/13] fix: don't use echo off --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 75657d4..1ac9c34 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -338,7 +338,6 @@ jobs: shell: pixi run pwsh -Command {0} - if: matrix.os == 'windows-latest' run: | - @echo off python --version | findstr "3.11" > nul if errorlevel 1 ( echo Python 3.11 not found. From 2ec35736b485e4f84770314d59dd01b32208e4b4 Mon Sep 17 00:00:00 2001 From: Ruben Arts Date: Fri, 16 Feb 2024 11:48:10 +0100 Subject: [PATCH 06/13] fix: simplify cmd command --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1ac9c34..4f01e32 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -343,7 +343,7 @@ jobs: echo Python 3.11 not found. exit /b 1 ) - shell: pixi run cmd.exe /D /E:ON /V:OFF /S /C "CALL "{0}"" + shell: pixi run cmd /C CALL {0} post-cleanup-linux: runs-on: ubuntu-latest strategy: From 765ee173ccd7065931c438d15bc773b4da5a2038 Mon Sep 17 00:00:00 2001 From: Ruben Arts Date: Sat, 17 Feb 2024 09:58:17 +0100 Subject: [PATCH 07/13] fix: ignore cmd.exe's existence --- .github/workflows/test.yml | 8 -------- README.md | 14 +++++--------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4f01e32..cdb8941 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -336,14 +336,6 @@ jobs: - run: | python --version | Select-String "3.11" shell: pixi run pwsh -Command {0} - - if: matrix.os == 'windows-latest' - run: | - python --version | findstr "3.11" > nul - if errorlevel 1 ( - echo Python 3.11 not found. - exit /b 1 - ) - shell: pixi run cmd /C CALL {0} post-cleanup-linux: runs-on: ubuntu-latest strategy: diff --git a/README.md b/README.md index 3350888..a210ac0 100644 --- a/README.md +++ b/README.md @@ -203,7 +203,7 @@ This can be useful if you want to run commands inside of the pixi environment, b shell: pixi run bash {0} ``` -You can even run python scripts like this: +You can even run Python scripts like this: ```yml - run: | # everything here will be run inside of the pixi environment @@ -212,15 +212,11 @@ You can even run python scripts like this: shell: pixi run python {0} ``` -Or using windows? Try `powershell` and `cmd`: +Using Windows? Try `powershell` or `bash`: ```yml -- run: | - python --version | grep -q "3.11" - shell: pixi run pwsh -File {0} # Works on all platforms -- if: matrix.os == 'windows-latest' - run: | - python --version | grep -q "3.11" - shell: pixi run cmd /c {0} # cmd is only available on Windows +- run: | # everything here will be run inside of the pixi environment + python --version | Select-String "3.11" + shell: pixi run pwsh -Command {0} # pwsh works on all platforms ``` > [!NOTE] From b704c123bc3fadf7b83981acc3bbee786446368a Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 17 Feb 2024 10:13:06 +0100 Subject: [PATCH 08/13] bump pixi version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a210ac0..28a2831 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ GitHub Action to set up the [pixi](https://github.com/prefix-dev/pixi) package m ```yml - uses: prefix-dev/setup-pixi@v0.5.1 with: - pixi-version: v0.13.0 + pixi-version: v0.14.0 cache: true auth-host: prefix.dev auth-token: ${{ secrets.PREFIX_DEV_TOKEN }} From 903a49b5cedc14762db63708ee292589552595c0 Mon Sep 17 00:00:00 2001 From: Ruben Arts Date: Sat, 17 Feb 2024 10:15:58 +0100 Subject: [PATCH 09/13] Update README.md Co-authored-by: Pavel Zwerschke --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 28a2831..c007718 100644 --- a/README.md +++ b/README.md @@ -212,7 +212,7 @@ You can even run Python scripts like this: shell: pixi run python {0} ``` -Using Windows? Try `powershell` or `bash`: +If you want to use PowerShell, you need to specify `-Command` as well. ```yml - run: | # everything here will be run inside of the pixi environment python --version | Select-String "3.11" From 8abe675a83842b7dc6b189ee589954c12fff592a Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 17 Feb 2024 10:24:23 +0100 Subject: [PATCH 10/13] use bash -e --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c007718..411cff5 100644 --- a/README.md +++ b/README.md @@ -200,7 +200,7 @@ This can be useful if you want to run commands inside of the pixi environment, b - run: | # everything here will be run inside of the pixi environment python --version pip install -e --no-deps . - shell: pixi run bash {0} + shell: pixi run bash -e {0} ``` You can even run Python scripts like this: From c8a5be920c957e165d9d580f7da693f0c42b4597 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 17 Feb 2024 10:26:53 +0100 Subject: [PATCH 11/13] bash -e in tests --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cdb8941..0ad97e5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -327,7 +327,7 @@ jobs: cache: false - run: | python --version | grep -q "3.11" - shell: pixi run bash {0} + shell: pixi run bash -e {0} - run: | import sys print(sys.version) From 6963a4f47e1429b1bac6eae66dde00608000292d Mon Sep 17 00:00:00 2001 From: Ruben Arts Date: Sat, 17 Feb 2024 10:34:32 +0100 Subject: [PATCH 12/13] Update README.md Co-authored-by: Pavel Zwerschke --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 411cff5..0355bfb 100644 --- a/README.md +++ b/README.md @@ -222,6 +222,7 @@ If you want to use PowerShell, you need to specify `-Command` as well. > [!NOTE] > Under the hood, the `shell: xyz {0}` option is implemented by creating a temporary script file and calling `xyz` with that script file as an argument. > This file does not have the executable bit set, so you cannot use `shell: pixi run {0}` directly but instead have to use `shell: pixi run bash {0}`. +> There are some custom shells provided by GitHub that have slightly different behavior, see [`jobs..steps[*].shell`](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell) in the documentation. > See the [official documentation](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#custom-shell) and [ADR 0277](https://github.com/actions/runner/blob/main/docs/adrs/0277-run-action-shell-options.md) for more information about how the `shell:` input works in GitHub Actions. ### `--frozen` and `--locked` From 6cad0daf51edc7baf42f52029cea803bdc1fd06a Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 17 Feb 2024 10:37:18 +0100 Subject: [PATCH 13/13] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0355bfb..ac28500 100644 --- a/README.md +++ b/README.md @@ -193,7 +193,7 @@ This form of authentication (token is encoded in URL: `https://my-quetz-instance ### Custom shell wrapper -`setup-pixi` allows you to run command inside of the pixi environment by specifying a custom shell wrapper with `shell: pixi run bash {0}`. +`setup-pixi` allows you to run command inside of the pixi environment by specifying a custom shell wrapper with `shell: pixi run bash -e {0}`. This can be useful if you want to run commands inside of the pixi environment, but don't want to use the `pixi run` command for each command. ```yml