Skip to content

Commit

Permalink
Add pwsh as pixi shells to the tests and documentation (#79)
Browse files Browse the repository at this point in the history
Co-authored-by: Pavel Zwerschke <pavelzw@gmail.com>
  • Loading branch information
ruben-arts and pavelzw authored Feb 17, 2024
1 parent 26e623c commit 20681db
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,15 @@ 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)
print("Hello world")
shell: pixi run python {0}
- run: |
python --version | Select-String "3.11"
shell: pixi run pwsh -Command {0}
post-cleanup-linux:
runs-on: ubuntu-latest
strategy:
Expand Down
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -193,17 +193,17 @@ 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
- 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:
You can even run Python scripts like this:

```yml
- run: | # everything here will be run inside of the pixi environment
Expand All @@ -212,9 +212,17 @@ You can even run python scripts like this:
shell: pixi run python {0}
```

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"
shell: pixi run pwsh -Command {0} # pwsh works on all platforms
```

> [!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.<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.

### `--frozen` and `--locked`
Expand Down

0 comments on commit 20681db

Please sign in to comment.