Skip to content

Commit 6ad791a

Browse files
committed
1 parent ff6c5ff commit 6ad791a

3 files changed

Lines changed: 80 additions & 1 deletion

File tree

.github/workflows/benchmarks.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ env:
99
PR_HEAD_LABEL: ${{ github.event.pull_request.head.label }}
1010

1111
jobs:
12+
cache-pixi-lock:
13+
uses: ./.github/workflows/cache-pixi-lock.yml
1214
benchmark:
15+
needs: cache-pixi-lock
1316
if: ${{ contains( github.event.pull_request.labels.*.name, 'run-benchmark') && github.event_name == 'pull_request' || contains( github.event.pull_request.labels.*.name, 'topic-performance') && github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }}
1417
name: Linux
1518
runs-on: ubuntu-latest
@@ -24,6 +27,18 @@ jobs:
2427
with:
2528
fetch-depth: 0
2629

30+
- name: Restore cached pixi lockfile
31+
uses: actions/cache/restore@v4
32+
id: restore-pixi-lock
33+
with:
34+
path: |
35+
pixi.lock
36+
key: ${{ needs.cache-pixi-lock.outputs.cache-id }}
37+
- uses: prefix-dev/setup-pixi@v0.9.0
38+
with:
39+
cache: true
40+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
41+
2742
- name: Set up conda environment
2843
uses: mamba-org/setup-micromamba@v2
2944
with:
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Generate and cache Pixi lockfile
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
cache-id:
7+
description: "The lock file contents"
8+
value: ${{ jobs.cache-pixi-lock.outputs.cache-id }}
9+
10+
jobs:
11+
cache-pixi-lock:
12+
name: Generate output
13+
runs-on: ubuntu-latest
14+
outputs:
15+
cache-id: ${{ steps.restore.outputs.cache-primary-key }}
16+
steps:
17+
- uses: actions/checkout@v5
18+
with:
19+
fetch-depth: 0
20+
sparse-checkout: pixi.toml
21+
- name: Get current date
22+
id: date
23+
run: echo "date=$(date +'%Y-%m-%d')" >> "$GITHUB_OUTPUT"
24+
- uses: actions/cache/restore@v4
25+
id: restore
26+
with:
27+
path: |
28+
pixi.lock
29+
key: ${{ steps.date.outputs.date }}_${{hashFiles('pixi.toml')}}
30+
- uses: prefix-dev/setup-pixi@v0.9.0
31+
if: ${{ !steps.restore.outputs.cache-hit }}
32+
with:
33+
pixi-version: v0.49.0
34+
run-install: false
35+
- name: Run pixi lock
36+
if: ${{ !steps.restore.outputs.cache-hit }}
37+
run: pixi lock
38+
- uses: actions/cache/save@v4
39+
if: ${{ !steps.restore.outputs.cache-hit }}
40+
id: cache
41+
with:
42+
path: |
43+
pixi.lock
44+
key: ${{ steps.restore.outputs.cache-primary-key }}
45+
- name: Upload pixi.lock
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: pixi-lock
49+
path: pixi.lock

.github/workflows/ci.yaml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,13 @@ jobs:
3232
id: detect-trigger
3333
with:
3434
keyword: "[skip-ci]"
35+
36+
cache-pixi-lock:
37+
uses: ./.github/workflows/cache-pixi-lock.yml
3538
test:
3639
name: ${{ matrix.os }} py${{ matrix.python-version }} ${{ matrix.env }}
3740
runs-on: ${{ matrix.os }}
38-
needs: detect-ci-trigger
41+
needs: [detect-ci-trigger, cache-pixi-lock]
3942
if: needs.detect-ci-trigger.outputs.triggered == 'false'
4043
defaults:
4144
run:
@@ -82,6 +85,18 @@ jobs:
8285
- uses: actions/checkout@v5
8386
with:
8487
fetch-depth: 0 # Fetch all history for all branches and tags.
88+
- name: Restore cached pixi lockfile
89+
uses: actions/cache/restore@v4
90+
id: restore-pixi-lock
91+
with:
92+
path: |
93+
pixi.lock
94+
key: ${{ needs.cache-pixi-lock.outputs.cache-id }}
95+
- uses: prefix-dev/setup-pixi@v0.9.0
96+
with:
97+
cache: true
98+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
99+
85100
- name: Set environment variables
86101
run: |
87102
echo "TODAY=$(date +'%Y-%m-%d')" >> $GITHUB_ENV

0 commit comments

Comments
 (0)