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
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,9 @@ jobs:
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
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1 align="center">

Check failure on line 1 in README.md

View workflow job for this annotation

GitHub Actions / Reference latest Pixi version in README

Expected 1 mentions of `pixi-version: v0.14.0` in README.md, but found 0.

[![License][license-badge]][license]
[![CI][build-badge]][build]
Expand Down Expand Up @@ -203,7 +203,7 @@
shell: pixi run bash {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,6 +212,13 @@
shell: pixi run python {0}
```

Using Windows? Try `powershell` or `bash`:
```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}`.
Expand Down
Loading