Repository navigation
233 lines (233 loc) · 12.5 KB
/
Copy pathbinary-cache.yml
File metadata and controls
233 lines (233 loc) · 12.5 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
name: Build FoxFlake binary cache and update flake locks
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
push:
branches:
- 'main'
paths-ignore:
- 'Readme.md'
concurrency:
group: environment-${{ github.ref }}
cancel-in-progress: true
jobs:
create-foxflake-stable-binary-cache:
runs-on: ubuntu-latest
strategy:
matrix:
branch: [ "stable", "stable-test" ]
steps:
- name: Reclaim disk space
uses: wimpysworld/nothing-but-nix@main
with:
hatchet-protocol: 'cleave'
witness-carnage: true
root-safe-haven: '20480'
- name: Display disk space
run: |
echo "Free space:"
df -h
- name: Checkout branch
uses: actions/checkout@v6
with:
ref: main
- name: Install nix
uses: cachix/install-nix-action@v31
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Install cachix action
uses: cachix/cachix-action@v17
with:
name: foxflake
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
pushFilter: '(\.deb$|\.exe$|\.run$|source$|\.tar\.)'
useDaemon: false
- name: Build FoxFlake binary cache
run: |
sudo fallocate -l 16G /nixswap
sudo chmod 600 /nixswap
sudo mkswap /nixswap
sudo swapon /nixswap
sudo swapon --show
./create_binary_cache.sh ${{ matrix.branch }}
- name: Order FoxFlake binary cache uploads
run: |
while true; do
stable_build_status=$(curl -s -H "Authorization: Bearer ${{ github.token }}" "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs" | jq '.jobs[] | select(.name=="create-foxflake-stable-binary-cache (stable)") | .steps[] | select(.name=="Build FoxFlake binary cache") | .conclusion' | cut -d'"' -f2)
stable_test_build_status=$(curl -s -H "Authorization: Bearer ${{ github.token }}" "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs" | jq '.jobs[] | select(.name=="create-foxflake-stable-binary-cache (stable-test)") | .steps[] | select(.name=="Build FoxFlake binary cache") | .conclusion' | cut -d'"' -f2)
if [ "${stable_build_status}" != "null" ] && [ "${stable_test_build_status}" != "null" ]; then
if [ "${stable_build_status}" == "success" ] && [ "${stable_test_build_status}" == "success" ]; then
break
else
exit 1
fi
fi
echo "Waiting for all stable Build FoxFlake binary cache steps to finish..."
sleep 300
done
while true; do
unstable_push_status=$(curl -s -H "Authorization: Bearer ${{ github.token }}" "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs" | jq '.jobs[] | select(.name=="create-foxflake-unstable-binary-cache (unstable)") | .steps[] | select(.name=="Post Install cachix action") | .conclusion' | cut -d'"' -f2)
unstable_test_push_status=$(curl -s -H "Authorization: Bearer ${{ github.token }}" "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs" | jq '.jobs[] | select(.name=="create-foxflake-unstable-binary-cache (unstable-test)") | .steps[] | select(.name=="Post Install cachix action") | .conclusion' | cut -d'"' -f2)
dev_push_status=$(curl -s -H "Authorization: Bearer ${{ github.token }}" "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs" | jq '.jobs[] | select(.name=="create-foxflake-unstable-binary-cache (dev)") | .steps[] | select(.name=="Post Install cachix action") | .conclusion' | cut -d'"' -f2)
if [ "${unstable_push_status}" != "null" ] && [ "${unstable_test_push_status}" != "null" ] && [ "${dev_push_status}" != "null" ]; then
break
fi
echo "Waiting for create-foxflake-unstable-binary-cache job to finish..."
sleep 300
done
case ${{ matrix.branch }} in
'stable')
while true; do
previous_job_status=$(curl -s -H "Authorization: Bearer ${{ github.token }}" "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs" | jq '.jobs[] | select(.name=="create-foxflake-stable-binary-cache (stable-test)") | .steps[] | select(.name=="Post Install cachix action") | .conclusion' | cut -d'"' -f2)
if [ "${previous_job_status}" == "success" ]; then break; fi
echo "Waiting for stable build to finish (status is ${previous_job_status})..."
sleep 300
done
;;
esac
- name: Upload updated FoxFlake flake.lock
uses: actions/upload-artifact@v7
with:
name: foxflake-${{ matrix.branch }}-flake-lock
path: /home/runner/work/foxflake/foxflake/foxflake-${{ matrix.branch }}-flake.lock
if-no-files-found: error
create-foxflake-unstable-binary-cache:
runs-on: ubuntu-latest
strategy:
matrix:
branch: [ "unstable", "unstable-test", "dev" ]
steps:
- name: Reclaim disk space
uses: wimpysworld/nothing-but-nix@main
with:
hatchet-protocol: 'cleave'
witness-carnage: true
root-safe-haven: '20480'
- name: Display disk space
run: |
echo "Free space:"
df -h
- name: Checkout branch
uses: actions/checkout@v6
with:
ref: main
- name: Install nix
uses: cachix/install-nix-action@v31
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Install cachix action
uses: cachix/cachix-action@v17
with:
name: foxflake
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
pushFilter: '(\.deb$|\.exe$|\.run$|source$|\.tar\.)'
useDaemon: false
- name: Build FoxFlake binary cache
run: |
sudo fallocate -l 16G /nixswap
sudo chmod 600 /nixswap
sudo mkswap /nixswap
sudo swapon /nixswap
sudo swapon --show
./create_binary_cache.sh ${{ matrix.branch }}
- name: Order FoxFlake binary cache uploads
run: |
while true; do
stable_build_status=$(curl -s -H "Authorization: Bearer ${{ github.token }}" "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs" | jq '.jobs[] | select(.name=="create-foxflake-stable-binary-cache (stable)") | .steps[] | select(.name=="Build FoxFlake binary cache") | .conclusion' | cut -d'"' -f2)
stable_test_build_status=$(curl -s -H "Authorization: Bearer ${{ github.token }}" "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs" | jq '.jobs[] | select(.name=="create-foxflake-stable-binary-cache (stable-test)") | .steps[] | select(.name=="Build FoxFlake binary cache") | .conclusion' | cut -d'"' -f2)
unstable_build_status=$(curl -s -H "Authorization: Bearer ${{ github.token }}" "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs" | jq '.jobs[] | select(.name=="create-foxflake-unstable-binary-cache (unstable)") | .steps[] | select(.name=="Build FoxFlake binary cache") | .conclusion' | cut -d'"' -f2)
unstable_test_build_status=$(curl -s -H "Authorization: Bearer ${{ github.token }}" "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs" | jq '.jobs[] | select(.name=="create-foxflake-unstable-binary-cache (unstable-test)") | .steps[] | select(.name=="Build FoxFlake binary cache") | .conclusion' | cut -d'"' -f2)
dev_build_status=$(curl -s -H "Authorization: Bearer ${{ github.token }}" "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs" | jq '.jobs[] | select(.name=="create-foxflake-unstable-binary-cache (dev)") | .steps[] | select(.name=="Build FoxFlake binary cache") | .conclusion' | cut -d'"' -f2)
if [ "${stable_build_status}" != "null" ] && [ "${stable_test_build_status}" != "null" ] && [ "${unstable_build_status}" != "null" ] && [ "${unstable_test_build_status}" != "null" ] && [ "${dev_build_status}" != "null" ]; then
if [ "${stable_build_status}" == "success" ] && [ "${stable_test_build_status}" == "success" ] && [ "${unstable_build_status}" == "success" ] && [ "${unstable_test_build_status}" == "success" ] && [ "${dev_build_status}" == "success" ]; then
break
else
exit 1
fi
fi
echo "Waiting for all Build FoxFlake binary cache steps to finish..."
sleep 300
done
case ${{ matrix.branch }} in
'unstable')
while true; do
unstable_test_wait_status=$(curl -s -H "Authorization: Bearer ${{ github.token }}" "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs" | jq '.jobs[] | select(.name=="create-foxflake-unstable-binary-cache (unstable-test)") | .steps[] | select(.name=="Post Install cachix action") | .conclusion' | cut -d'"' -f2)
if [ "${unstable_test_wait_status}" == "success" ]; then break; fi
echo "Waiting for unstable-test push to finish (status is ${unstable_test_wait_status})..."
sleep 300
done
;;
'unstable-test')
while true; do
dev_wait_status=$(curl -s -H "Authorization: Bearer ${{ github.token }}" "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs" | jq '.jobs[] | select(.name=="create-foxflake-unstable-binary-cache (dev)") | .steps[] | select(.name=="Post Install cachix action") | .conclusion' | cut -d'"' -f2)
if [ "${dev_wait_status}" == "success" ]; then break; fi
echo "Waiting for dev push to finish (status is ${dev_wait_status})..."
sleep 300
done
;;
esac
- name: Upload updated FoxFlake flake.lock
uses: actions/upload-artifact@v7
with:
name: foxflake-${{ matrix.branch }}-flake-lock
path: /home/runner/work/foxflake/foxflake/foxflake-${{ matrix.branch }}-flake.lock
if-no-files-found: error
update-foxflake-stable-flake-locks:
needs: create-foxflake-stable-binary-cache
if: ${{ !cancelled() && contains(join(needs.*.result, ','), 'success') }}
permissions:
contents: write
runs-on: ubuntu-latest
strategy:
matrix:
branch: [ "stable", "stable-test" ]
steps:
- name: Checkout ${{ matrix.branch }} branch
uses: actions/checkout@v6
with:
ref: ${{ matrix.branch }}
- name: Download FoxFlake ${{ matrix.branch }} flake lock
uses: actions/download-artifact@v8
with:
name: foxflake-${{ matrix.branch }}-flake-lock
path: /home/runner/work/foxflake/foxflake/
- name: Copy FoxFlake ${{ matrix.branch }} flake lock
run: |
cp ./foxflake-${{ matrix.branch }}-flake.lock ./flake.lock
rm ./foxflake-${{ matrix.branch }}-flake.lock
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v7
with:
branch: ${{ matrix.branch }}
commit_message: Update flake lock
update-foxflake-unstable-flake-locks:
needs: create-foxflake-unstable-binary-cache
if: ${{ !cancelled() && contains(join(needs.*.result, ','), 'success') }}
permissions:
contents: write
runs-on: ubuntu-latest
strategy:
matrix:
branch: [ "unstable","unstable-test","dev" ]
steps:
- name: Checkout ${{ matrix.branch }} branch
uses: actions/checkout@v6
with:
ref: ${{ matrix.branch }}
- name: Download FoxFlake ${{ matrix.branch }} flake lock
uses: actions/download-artifact@v8
with:
name: foxflake-${{ matrix.branch }}-flake-lock
path: /home/runner/work/foxflake/foxflake/
- name: Copy FoxFlake ${{ matrix.branch }} flake lock
run: |
cp ./foxflake-${{ matrix.branch }}-flake.lock ./flake.lock
rm ./foxflake-${{ matrix.branch }}-flake.lock
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v7
with:
branch: ${{ matrix.branch }}
commit_message: Update flake lock