-
Notifications
You must be signed in to change notification settings - Fork 0
177 lines (162 loc) · 6.02 KB
/
test.yml
File metadata and controls
177 lines (162 loc) · 6.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: Test pixi-lock actions
on:
push:
branches: [main, test-me/*]
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
clear-cache:
runs-on: ubuntu-slim
permissions:
actions: write
steps:
- name: Clear pixi-lock cache entries
env:
GH_TOKEN: ${{ github.token }}
run: |
echo "Clearing pixi-lock-* cache entries"
gh cache list --repo ${{ github.repository }} --json key --jq '.[].key' | grep '^pixi-lock_' | while read -r key; do
echo "Deleting cache: $key"
for attempt in 1 2 3; do
if gh cache delete "$key" --repo ${{ github.repository }}; then
break
fi
echo "Attempt $attempt failed, retrying in 5 seconds..."
sleep 5
done
done
sleep 5
echo "Verifying all caches are cleared..."
remaining=$(gh cache list --repo ${{ github.repository }} --json key --jq '.[].key' | grep '^pixi-lock_' || true)
if [ -n "$remaining" ]; then
echo "Error: Some caches still exist:"
echo "$remaining"
exit 1
fi
echo "Cache cleared"
test-cache-restore-install:
needs: clear-cache
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# Test OS values with fixed test-folder and pixi-version
- os: ubuntu-latest
test-folder: just-pixi-toml
expected-hash: "pixi-lock__69110db0bf39d7ce64fd774c7078ccd56ebf8542d9a1e86f84e63011634dc43f_{TODAYS_DATE}"
pixi-version: ""
- os: macos-latest
test-folder: just-pixi-toml
expected-hash: "pixi-lock__69110db0bf39d7ce64fd774c7078ccd56ebf8542d9a1e86f84e63011634dc43f_{TODAYS_DATE}"
pixi-version: ""
- os: windows-latest
test-folder: just-pixi-toml
expected-hash: "pixi-lock__adbacdefe20c62f204989acf366ef09911f3af89f066088613341b946be131e8_{TODAYS_DATE}"
pixi-version: ""
# Test test-folder values with fixed OS and pixi-version
- os: ubuntu-latest
test-folder: just-pixi-toml
expected-hash: "pixi-lock__69110db0bf39d7ce64fd774c7078ccd56ebf8542d9a1e86f84e63011634dc43f_{TODAYS_DATE}"
pixi-version: ""
- os: ubuntu-latest
test-folder: just-pyproject-toml
expected-hash: "pixi-lock__4a057faded2062ff018955c0be1db1b9e1d2fb8d1fe4303d8b778af7fd9e411d_{TODAYS_DATE}"
pixi-version: ""
- os: ubuntu-latest
test-folder: pyproject-and-pixi-toml
expected-hash: "pixi-lock__b5bae43771086cb1dd79c43dc06881f8b0e006ad8c54e7269dad1a4f8ce96522_{TODAYS_DATE}"
pixi-version: ""
# Test pixi-version values with fixed OS and test-folder
- os: ubuntu-latest
test-folder: just-pixi-toml
expected-hash: "pixi-lock__69110db0bf39d7ce64fd774c7078ccd56ebf8542d9a1e86f84e63011634dc43f_{TODAYS_DATE}"
pixi-version: ""
- os: ubuntu-latest
test-folder: just-pixi-toml
expected-hash: "pixi-lock_v0.63.2_69110db0bf39d7ce64fd774c7078ccd56ebf8542d9a1e86f84e63011634dc43f_{TODAYS_DATE}"
pixi-version: "v0.63.2"
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
path: pixi-lock
- name: Copy test files to working directory
shell: bash
run: cp -r pixi-lock/ci/test/${{ matrix.test-folder }}/* .
- name: Run create-and-cache action
id: create-and-cache
uses: ./pixi-lock/create-and-cache
with:
pixi-version: ${{ matrix.pixi-version }}
- name: Verify cache key hash matches expected
shell: bash
run: |
actual_hash="${{ steps.create-and-cache.outputs.cache-key }}"
expected_hash="${{ matrix.expected-hash }}"
expected_hash="${expected_hash/\{TODAYS_DATE\}/$(date +%Y-%m-%d)}"
echo "Expected hash: $expected_hash"
echo "Actual hash: $actual_hash"
if [ "$actual_hash" != "$expected_hash" ]; then
echo "ERROR: Hash mismatch!"
echo "Please update the expected-hash in the workflow matrix to: $actual_hash"
exit 1
fi
echo "Hash matches expected value"
- name: Verify pixi.lock exists
shell: bash
run: |
if [ -f "pixi.lock" ]; then
echo "pixi.lock exists"
else
echo "pixi.lock does not exist"
exit 1
fi
- name: Cleanup pixi.lock
shell: bash
run: rm pixi.lock
- name: Cleanup pixi install
shell: bash
run: rm -rf ~/.pixi
- name: Restore pixi.lock from cache
uses: ./pixi-lock/restore
with:
cache-key: ${{ steps.create-and-cache.outputs.cache-key }}
- name: Verify pixi.lock exists after restore
shell: bash
run: |
if [ -f "pixi.lock" ]; then
echo "pixi.lock exists"
else
echo "pixi.lock does not exist"
exit 1
fi
- name: Setup pixi and install environment
uses: prefix-dev/setup-pixi@v0.9.3
with:
pixi-version: ${{ matrix.pixi-version }}
- name: Verify environment installed
shell: bash
run: |
if [ -d ".pixi/envs/default" ]; then
echo "Environment installed successfully"
else
echo "Environment not installed"
exit 1
fi
all-checks-passed:
name: All checks passed
needs: test-cache-restore-install
runs-on: ubuntu-slim
if: always()
steps:
- name: Check if all jobs passed
run: |
if [ "${{ needs.test-cache-restore-install.result }}" != "success" ]; then
echo "test-cache-restore-install did not pass"
exit 1
fi
echo "All checks passed successfully"