forked from fedify-dev/fedify
-
Notifications
You must be signed in to change notification settings - Fork 0
533 lines (510 loc) · 17.1 KB
/
main.yaml
File metadata and controls
533 lines (510 loc) · 17.1 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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
#
# Main CI workflow for testing, linting, and publishing to JSR/npm.
# npm publishing is handled by build.yaml, which is triggered via workflow_dispatch
# from the publish-npm job. This allows npm publishing to run in parallel with
# docs publishing, rather than waiting for the entire workflow to complete.
# See build.yaml for details on why this separation is required for npm's
# trusted publishing (OIDC).
name: main
on: [push, pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
issues: read
checks: write
pull-requests: write
services:
rabbitmq:
image: rabbitmq
env:
RABBITMQ_DEFAULT_USER: guest
RABBITMQ_DEFAULT_PASS: guest
ports:
- 5672:5672
options: >-
--health-cmd "rabbitmq-diagnostics -q ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
mysql:
image: mysql:8
env:
MYSQL_ROOT_PASSWORD: mysql
MYSQL_DATABASE: fedify
options: >-
--health-cmd "mysqladmin ping -h 127.0.0.1 -uroot -pmysql"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 3306:3306
env:
AMQP_URL: amqp://guest:guest@localhost:5672
MYSQL_URL: mysql://root:mysql@localhost:3306/fedify
POSTGRES_URL: postgres://postgres:postgres@localhost:5432/postgres
REDIS_URL: redis://localhost:6379
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-mise
- name: Enable RabbitMQ consistent hash exchange plugin
run: docker exec ${{ job.services.rabbitmq.id }} rabbitmq-plugins enable rabbitmq_consistent_hash_exchange
- run: mise run --skip-deps test:deno -- --coverage=.cov --junit-path=.test-report.xml
env:
RUST_BACKTRACE: ${{ runner.debug }}
LOG: ${{ runner.debug && 'always' || '' }}
AMQP_ORDERING_TEST: "true"
- uses: dorny/test-reporter@v2
if: success() || failure()
with:
name: "Test Results (${{ matrix.os }})"
path: .test-report.xml
reporter: jest-junit
continue-on-error: true
- if: '!cancelled()'
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: .test-report.xml
- run: deno coverage --lcov .cov > .cov.lcov
continue-on-error: true
- uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: .cov.lcov
continue-on-error: true
test-node:
runs-on: ubuntu-latest
services:
rabbitmq:
image: rabbitmq
env:
RABBITMQ_DEFAULT_USER: guest
RABBITMQ_DEFAULT_PASS: guest
ports:
- 5672:5672
options: >-
--health-cmd "rabbitmq-diagnostics -q ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
mysql:
image: mysql:8
env:
MYSQL_ROOT_PASSWORD: mysql
MYSQL_DATABASE: fedify
options: >-
--health-cmd "mysqladmin ping -h 127.0.0.1 -uroot -pmysql"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 3306:3306
env:
AMQP_URL: amqp://guest:guest@localhost:5672
MYSQL_URL: mysql://root:mysql@localhost:3306/fedify
POSTGRES_URL: postgres://postgres:postgres@localhost:5432/postgres
REDIS_URL: redis://localhost:6379
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-mise
- name: Enable RabbitMQ consistent hash exchange plugin
run: docker exec ${{ job.services.rabbitmq.id }} rabbitmq-plugins enable rabbitmq_consistent_hash_exchange
- run: mise run --skip-deps test:node
env:
AMQP_ORDERING_TEST: "true"
test-bun:
runs-on: ubuntu-latest
services:
rabbitmq:
image: rabbitmq
env:
RABBITMQ_DEFAULT_USER: guest
RABBITMQ_DEFAULT_PASS: guest
ports:
- 5672:5672
options: >-
--health-cmd "rabbitmq-diagnostics -q ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
mysql:
image: mysql:8
env:
MYSQL_ROOT_PASSWORD: mysql
MYSQL_DATABASE: fedify
options: >-
--health-cmd "mysqladmin ping -h 127.0.0.1 -uroot -pmysql"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 3306:3306
env:
AMQP_URL: amqp://guest:guest@localhost:5672
MYSQL_URL: mysql://root:mysql@localhost:3306/fedify
POSTGRES_URL: postgres://postgres:postgres@localhost:5432/postgres
REDIS_URL: redis://localhost:6379
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-mise
- name: Enable RabbitMQ consistent hash exchange plugin
run: docker exec ${{ job.services.rabbitmq.id }} rabbitmq-plugins enable rabbitmq_consistent_hash_exchange
- run: mise run --skip-deps test:bun
env:
AMQP_ORDERING_TEST: "true"
test-cfworkers:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-mise
- run: deno task test:cfworkers
working-directory: ${{ github.workspace }}/packages/fedify/
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-mise
- run: mise run check
release-test:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-mise
- run: '[[ "$(jq -r .version deno.json)" = "$(jq -r .version package.json)" ]]'
working-directory: ${{ github.workspace }}/packages/fedify/
- run: mise run codegen
- run: deno publish --dry-run --allow-slow-types
- run: pnpm publish --recursive --dry-run --no-git-checks --ignore-scripts
# ===========================================================================
# PR-only jobs: Validate CLI and docs build
# ===========================================================================
build-cli-pr:
if: github.event_name == 'pull_request'
needs: [release-test]
runs-on: namespace-profile-linux-amd64-16gb
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-mise
- run: mise run codegen
- run: deno task pack
working-directory: ${{ github.workspace }}/packages/cli/
env:
CONCURRENCY: "3"
- uses: actions/upload-artifact@v4
with:
name: cli-pr-${{ github.event.pull_request.number }}
path: |
packages/cli/fedify-cli-*.tar.xz
packages/cli/fedify-cli-*.zip
build-docs-pr:
if: github.event_name == 'pull_request'
needs: [release-test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-mise
- run: pnpm run build
working-directory: ${{ github.workspace }}/docs/
- uses: actions/upload-artifact@v4
with:
name: docs-pr-${{ github.event.pull_request.number }}
path: docs/.vitepress/dist
# ===========================================================================
# Push-only jobs: Determine version
# ===========================================================================
determine-version:
if: github.event_name == 'push'
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
short_version: ${{ steps.version.outputs.short_version }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-mise
- id: version
uses: ./.github/actions/determine-version
- if: github.ref_type == 'tag'
run: |
set -ex
[[ "$(jq -r .version deno.json)" = "$GITHUB_REF_NAME" ]]
! grep -i "to be released" CHANGES.md
working-directory: ${{ github.workspace }}/packages/fedify/
# ===========================================================================
# Push-only jobs: Build artifacts (run in parallel after version determined)
# ===========================================================================
build-cli:
if: github.event_name == 'push'
needs: [test, test-node, test-bun, test-cfworkers, lint, release-test, determine-version]
runs-on: namespace-profile-linux-amd64-16gb
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-mise
- uses: ./.github/actions/determine-version
- run: mise run codegen
- run: deno task pack
working-directory: ${{ github.workspace }}/packages/cli/
env:
CONCURRENCY: "3"
- uses: actions/upload-artifact@v4
with:
name: cli
path: |
packages/cli/fedify-cli-*.tar.xz
packages/cli/fedify-cli-*.zip
build-packages:
if: github.event_name == 'push'
needs: [test, test-node, test-bun, test-cfworkers, lint, release-test, determine-version]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-mise
- uses: ./.github/actions/determine-version
- run: sudo npm install -g npm@latest && npm --version
- run: pnpm -r --filter='!./examples/**' run build:self
- run: |
pnpm pack --recursive --filter='!./examples/**' --config.ignore-scripts=true
# Remove private packages
for pkg in fedify-*.tgz; do
if tar -xOzf "$pkg" package/package.json | jq -e '.private == true' > /dev/null 2>&1; then
echo "Removing private package: $pkg"
rm "$pkg"
fi
done
if [[ "$GITHUB_REF_TYPE" != tag ]]; then
rm fedify-cli-*.tgz
fi
- uses: actions/upload-artifact@v4
with:
name: npm-packages
path: fedify-*.tgz
publish-jsr:
if: github.event_name == 'push'
needs: [test, test-node, test-bun, test-cfworkers, lint, release-test, determine-version]
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-mise
- uses: ./.github/actions/determine-version
- run: |
set -ex
mise run codegen
max_attempts=5
attempt=1
until deno publish --allow-dirty --allow-slow-types; do
exit_code=$?
if [[ $attempt -ge $max_attempts ]]; then
echo "deno publish failed after $max_attempts attempts"
exit $exit_code
fi
echo "deno publish failed (attempt $attempt/$max_attempts), retrying in 30 seconds..."
sleep 30
((attempt++))
done
# ===========================================================================
# Push-only jobs: Create GitHub release (tag only)
# ===========================================================================
create-release:
if: github.event_name == 'push' && github.ref_type == 'tag'
needs: [build-cli, build-packages, publish-jsr]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: cli
path: cli-artifacts/
- uses: actions/download-artifact@v4
with:
name: npm-packages
path: npm-artifacts/
- id: extract-changelog
uses: dahlia/submark@5a5ff0a58382fb812616a5801402f5aef00f90ce
with:
input-file: CHANGES.md
heading-level: 2
heading-title-text: version ${{ github.ref_name }}
ignore-case: true
omit-heading: true
- run: 'cat "$CHANGES_FILE"'
env:
CHANGES_FILE: ${{ steps.extract-changelog.outputs.output-file }}
- uses: softprops/action-gh-release@v1
with:
body_path: ${{ steps.extract-changelog.outputs.output-file }}
name: Fedify ${{ github.ref_name }}
files: |
npm-artifacts/fedify-*.tgz
cli-artifacts/fedify-cli-*.tar.xz
cli-artifacts/fedify-cli-*.zip
generate_release_notes: false
# ===========================================================================
# Push-only jobs: Publish to npm and docs
# ===========================================================================
# Trigger build.yaml via workflow_dispatch to publish to npm.
# This is required because npm's trusted publishing (OIDC) validates
# the directly triggered workflow, not reusable workflows called via
# workflow_call. By triggering build.yaml directly, npm sees build.yaml
# as the entry point and validates against it.
publish-npm:
if: github.event_name == 'push'
needs: [build-packages]
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Trigger build.yaml workflow
uses: actions/github-script@v7
with:
script: |
// Determine tag based on ref type
let tag;
if (context.payload.ref && context.payload.ref.startsWith('refs/tags/')) {
tag = 'latest';
} else {
tag = 'dev';
}
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'build.yaml',
ref: context.ref,
inputs: {
run_id: '${{ github.run_id }}',
tag: tag
}
});
console.log(`Triggered build.yaml workflow with run_id=${{ github.run_id }}, tag=${tag}`);
publish-docs:
if: github.event_name == 'push'
needs: [publish-jsr, determine-version]
runs-on: ubuntu-latest
permissions:
id-token: write
pages: write
deployments: write
statuses: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-mise
- run: |
set -ex
if [[ "$GITHUB_REF_TYPE" = "tag" ]]; then
EXTRA_NAV_TEXT=Unstable \
EXTRA_NAV_LINK="$UNSTABLE_DOCS_URL" \
SITEMAP_HOSTNAME="$STABLE_DOCS_URL" \
JSR_REF_VERSION=stable \
pnpm run build
else
EXTRA_NAV_TEXT=Stable \
EXTRA_NAV_LINK="$STABLE_DOCS_URL" \
SITEMAP_HOSTNAME="$UNSTABLE_DOCS_URL" \
JSR_REF_VERSION=unstable \
pnpm run build
fi
env:
SHORT_VERSION: ${{ needs.determine-version.outputs.short_version }}
PLAUSIBLE_DOMAIN: ${{ secrets.PLAUSIBLE_DOMAIN }}
STABLE_DOCS_URL: ${{ vars.STABLE_DOCS_URL }}
UNSTABLE_DOCS_URL: ${{ vars.UNSTABLE_DOCS_URL }}
working-directory: ${{ github.workspace }}/docs/
- uses: actions/upload-pages-artifact@v3
with:
path: docs/.vitepress/dist
- id: deployment
if: github.ref_type == 'tag'
uses: actions/deploy-pages@v4
- if: github.ref == 'refs/heads/main'
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
gitHubToken: ${{ github.token }}
command: >-
pages deploy .vitepress/dist
--project-name=${{ vars.CLOUDFLARE_PROJECT_NAME }}
packageManager: pnpm
workingDirectory: ${{ github.workspace }}/docs/
# cSpell: ignore submark softprops npmjs deployctl nwtgck thollander elif