-
Notifications
You must be signed in to change notification settings - Fork 34
308 lines (262 loc) · 11.4 KB
/
tests.yml
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
---
name: brew test-bot
on:
push:
branches:
- main
- master
pull_request:
workflow_dispatch: # NOTE: nova with homebrew gha
env:
HOMEBREW_NO_ANALYTICS: 1
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
HOMEBREW_NO_INSTALL_FROM_API: 1
HOMEBREW_DEVELOPER: 1
jobs:
test-bot:
strategy:
# NOTE: ipatch, `fail-fast` disabled because subsequent runners can not run job if previous job failed
fail-fast: false
matrix:
# os: [ubuntu-latest, macos-latest] # NOTE: default
# NOTE: homebrew/homebrew-core uses private self hosted runners
# https://github.com/actions/runner-images
os:
# NOTE: macos-*-large runner requires additional spending limits
# - macos-14-large
- macos-15
- macos-14
# - macos-13-large
# NOTE: macos-13 is the last free intel runner provided by github
- macos-13
# - macos-12-large
# upstream homebrew-core has deprecated macos-12 and github will retire images on 12/3/24
# - macos-12
- ubuntu-22.04
# - self-hosted-catalinavm
# - self-hosted-bigsurvm
# - self-hosted-mojavevm
# - self-hosted-ubuntu-22.04
# NOTE: ipatch, all three self hosted runners (vms) are hosted on same computer
# ...so limit job to one runner at a time.
# REF:
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#defining-the-maximum-number
# max-parallel: 1
max-parallel: 5
runs-on: ${{ matrix.os }}
permissions: read-all
# permissions:
# actions: write
# contents: write
# packages: write
# pull-requests: write
timeout-minutes: 1200
steps:
- name: Test GitHub Token, ie. HOMEBREW_GITHUB_API_TOKEN
continue-on-error: true
run: |
RESPONSE=$(curl -s -L \
-H "Authorization: Bearer ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}" \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/freecad/homebrew-freecad/actions/runners)
# echo "API response: $RESPONSE"
if echo "$RESPONSE" | grep -q '"message": "Bad credentials"'; then
echo "Error: Bad credentials - the GitHub token may be invalid or lacks permissions."
exit 1
fi
echo "Success: GitHub token is valid."
- name: Get current date
id: get-current-date
run: echo "date=$(date +'%Y-%m-%dT%H:%M:%S')" >> "$GITHUB_ENV"
- name: Set date output
id: set-date
run: echo "date=$(date +'%Y-%m-%dT%H:%M:%S')" >> "$GITHUB_OUTPUT"
- name: Print value of date from previous step
id: print-date
run: echo "${{ steps.set-date.outputs.date }}"
- name: Set default run status
id: set-default-run-status
run: echo "last-run-status=default" >> "$GITHUB_ENV"
- name: Restore last run status
id: restore-last-run-status
uses: actions/[email protected]
with:
path: |
last-run-status
key: |
${{ github.run_id }}-${{ matrix.os }}-${{ steps.set-date.outputs.date }}
restore-keys: |
${{ github.run_id }}-${{ matrix.os }}-
- name: Set last run status
id: set-last-run-status
run: echo "last-run-status=${{ env.last-run-status }}" >> "GITHUB_OUTPUT"
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Cache Homebrew Bundler RubyGems
if: steps.set-last-run-status.outputs.last-run-status != 'success'
id: cache
uses: actions/[email protected]
with:
path: ${{ steps.set-up-homebrew.outputs.gems-path }}
key: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }}
restore-keys: ${{ runner.os }}-rubygems-
- name: Fetch GitHub runners and check if self-hosted
continue-on-error: true
id: fetch-runners-then-check-for-self-hosted
run: |
RESPONSE=$(curl -s -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/freecad/homebrew-freecad/actions/runners)
# debug output of response
echo "API response: $RESPONSE"
# Check if any runner is self-hosted
RUNNER_NAME=$(echo "$RESPONSE" | jq -r '.runners[] | select(.labels[]?.name == "self-hosted") | .name')
if [ -n "$RUNNER_NAME" ]; then
echo "GITHUB_ACTIONS_HOMEBREW_SELF_HOSTED=1" >> "$GITHUB_ENV"
echo "Self-hosted runner found: $RUNNER_NAME"
else
echo "No self-hosted runner found"
fi
- name: manually update GITHUB_ENV based on RUNNER_NAME
id: update-github_env-based-on-runner_name
run: |
if [ "$RUNNER_NAME" = "self-hosted-ubuntu-22.04" ]; then
echo "GITHUB_ACTIONS_HOMEBREW_SELF_HOSTED=1" >> "$GITHUB_ENV"
echo "HOMEBREW_GITHUB_ACTIONS=1" >> "$GITHUB_ENV"
export GITHUB_ACTIONS_HOMEBREW_SELF_HOSTED=1
export HOMEBREW_GITHUB_ACTIONS=1
echo "Self-hosted runner found: $RUNNER_NAME"
else
echo "No self-hosted runner found"
fi
# # Step to add Homebrew paths to GITHUB_ENV if using act locally
# - name: Set Homebrew environment variables for act
# if: runner.os == 'Linux' && env.ACT == 'true'
# run: |
# #!/bin/bash
# echo "Adding Homebrew paths to GITHUB_ENV"
# {
# echo "PATH=/home/linuxbrew/.linuxbrew/sbin:/home/linuxbrew/.linuxbrew/bin:${PATH}"
# echo "HOMEBREW_PREFIX=/home/linuxbrew/.linuxbrew"
# echo "HOMEBREW_NO_ANALYTICS=1"
# } >> "$GITHUB_ENV"
- name: print message about adding homebrew paths to GITHUB_ENV
if: runner.os == 'Linux' && env.ACT == 'true'
run: |
echo "Adding Homebrew paths to GITHUB_ENV"
- name: add paths to GIHTUB_ENV
if: runner.os == 'Linux' && env.ACT == 'true'
run: |
echo "PATH=/home/linuxbrew/.linuxbrew/sbin:/home/linuxbrew/.linuxbrew/bin:${PATH}" >> "$GITHUB_ENV"
- name: disable homebrew analytics and store value in GITHUB_ENV
if: runner.os == 'Linux' && env.ACT == 'true'
run: |
echo "HOMEBREW_NO_ANALYTICS=1" >> "$GITHUB_ENV"
- name: print env
id: print-env
run: env
- name: run brew config
run: brew config
- name: check env
id: print-the-value-of-GITHUB_ACTIONS_HOMEBREW_SELF_HOSTED-env-var
run: |
echo "the value of GITHUB_ACTIONS_HOMEBREW_SELF_HOSTED is $GITHUB_ACTIONS_HOMEBREW_SELF_HOSTED"
- name: condition, check runner name
# NOTE: use a condition to add env var for mojave runner
# REF: https://docs.github.com/en/actions/learn-github-actions/environment-variables
if: runner.name == 'vmmojave'
run: echo "The operating system on the runner is, $RUNNER_OS."; echo HOMEBREW_DEVELOPER=1 >> "$GITHUB_ENV"
# NOTE: not possible to have two `run:` blocks within a `name`
- name: Install Homebrew Bundler RubyGems
if: steps.cache.outputs.cache-hit != 'true' && steps.set-last-run-status.outputs.last-run-status != 'success'
run: brew install-bundler-gems
- name: only run brew test-bot cleanup before on github hosted runners
if: ${{ !contains(matrix.os, 'self-hosted-ubuntu-22.04') }}
id: brew-test-bot-cleanup-before
run: |
brew test-bot --only-cleanup-before
- run: brew test-bot --only-setup
- run: brew test-bot --only-tap-syntax
- name: check for catalina vm and set homebrew-core repo to specific commit
# NOTE: ipatch, attempt to set homebrew-core repo to specific commit for catalina bottling
if: runner.name == 'vmcatalina'
run: |
cd "$(brew --repo homebrew/core)"; \
git checkout ipatch-1015-cmake-bottle
- name: condition, update style exceptions for vmmojave
if: runner.name == 'vmmojave'
run: |
sed -i '' \
-e '/[email protected]/d' \
-e '/[email protected]/d' \
-e '/[email protected]/d' \
-e '/[email protected]/d' \
"$(brew --repo homebrew/core)/style_exceptions/binary_bootstrap_formula_urls_allowlist.json"
- name: unset HOMEBREW_NO_INSTALL_FROM_API for linux runners -------------------
# NOTE: ipatch, env var required, see, https://github.com/orgs/Homebrew/discussions/4856
run: |
if [[ $RUNNER_OS == 'Linux' ]]; then
unset HOMEBREW_NO_INSTALL_FROM_API
fi
# - name: print event name ----------------------------------------DEBUG
# run: |
# echo "Event Name: ${{ github.event_name }}"
# echo "Event Content: ${{ toJson(github.event) }}"
- name: build bottle using test-bot for current formula
id: build-bottle
# Check if the runner name is vmmojave or vmcatalina and add the flag if true
# NOTE: ipatch, keep-old is not the droid you're looking for,
# see: https://github.com/orgs/Homebrew/discussions/4935
# --keep-old \
run: |
if [[ runner.name == 'vmmojave' || runner.name == 'vmcatalina' ]]; then
brew test-bot \
--skip-online-checks \
--only-formulae \
--only-json-tab \
--skip-recursive-dependents \
--build-dependents-from-source \
--root-url=https://ghcr.io/v2/freecad/homebrew-freecad
else
brew test-bot \
--skip-online-checks \
--only-formulae \
--only-json-tab \
--skip-recursive-dependents \
--root-url=https://ghcr.io/v2/freecad/homebrew-freecad
fi
if: github.event_name == 'pull_request'
# - name: debug with tmate on failure
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3
- name: debug with lhotari/action-upterm
id: debug-workflow-run
if: ${{ failure() && !env.ACT }} # skip during local actions testing using `act`
# NOTE: ipatch, issue with macos runners circa oct 2024
# uses: lhotari/action-upterm@v1
#-------
uses: owenthereal/action-upterm@v1
with:
# limit ssh access to user who triggered the workflow
limit-access-to-actor: true
# shut down server after 10 minutes if no one connects
wait-timeout-minutes: 10
- name: Upload bottles as artifact
# NOTE: ipatch, issue using upload-artifact@v4
# see: https://github.com/actions/upload-artifact/issues/478
id: upload-bottle-artifacts
if: always() && github.event_name == 'pull_request'
# uses: actions/[email protected]
uses: actions/[email protected]
with:
name: bottles
path: '*.bottle.*'
- name: Save run status
id: save-run-status
if: steps.set-last-run-status.outputs.last-run-status != 'success'
run: echo "last-run-status=${{ steps.build-bottle.outcome }}" >> "$GITHUB_ENV"