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

docs: Mention pixi exec in GHA docs #1724

Merged
merged 3 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
23 changes: 23 additions & 0 deletions docs/advanced/github_actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,29 @@ 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.

```yaml
- run: | # (1)!
zstd --version
shell: pixi exec --spec zstd -- bash -e {0}
```

1. everything here will be run inside of the temporary pixi environment

```yaml
- run: | # (1)!
import ruamel.yaml
# ...
shell: pixi exec --spec python=3.11.* --spec ruamel.yaml -- python {0}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

small note: 'python=3.11.*' doesn't work here as this isn't evaluated in a shell and it would be passed with quotes to pixi which results in the following error:

error: invalid value ''python=3.11.*'' for '--spec <SPECS>': ''python' is not a valid package name. Package names can only contain 0-9, a-z, A-Z, -, _, or .

For more information, try '--help'.

Nothing we need to fix on pixi's side IMO

```

1. everything here will be run inside of the temporary pixi environment

See [here](../reference/cli.md#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
4 changes: 2 additions & 2 deletions docs/advanced/updates_github_actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ jobs:
run-install: false
- name: Update lockfiles
run: |
pixi global install pixi-diff-to-markdown
pixi update --json --no-install | pixi-diff-to-markdown >> diff.md
set -o pipefail
pixi update --json --no-install | pixi exec pixi-diff-to-markdown >> diff.md
- name: Create pull request
uses: peter-evans/create-pull-request@v6
with:
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pixi add --feature featurex numpy
```

!!! tip
If you want to use a non default pinning strategy, you can set it using [pixi's configuration](reference/pixi_configuration#pinning-strategy).
If you want to use a non default pinning strategy, you can set it using [pixi's configuration](./pixi_configuration.md#pinning-strategy).
```
pixi config set pinning-strategy no-pin --global
```
Expand Down
Loading