From cf5a4ddffe30a77d61d9c4b8bfd35c06d00e386c Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Fri, 2 Aug 2024 10:40:16 +0200 Subject: [PATCH 1/6] Mention pixi exec in docs --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index fd3c99a..85a7555 100644 --- a/README.md +++ b/README.md @@ -229,6 +229,25 @@ If you want to use PowerShell, you need to specify `-Command` as well. > 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. +#### One-off shell wrapper using `pixi exec` + +With `pixi exec`, you can also run a one-off command inside a temporary pixi environment. + +```yml +- run: | # everything here will be run inside of the temporary pixi environment + zstd --version + shell: pixi exec --spec zstd -- bash -e {0} +``` + +```yml +- run: | # everything here will be run inside of the temporary pixi environment + import ruamel.yaml + # ... + shell: pixi exec --spec python --spec ruamel.yaml -- python {0} +``` + +See [here](https://pixi.sh/latest/reference/cli#exec) for more information about `pixi exec`. + ### Environment activation Instead of using a custom shell wrapper, you can also make all pixi-installed binaries available to subsequent steps by "activating" the installed environment in the currently running job. From 316da19c4107ada95e37e84580a7782a152d7039 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Fri, 2 Aug 2024 11:00:56 +0200 Subject: [PATCH 2/6] add test --- .github/workflows/test.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 77bb8d1..e4d3700 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -456,6 +456,26 @@ jobs: - run: | python --version | Select-String "3.11" shell: pixi run pwsh -Command {0} + + pixi-shell-exec: + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: ./ + with: + run-install: false + - run: | + python --version | grep -q "3.11" + shell: pixi exec --spec python='3.11.*' -- bash -e {0} + - run: | + import ruamel.yaml + shell: pixi exec --spec python --spec ruamel.yaml -- python {0} + - run: | + python --version | Select-String "3.11" + shell: pixi exec --spec python='3.11.*' -- pwsh -Command {0} + post-cleanup-linux: runs-on: ubuntu-latest strategy: From db6968407e9277e6721df0b13dd77145a02697d3 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Fri, 2 Aug 2024 11:03:29 +0200 Subject: [PATCH 3/6] checkout --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e4d3700..9f68e9e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -463,6 +463,7 @@ jobs: os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} steps: + - uses: actions/checkout@v4 - uses: ./ with: run-install: false From 3d2670d89524a59118cc7ca37b43e554b34ebf9e Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Fri, 2 Aug 2024 11:07:07 +0200 Subject: [PATCH 4/6] . --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9f68e9e..f761be1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -469,13 +469,13 @@ jobs: run-install: false - run: | python --version | grep -q "3.11" - shell: pixi exec --spec python='3.11.*' -- bash -e {0} + shell: pixi exec --spec 'python=3.11.*' -- bash -e {0} - run: | import ruamel.yaml shell: pixi exec --spec python --spec ruamel.yaml -- python {0} - run: | python --version | Select-String "3.11" - shell: pixi exec --spec python='3.11.*' -- pwsh -Command {0} + shell: pixi exec --spec 'python=3.11.*' -- pwsh -Command {0} post-cleanup-linux: runs-on: ubuntu-latest From f4fa8637d49ebcf898433a9b648fd9bbde30c2ee Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Fri, 2 Aug 2024 11:12:00 +0200 Subject: [PATCH 5/6] ? --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f761be1..bcc8c13 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -469,13 +469,13 @@ jobs: run-install: false - run: | python --version | grep -q "3.11" - shell: pixi exec --spec 'python=3.11.*' -- bash -e {0} + shell: pixi exec --spec python=3.11.* -- bash -e {0} - run: | import ruamel.yaml shell: pixi exec --spec python --spec ruamel.yaml -- python {0} - run: | python --version | Select-String "3.11" - shell: pixi exec --spec 'python=3.11.*' -- pwsh -Command {0} + shell: pixi exec --spec python=3.11.* -- pwsh -Command {0} post-cleanup-linux: runs-on: ubuntu-latest From 2232461261299d0d652fcf96812bb767020b492c Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Fri, 2 Aug 2024 11:16:56 +0200 Subject: [PATCH 6/6] . --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 85a7555..e7b776e 100644 --- a/README.md +++ b/README.md @@ -243,7 +243,7 @@ With `pixi exec`, you can also run a one-off command inside a temporary pixi env - run: | # everything here will be run inside of the temporary pixi environment import ruamel.yaml # ... - shell: pixi exec --spec python --spec ruamel.yaml -- python {0} + shell: pixi exec --spec python=3.11.* --spec ruamel.yaml -- python {0} ``` See [here](https://pixi.sh/latest/reference/cli#exec) for more information about `pixi exec`.