Skip to content

Commit 194d461

Browse files
Add possibility to install global environments (#221)
Co-authored-by: Pavel Zwerschke <[email protected]>
1 parent 40ab261 commit 194d461

File tree

9 files changed

+291
-138
lines changed

9 files changed

+291
-138
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
run: |
4848
set -euo pipefail
4949
latest_version="$(jq -r '.version' package.json)"
50-
count_expected=20
50+
count_expected=21
5151
count_actual="$(grep -c "setup-pixi@v$latest_version" README.md || true)"
5252
if [ "$count_actual" -ne "$count_expected" ]; then
5353
echo "::error file=README.md::Expected $count_expected mentions of \`setup-pixi@v$latest_version\` in README.md, but found $count_actual."

.github/workflows/test.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,55 @@ jobs:
4747
pixi run python --version | grep -q 3.11
4848
pixi run test | grep -q "Hello world"
4949
50+
global-environments:
51+
strategy:
52+
matrix:
53+
os: [ubuntu-latest, macos-latest, windows-latest]
54+
runs-on: ${{ matrix.os }}
55+
steps:
56+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
57+
- name: Move pixi.toml
58+
run: mv test/default/* .
59+
- uses: ./
60+
with:
61+
global-environments: |
62+
cowpy
63+
- run: |
64+
cowpy hello world
65+
- run: |
66+
set -o pipefail
67+
pixi info
68+
test -f ${{ matrix.os == 'windows-latest' && './.pixi/envs/default/python.exe' || './.pixi/envs/default/bin/python' }}
69+
${{ matrix.os == 'windows-latest' && './.pixi/envs/default/python.exe' || './.pixi/envs/default/bin/python' }} --version | grep -q 3.11
70+
shell: bash
71+
- run: |
72+
pixi run python --version | grep -q 3.11
73+
pixi run test | grep -q "Hello world"
74+
75+
global-environments-with-project-install:
76+
strategy:
77+
matrix:
78+
os: [ubuntu-latest, macos-latest, windows-latest]
79+
runs-on: ${{ matrix.os }}
80+
steps:
81+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
82+
- uses: ./
83+
with:
84+
run-install: false
85+
global-environments: |
86+
cowpy
87+
keyring --with keyrings.google-artifactregistry-auth
88+
- run: |
89+
set -o pipefail
90+
cowpy hello world
91+
keyring --list-backends | grep "keyrings.gauth.GooglePythonAuth"
92+
shell: bash
93+
if: matrix.os != 'windows-latest'
94+
- run: |
95+
cowpy hello world
96+
keyring --list-backends | findstr "keyrings.gauth.GooglePythonAuth"
97+
if: matrix.os == 'windows-latest'
98+
5099
no-run-install:
51100
strategy:
52101
matrix:

README.md

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ GitHub Action to set up the [pixi](https://github.com/prefix-dev/pixi) package m
2323
## Usage
2424

2525
```yml
26-
- uses: prefix-dev/[email protected].0
26+
- uses: prefix-dev/[email protected].1
2727
with:
2828
pixi-version: v0.49.0
2929

@@ -35,7 +35,7 @@ GitHub Action to set up the [pixi](https://github.com/prefix-dev/pixi) package m
3535
3636
> [!WARNING]
3737
> Since pixi is not yet stable, the API of this action may change between minor versions.
38-
> Please pin the versions of this action to a specific version (i.e., `prefix-dev/[email protected].0`) to avoid breaking changes.
38+
> Please pin the versions of this action to a specific version (i.e., `prefix-dev/[email protected].1`) to avoid breaking changes.
3939
> You can automatically update the version of this action by using [Dependabot](https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot).
4040
>
4141
> Put the following in your `.github/dependabot.yml` file to enable Dependabot for your GitHub Actions:
@@ -74,7 +74,7 @@ In order to not exceed the [10 GB cache size limit](https://docs.github.com/en/a
7474
This can be done by setting the `cache-write` argument.
7575

7676
```yml
77-
- uses: prefix-dev/[email protected].0
77+
- uses: prefix-dev/[email protected].1
7878
with:
7979
cache: true
8080
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
@@ -119,7 +119,7 @@ test:
119119
environment: [py311, py312]
120120
steps:
121121
- uses: actions/checkout@v4
122-
- uses: prefix-dev/[email protected].0
122+
- uses: prefix-dev/[email protected].1
123123
with:
124124
environments: ${{ matrix.environment }}
125125
```
@@ -129,7 +129,7 @@ test:
129129
The following example will install both the `py311` and the `py312` environment on the runner.
130130

131131
```yml
132-
- uses: prefix-dev/[email protected].0
132+
- uses: prefix-dev/[email protected].1
133133
with:
134134
# separated by spaces
135135
environments: >-
@@ -143,14 +143,34 @@ The following example will install both the `py311` and the `py312` environment
143143
> [!WARNING]
144144
> If you don't specify any environment, the `default` environment will be installed and cached, even if you use other environments.
145145

146+
### Global Environments
147+
148+
You can specify `pixi global install` commands by setting the `global-environments` input argument.
149+
This will create one environment per line, and install them.
150+
This is useful in particular to install executables that are needed for `pixi install` to work properly.
151+
For instance, the `keyring`, or `gcloud` executables. The following example shows how to install both in separate global environments.
152+
Note that global environments are not cached.
153+
154+
```yml
155+
- uses: prefix-dev/[email protected]
156+
with:
157+
global-environments: |
158+
google-cloud-sdk
159+
keyring --with keyrings.google-artifactregistry-auth
160+
- run: |
161+
gcloud --version
162+
keyring --list-backends
163+
```
164+
146165
### Authentication
147166

148-
There are currently three ways to authenticate with pixi:
167+
There are currently five ways to authenticate with pixi:
149168

150169
- using a token
151170
- using a username and password
152171
- using a conda-token
153172
- using an S3 key pair
173+
- using keyring for PyPI registries
154174

155175
For more information, see the [pixi documentation](https://prefix.dev/docs/pixi/authentication).
156176

@@ -165,7 +185,7 @@ Specify the token using the `auth-token` input argument.
165185
This form of authentication (bearer token in the request headers) is mainly used at [prefix.dev](https://prefix.dev).
166186

167187
```yml
168-
- uses: prefix-dev/[email protected].0
188+
- uses: prefix-dev/[email protected].1
169189
with:
170190
auth-host: prefix.dev
171191
auth-token: ${{ secrets.PREFIX_DEV_TOKEN }}
@@ -177,7 +197,7 @@ Specify the username and password using the `auth-username` and `auth-password`
177197
This form of authentication (HTTP Basic Auth) is used in some enterprise environments with [artifactory](https://jfrog.com/artifactory) for example.
178198

179199
```yml
180-
- uses: prefix-dev/[email protected].0
200+
- uses: prefix-dev/[email protected].1
181201
with:
182202
auth-host: custom-artifactory.com
183203
auth-username: ${{ secrets.PIXI_USERNAME }}
@@ -190,7 +210,7 @@ Specify the conda-token using the `auth-conda-token` input argument.
190210
This form of authentication (token is encoded in URL: `https://my-quetz-instance.com/t/<token>/get/custom-channel`) is used at [anaconda.org](https://anaconda.org) or with [quetz instances](https://github.com/mamba-org/quetz).
191211

192212
```yml
193-
- uses: prefix-dev/[email protected].0
213+
- uses: prefix-dev/[email protected].1
194214
with:
195215
auth-host: anaconda.org # or my-quetz-instance.com
196216
auth-conda-token: ${{ secrets.CONDA_TOKEN }}
@@ -202,7 +222,7 @@ Specify the S3 key pair using the `auth-access-key-id` and `auth-secret-access-k
202222
You can also specify the session token using the `auth-session-token` input argument.
203223

204224
```yaml
205-
- uses: prefix-dev/[email protected].0
225+
- uses: prefix-dev/[email protected].1
206226
with:
207227
auth-host: s3://my-s3-bucket
208228
auth-s3-access-key-id: ${{ secrets.ACCESS_KEY_ID }}
@@ -218,11 +238,13 @@ See the [pixi documentation](https://pixi.sh/latest/advanced/s3) for more inform
218238
You can specify whether to use keyring to look up credentials for PyPI.
219239

220240
```yml
221-
- uses: prefix-dev/[email protected].0
241+
- uses: prefix-dev/[email protected].1
222242
with:
223243
pypi-keyring-provider: subprocess # one of 'subprocess', 'disabled'
224244
```
225245

246+
You can use the [`global-environments`](#global-environments) input to install `keyring` and its backends.
247+
226248
### Custom shell wrapper
227249

228250
`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}`.
@@ -284,15 +306,15 @@ To this end, `setup-pixi` adds all environment variables set when executing `pix
284306
As a result, all installed binaries can be accessed without having to call `pixi run`.
285307

286308
```yml
287-
- uses: prefix-dev/[email protected].0
309+
- uses: prefix-dev/[email protected].1
288310
with:
289311
activate-environment: true
290312
```
291313

292314
If you are installing multiple environments, you will need to specify the name of the environment that you want to be activated.
293315

294316
```yml
295-
- uses: prefix-dev/[email protected].0
317+
- uses: prefix-dev/[email protected].1
296318
with:
297319
environments: >-
298320
py311
@@ -309,7 +331,7 @@ You can specify whether `setup-pixi` should run `pixi install --frozen` or `pixi
309331
See the [official documentation](https://prefix.dev/docs/pixi/cli#install) for more information about the `--frozen` and `--locked` flags.
310332

311333
```yml
312-
- uses: prefix-dev/[email protected].0
334+
- uses: prefix-dev/[email protected].1
313335
with:
314336
locked: true
315337
# or
@@ -328,7 +350,7 @@ The first one is the debug logging of the action itself.
328350
This can be enabled by running the action with the `RUNNER_DEBUG` environment variable set to `true`.
329351

330352
```yml
331-
- uses: prefix-dev/[email protected].0
353+
- uses: prefix-dev/[email protected].1
332354
env:
333355
RUNNER_DEBUG: true
334356
```
@@ -346,7 +368,7 @@ The second type is the debug logging of the pixi executable.
346368
This can be specified by setting the `log-level` input.
347369

348370
```yml
349-
- uses: prefix-dev/[email protected].0
371+
- uses: prefix-dev/[email protected].1
350372
with:
351373
# one of `q`, `default`, `v`, `vv`, or `vvv`.
352374
log-level: vvv
@@ -372,7 +394,7 @@ If nothing is specified, `post-cleanup` will default to `true`.
372394
On self-hosted runners, you also might want to alter the default pixi install location to a temporary location. You can use `pixi-bin-path: ${{ runner.temp }}/bin/pixi` to do this.
373395

374396
```yml
375-
- uses: prefix-dev/[email protected].0
397+
- uses: prefix-dev/[email protected].1
376398
with:
377399
post-cleanup: true
378400
# ${{ runner.temp }}\Scripts\pixi.exe on Windows
@@ -388,7 +410,7 @@ You can also use a preinstalled local version of pixi on the runner by not setti
388410
This can be overwritten by setting the `manifest-path` input argument.
389411

390412
```yml
391-
- uses: prefix-dev/[email protected].0
413+
- uses: prefix-dev/[email protected].1
392414
with:
393415
manifest-path: pyproject.toml
394416
```
@@ -398,7 +420,7 @@ This can be overwritten by setting the `manifest-path` input argument.
398420
If you only want to install pixi and not install the current project, you can use the `run-install` option.
399421

400422
```yml
401-
- uses: prefix-dev/[email protected].0
423+
- uses: prefix-dev/[email protected].1
402424
with:
403425
run-install: false
404426
```
@@ -409,7 +431,7 @@ You can also download pixi from a custom URL by setting the `pixi-url` input arg
409431
Optionally, you can combine this with the `pixi-url-headers` input argument to supply additional headers for the download request, such as a bearer token.
410432

411433
```yml
412-
- uses: prefix-dev/[email protected].0
434+
- uses: prefix-dev/[email protected].1
413435
with:
414436
pixi-url: https://pixi-mirror.example.com/releases/download/v0.48.0/pixi-x86_64-unknown-linux-musl
415437
pixi-url-headers: '{"Authorization": "Bearer ${{ secrets.PIXI_MIRROR_BEARER_TOKEN }}"}'
@@ -425,7 +447,7 @@ It will be rendered with the following variables:
425447
By default, `pixi-url` is equivalent to the following template:
426448

427449
```yml
428-
- uses: prefix-dev/[email protected].0
450+
- uses: prefix-dev/[email protected].1
429451
with:
430452
pixi-url: |
431453
{{#if latest~}}

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ inputs:
2323
environments:
2424
description: |
2525
A space-separated list of environments to install. If not specified, only the default environment is installed.
26+
global-environments:
27+
description: |
28+
A newline-separated list of packages to install globally with `pixi global install`.
2629
activate-environment:
2730
description: |
2831
If the installed environment should be "activated" for the current job, modifying `$GITHUB_ENV` and

0 commit comments

Comments
 (0)