-
-
Notifications
You must be signed in to change notification settings - Fork 633
318 lines (271 loc) Β· 10.5 KB
/
tests.yml
File metadata and controls
318 lines (271 loc) Β· 10.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
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
308
309
310
311
312
313
314
315
316
317
318
name: CI
on:
push:
branches:
- main
pull_request:
schedule:
# Every 15 minutes
- cron: "*/15 * * * *"
workflow_dispatch:
concurrency:
group: scheduled-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
generate-cask:
if: startsWith( github.repository, 'Homebrew/' )
name: Generate homebrew/cask data, pages and API
runs-on: macos-latest
timeout-minutes: 20
permissions:
contents: read
steps:
- name: Check out repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
persist-credentials: false
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@main
with:
core: false
cask: true
stable: false
- run: brew generate-cask-api
env:
HOMEBREW_DEVELOPER: 1
- name: Archive data
run: tar czvf data-cask.tar.gz _data/cask/ api/cask/ api/cask-source/ api/cask_tap_migrations.json api/internal/cask.* cask/
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: data-cask
path: data-cask.tar.gz
retention-days: 1
generate-core:
if: startsWith( github.repository, 'Homebrew/' )
name: Generate homebrew/core data, pages and API
runs-on: macos-latest
timeout-minutes: 20
permissions:
contents: read
steps:
- name: Check out repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
persist-credentials: false
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@main
with:
core: true
cask: false
stable: false
- run: brew test-bot --only-cleanup-before
- run: brew generate-formula-api
env:
HOMEBREW_DEVELOPER: 1
- name: Archive data
run: tar czvf data-core.tar.gz _data/formula/ _data/formula_canonical.json api/formula/ api/formula_tap_migrations.json api/internal/formula.* formula/
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: data-core
path: data-core.tar.gz
retention-days: 1
generate-internal:
if: startsWith( github.repository, 'Homebrew/' )
name: Generate internal API data
runs-on: macos-latest
timeout-minutes: 20
permissions:
contents: read
steps:
- name: Check out repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
persist-credentials: false
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@main
with:
core: true
cask: true
stable: false
- run: brew test-bot --only-cleanup-before
- run: brew generate-internal-api
env:
HOMEBREW_DEVELOPER: 1
- name: Archive data
run: tar czvf data-internal.tar.gz api/internal/packages.*
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: data-internal
path: data-internal.tar.gz
retention-days: 1
generate-analytics:
if: startsWith( github.repository, 'Homebrew/' )
name: Generate analytics data
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read
steps:
- name: Check out repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
persist-credentials: false
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@main
with:
core: false
cask: false
stable: false
- name: Set up Ruby
uses: ruby/setup-ruby@7372622e62b60b3cb750dcd2b9e32c247ffec26a # v1.302.0
with:
bundler-cache: true
- name: Get Python version file
id: get-python-version
run: |
echo "python-version-file=$(brew --repo)/Library/Homebrew/formula-analytics/.python-version" >> "$GITHUB_OUTPUT"
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version-file: ${{ steps.get-python-version.outputs.python-version-file }}
- name: Create directories
run: mkdir -p _data/analytics api/analytics
- name: Determine analytics cache date
id: analytics-cache-date
run: echo "date=$(date -u +%Y-%m-%d)" >> "$GITHUB_OUTPUT"
- name: Cache analytics data
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: |
_data/analytics
api/analytics
key: analytics-data-${{ steps.analytics-cache-date.outputs.date }}
restore-keys: analytics-data-
- name: Update analytics data
run: |
set -euo pipefail
analytics_backup_path="$(mktemp -d)"
mv -v "_data/analytics" "${analytics_backup_path}/data_analytics"
mv -v "api/analytics" "${analytics_backup_path}/api_analytics"
if brew generate-analytics-api; then
exit 0
fi
rm -rf "_data/analytics" "api/analytics"
mv -v "${analytics_backup_path}/data_analytics" "_data/analytics"
mv -v "${analytics_backup_path}/api_analytics" "api/analytics"
echo "::notice title=Analytics fallback::Restored cached analytics data after brew generate-analytics-api failure."
if: github.ref_name == 'main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false && github.event.pull_request.user.login != 'dependabot[bot]')
env:
HOMEBREW_INFLUXDB_TOKEN: ${{ secrets.HOMEBREW_INFLUXDB_READ_TOKEN }}
- name: Archive data
run: tar czvf data-analytics.tar.gz _data/analytics api/analytics
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: data-analytics
path: data-analytics.tar.gz
retention-days: 1
build:
needs: [generate-cask, generate-core, generate-internal, generate-analytics]
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read
steps:
- name: Set up Git repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@main
with:
core: false
cask: false
stable: false
- name: Set up Ruby
uses: ruby/setup-ruby@7372622e62b60b3cb750dcd2b9e32c247ffec26a # v1.302.0
with:
bundler-cache: true
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
- name: Move artifacts into place
run: |
tar xvf data-analytics/data-analytics.tar.gz
tar xvf data-cask/data-cask.tar.gz
tar xvf data-core/data-core.tar.gz
tar xvf data-internal/data-internal.tar.gz
- name: Install oras for pulling from GitHub Packages
run: brew install oras
- name: Pull executables.txt from GitHub Packages
run: oras pull ghcr.io/homebrew/command-not-found/executables:latest --output api/internal
- name: Generate API samples
run: |
GENERATE_SAMPLES="${{ github.ref_name == 'main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false && github.event.pull_request.user.login != 'dependabot[bot]') }}"
if [ "$GENERATE_SAMPLES" = "true" ]; then
ruby script/generate-api-samples.rb
else
ruby script/generate-api-samples.rb --template
fi
- name: Build site
run: bundle exec jekyll build
- name: Validate build
run: ./script/validate-build.rb
- name: Sign API
if: github.ref_name == 'main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false && github.event.pull_request.user.login != 'dependabot[bot]')
env:
JWS_SIGNING_KEY_ID: homebrew-1
JWS_SIGNING_KEY: ${{ secrets.JWS_HOMEBREW_1 }}
run: ./script/sign-json.rb
- name: Upload artifact
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
deploy:
needs: build
if: ${{ github.ref_name == 'main' }}
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
outputs:
deploy_url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0
deploy-issue:
name: Open/close deploy issues
needs: [generate-cask, generate-core, generate-analytics, generate-internal, build, deploy]
if: ${{ always() && github.ref_name == 'main' }}
env:
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
issues: write # for Homebrew/actions/create-or-update-issue
steps:
- name: Open, update, or close deploy issue
uses: Homebrew/actions/create-or-update-issue@main
with:
token: ${{ github.token }}
repository: ${{ github.repository }}
title: formulae.brew.sh deployment failed!
body: The most recent [formulae.brew.sh deployment failed](${{ env.RUN_URL }}).
labels: deploy failure
update-existing: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped') }}
close-existing: ${{ needs.deploy.result == 'success' }}
close-from-author: github-actions[bot]
close-comment: The most recent [formulae.brew.sh deployment succeeded](${{ env.RUN_URL }}). Closing issue.