Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mention pixi exec in docs #131

Merged
merged 6 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,27 @@ 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: actions/checkout@v4
- 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:
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.<job_id>.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=3.11.* --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.
Expand Down
Loading