Skip to content

Commit a0af7a2

Browse files
retrrypavelzwclaude
authored
Implement working directory setup (#236)
Co-authored-by: Pavel Zwerschke <pavelzw@gmail.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 51b9803 commit a0af7a2

File tree

10 files changed

+223
-63
lines changed

10 files changed

+223
-63
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=21
50+
count_expected=23
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: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,94 @@ jobs:
327327
pixi-version: latest
328328
- run: pixi --version | grep -q "pixi 0.14.0"
329329

330+
working-directory:
331+
strategy:
332+
matrix:
333+
os: [ubuntu-latest, macos-latest, windows-latest]
334+
runs-on: ${{ matrix.os }}
335+
steps:
336+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
337+
- uses: ./
338+
with:
339+
cache: false
340+
working-directory: test/default
341+
- run: |
342+
set -o pipefail
343+
pixi info
344+
test -f .pixi/envs/default/bin/python
345+
.pixi/envs/default/bin/python --version | grep -q 3.11
346+
shell: bash
347+
working-directory: test/default
348+
if: matrix.os != 'windows-latest'
349+
- run: |
350+
set -o pipefail
351+
pixi info
352+
test -f .pixi/envs/default/python.exe
353+
.pixi/envs/default/python.exe --version | grep -q 3.11
354+
shell: bash
355+
working-directory: test/default
356+
if: matrix.os == 'windows-latest'
357+
- run: pixi run python --version | grep -q 3.11
358+
working-directory: test/default
359+
360+
working-directory-with-manifest-path:
361+
strategy:
362+
matrix:
363+
os: [ubuntu-latest, macos-latest, windows-latest]
364+
runs-on: ${{ matrix.os }}
365+
steps:
366+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
367+
- uses: ./
368+
with:
369+
cache: false
370+
working-directory: test
371+
manifest-path: default/pixi.toml
372+
- run: |
373+
set -o pipefail
374+
pixi info
375+
test -f .pixi/envs/default/bin/python
376+
shell: bash
377+
working-directory: test/default
378+
if: matrix.os != 'windows-latest'
379+
- run: |
380+
set -o pipefail
381+
pixi info
382+
test -f .pixi/envs/default/python.exe
383+
shell: bash
384+
working-directory: test/default
385+
if: matrix.os == 'windows-latest'
386+
- run: pixi run python --version | grep -q 3.11
387+
working-directory: test/default
388+
389+
working-directory-with-absolute-manifest-path:
390+
strategy:
391+
matrix:
392+
os: [ubuntu-latest, macos-latest, windows-latest]
393+
runs-on: ${{ matrix.os }}
394+
steps:
395+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
396+
- uses: ./
397+
with:
398+
cache: false
399+
working-directory: test/default
400+
manifest-path: ${{ github.workspace }}/test/default/pixi.toml
401+
- run: |
402+
set -o pipefail
403+
pixi info
404+
test -f .pixi/envs/default/bin/python
405+
shell: bash
406+
working-directory: test/default
407+
if: matrix.os != 'windows-latest'
408+
- run: |
409+
set -o pipefail
410+
pixi info
411+
test -f .pixi/envs/default/python.exe
412+
shell: bash
413+
working-directory: test/default
414+
if: matrix.os == 'windows-latest'
415+
- run: pixi run python --version | grep -q 3.11
416+
working-directory: test/default
417+
330418
custom-manifest-path:
331419
strategy:
332420
matrix:

README.md

Lines changed: 51 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/setup-pixi@v0.9.3
26+
- uses: prefix-dev/setup-pixi@v0.9.4
2727
with:
2828
pixi-version: v0.62.2
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/setup-pixi@v0.9.3`) to avoid breaking changes.
38+
> Please pin the versions of this action to a specific version (i.e., `prefix-dev/setup-pixi@v0.9.4`) 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:
@@ -77,7 +77,7 @@ In order to not exceed the [10 GB cache size limit](https://docs.github.com/en/a
7777
This can be done by setting the `cache-write` argument.
7878

7979
```yml
80-
- uses: prefix-dev/setup-pixi@v0.9.3
80+
- uses: prefix-dev/setup-pixi@v0.9.4
8181
with:
8282
cache: true
8383
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
@@ -122,7 +122,7 @@ test:
122122
environment: [py311, py312]
123123
steps:
124124
- uses: actions/checkout@v4
125-
- uses: prefix-dev/setup-pixi@v0.9.3
125+
- uses: prefix-dev/setup-pixi@v0.9.4
126126
with:
127127
environments: ${{ matrix.environment }}
128128
```
@@ -132,7 +132,7 @@ test:
132132
The following example will install both the `py311` and the `py312` environment on the runner.
133133

134134
```yml
135-
- uses: prefix-dev/setup-pixi@v0.9.3
135+
- uses: prefix-dev/setup-pixi@v0.9.4
136136
with:
137137
# separated by spaces
138138
environments: >-
@@ -155,7 +155,7 @@ For instance, the `keyring`, or `gcloud` executables. The following example show
155155
By default, global environments are not cached. You can enable caching by setting the `global-cache` input to `true`.
156156

157157
```yml
158-
- uses: prefix-dev/setup-pixi@v0.9.3
158+
- uses: prefix-dev/setup-pixi@v0.9.4
159159
with:
160160
global-environments: |
161161
google-cloud-sdk
@@ -188,7 +188,7 @@ Specify the token using the `auth-token` input argument.
188188
This form of authentication (bearer token in the request headers) is mainly used at [prefix.dev](https://prefix.dev).
189189

190190
```yml
191-
- uses: prefix-dev/setup-pixi@v0.9.3
191+
- uses: prefix-dev/setup-pixi@v0.9.4
192192
with:
193193
auth-host: prefix.dev
194194
auth-token: ${{ secrets.PREFIX_DEV_TOKEN }}
@@ -200,7 +200,7 @@ Specify the username and password using the `auth-username` and `auth-password`
200200
This form of authentication (HTTP Basic Auth) is used in some enterprise environments with [artifactory](https://jfrog.com/artifactory) for example.
201201

202202
```yml
203-
- uses: prefix-dev/setup-pixi@v0.9.3
203+
- uses: prefix-dev/setup-pixi@v0.9.4
204204
with:
205205
auth-host: custom-artifactory.com
206206
auth-username: ${{ secrets.PIXI_USERNAME }}
@@ -213,7 +213,7 @@ Specify the conda-token using the `auth-conda-token` input argument.
213213
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).
214214

215215
```yml
216-
- uses: prefix-dev/setup-pixi@v0.9.3
216+
- uses: prefix-dev/setup-pixi@v0.9.4
217217
with:
218218
auth-host: anaconda.org # or my-quetz-instance.com
219219
auth-conda-token: ${{ secrets.CONDA_TOKEN }}
@@ -225,7 +225,7 @@ Specify the S3 key pair using the `auth-access-key-id` and `auth-secret-access-k
225225
You can also specify the session token using the `auth-session-token` input argument.
226226

227227
```yaml
228-
- uses: prefix-dev/setup-pixi@v0.9.3
228+
- uses: prefix-dev/setup-pixi@v0.9.4
229229
with:
230230
auth-host: s3://my-s3-bucket
231231
auth-s3-access-key-id: ${{ secrets.ACCESS_KEY_ID }}
@@ -241,7 +241,7 @@ See the [pixi documentation](https://pixi.sh/latest/advanced/s3) for more inform
241241
You can specify whether to use keyring to look up credentials for PyPI.
242242

243243
```yml
244-
- uses: prefix-dev/setup-pixi@v0.9.3
244+
- uses: prefix-dev/setup-pixi@v0.9.4
245245
with:
246246
pypi-keyring-provider: subprocess # one of 'subprocess', 'disabled'
247247
```
@@ -309,15 +309,15 @@ To this end, `setup-pixi` adds all environment variables set when executing `pix
309309
As a result, all installed binaries can be accessed without having to call `pixi run`.
310310

311311
```yml
312-
- uses: prefix-dev/setup-pixi@v0.9.3
312+
- uses: prefix-dev/setup-pixi@v0.9.4
313313
with:
314314
activate-environment: true
315315
```
316316

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

319319
```yml
320-
- uses: prefix-dev/setup-pixi@v0.9.3
320+
- uses: prefix-dev/setup-pixi@v0.9.4
321321
with:
322322
environments: >-
323323
py311
@@ -334,7 +334,7 @@ You can specify whether `setup-pixi` should run `pixi install --frozen` or `pixi
334334
See the [official documentation](https://pixi.sh/latest/reference/cli/pixi/install/#update-options) for more information about the `--frozen` and `--locked` flags.
335335

336336
```yml
337-
- uses: prefix-dev/setup-pixi@v0.9.3
337+
- uses: prefix-dev/setup-pixi@v0.9.4
338338
with:
339339
locked: true
340340
# or
@@ -353,7 +353,7 @@ The first one is the debug logging of the action itself.
353353
This can be enabled by running the action with the `RUNNER_DEBUG` environment variable set to `true`.
354354

355355
```yml
356-
- uses: prefix-dev/setup-pixi@v0.9.3
356+
- uses: prefix-dev/setup-pixi@v0.9.4
357357
env:
358358
RUNNER_DEBUG: true
359359
```
@@ -371,7 +371,7 @@ The second type is the debug logging of the pixi executable.
371371
This can be specified by setting the `log-level` input.
372372

373373
```yml
374-
- uses: prefix-dev/setup-pixi@v0.9.3
374+
- uses: prefix-dev/setup-pixi@v0.9.4
375375
with:
376376
# one of `q`, `default`, `v`, `vv`, or `vvv`.
377377
log-level: vvv
@@ -397,7 +397,7 @@ If nothing is specified, `post-cleanup` will default to `true`.
397397
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.
398398

399399
```yml
400-
- uses: prefix-dev/setup-pixi@v0.9.3
400+
- uses: prefix-dev/setup-pixi@v0.9.4
401401
with:
402402
post-cleanup: true
403403
# ${{ runner.temp }}\Scripts\pixi.exe on Windows
@@ -413,17 +413,47 @@ You can also use a preinstalled local version of pixi on the runner by not setti
413413
This can be overwritten by setting the `manifest-path` input argument.
414414

415415
```yml
416-
- uses: prefix-dev/setup-pixi@v0.9.3
416+
- uses: prefix-dev/setup-pixi@v0.9.4
417417
with:
418418
manifest-path: pyproject.toml
419419
```
420420

421+
### Working directory for monorepos
422+
423+
If you're working with a monorepo where your pixi project is in a subdirectory, you can use the `working-directory` input to specify where pixi should look for manifest files (`pixi.toml` or `pyproject.toml`).
424+
425+
```yml
426+
- uses: prefix-dev/setup-pixi@v0.9.4
427+
with:
428+
working-directory: ./packages/my-project
429+
```
430+
431+
This will make pixi look for `pixi.toml` or `pyproject.toml` in the `./packages/my-project` directory instead of the repository root. All pixi commands will be executed from this working directory.
432+
433+
> [!NOTE]
434+
> The `working-directory` input only affects commands run by `setup-pixi` itself.
435+
> For subsequent `run:` steps, you need to set the working directory separately:
436+
>
437+
> ```yml
438+
> - run: pixi run test
439+
> working-directory: ./packages/my-project
440+
> ```
441+
442+
You can combine `working-directory` with `manifest-path` if needed:
443+
444+
```yml
445+
- uses: prefix-dev/setup-pixi@v0.9.4
446+
with:
447+
working-directory: ./packages/my-project
448+
manifest-path: custom-pixi.toml
449+
```
450+
421451
### Only install pixi
422452

423453
If you only want to install pixi and not install the current project, you can use the `run-install` option.
424454

425455
```yml
426-
- uses: prefix-dev/setup-pixi@v0.9.3
456+
- uses: prefix-dev/setup-pixi@v0.9.4
427457
with:
428458
run-install: false
429459
```
@@ -434,7 +464,7 @@ You can also download pixi from a custom URL by setting the `pixi-url` input arg
434464
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.
435465

436466
```yml
437-
- uses: prefix-dev/setup-pixi@v0.9.3
467+
- uses: prefix-dev/setup-pixi@v0.9.4
438468
with:
439469
pixi-url: https://pixi-mirror.example.com/releases/download/v0.48.0/pixi-x86_64-unknown-linux-musl
440470
pixi-url-headers: '{"Authorization": "Bearer ${{ secrets.PIXI_MIRROR_BEARER_TOKEN }}"}'
@@ -450,7 +480,7 @@ It will be rendered with the following variables:
450480
By default, `pixi-url` is equivalent to the following template:
451481

452482
```yml
453-
- uses: prefix-dev/setup-pixi@v0.9.3
483+
- uses: prefix-dev/setup-pixi@v0.9.4
454484
with:
455485
pixi-url: |
456486
{{#if latest~}}

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ inputs:
1818
One of `q`, `default`, `v`, `vv`, or `vvv`.
1919
manifest-path:
2020
description: Path to the manifest file (i.e., `pixi.toml`) to use for the pixi CLI. Defaults to `pixi.toml`.
21+
working-directory:
22+
description: |
23+
Working directory to use for pixi commands. If specified, pixi will look for manifest files (pixi.toml or pyproject.toml)
24+
in this directory instead of the repository root. Useful for monorepos where pixi projects are in subdirectories.
2125
run-install:
2226
description: Whether to run `pixi install` after installing pixi. Defaults to `true`.
2327
environments:

0 commit comments

Comments
 (0)