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

Add pwsh as pixi shells to the tests and documentation #79

Merged
merged 13 commits into from
Feb 17, 2024
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/[email protected]
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering why this even works 🤔 shouldn't it be -File? The thing in {0} will be replaced by a path to the script at runtime...

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started with -File but changed to -Command because that is what github uses: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub appends the extension .ps1 to your script name.

interesting... we unfortunately don't have the power to do this :(

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's also change the bash shell to bash -e while we're at it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also find it super weird that there is different bash behavior when specifying bash or not specifying anything on unix...

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah no clue this whole shell thing isn't the most ergonomic feature.

```

> [!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}`.
ruben-arts marked this conversation as resolved.
Show resolved Hide resolved
> 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
Loading