Skip to content

Commit 1f8c1bb

Browse files
authored
Mention pixi exec in docs (#131)
1 parent 3d7bf9c commit 1f8c1bb

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

.github/workflows/test.yml

+21
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,27 @@ jobs:
456456
- run: |
457457
python --version | Select-String "3.11"
458458
shell: pixi run pwsh -Command {0}
459+
460+
pixi-shell-exec:
461+
strategy:
462+
matrix:
463+
os: [ubuntu-latest, macos-latest, windows-latest]
464+
runs-on: ${{ matrix.os }}
465+
steps:
466+
- uses: actions/checkout@v4
467+
- uses: ./
468+
with:
469+
run-install: false
470+
- run: |
471+
python --version | grep -q "3.11"
472+
shell: pixi exec --spec python=3.11.* -- bash -e {0}
473+
- run: |
474+
import ruamel.yaml
475+
shell: pixi exec --spec python --spec ruamel.yaml -- python {0}
476+
- run: |
477+
python --version | Select-String "3.11"
478+
shell: pixi exec --spec python=3.11.* -- pwsh -Command {0}
479+
459480
post-cleanup-linux:
460481
runs-on: ubuntu-latest
461482
strategy:

README.md

+19
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,25 @@ If you want to use PowerShell, you need to specify `-Command` as well.
229229
> There are some custom shells provided by GitHub that have slightly different behavior, see [`jobs.<job_id>.steps[*].shell`](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell) in the documentation.
230230
> 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.
231231

232+
#### One-off shell wrapper using `pixi exec`
233+
234+
With `pixi exec`, you can also run a one-off command inside a temporary pixi environment.
235+
236+
```yml
237+
- run: | # everything here will be run inside of the temporary pixi environment
238+
zstd --version
239+
shell: pixi exec --spec zstd -- bash -e {0}
240+
```
241+
242+
```yml
243+
- run: | # everything here will be run inside of the temporary pixi environment
244+
import ruamel.yaml
245+
# ...
246+
shell: pixi exec --spec python=3.11.* --spec ruamel.yaml -- python {0}
247+
```
248+
249+
See [here](https://pixi.sh/latest/reference/cli#exec) for more information about `pixi exec`.
250+
232251
### Environment activation
233252

234253
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.

0 commit comments

Comments
 (0)