-
Notifications
You must be signed in to change notification settings - Fork 14
695 lines (573 loc) · 26.2 KB
/
check.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
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
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
name: Checks
on:
pull_request:
types: [opened, synchronize]
push:
branches:
- main
merge_group:
types: [checks_requested]
concurrency:
group: ${{ github.ref }}
cancel-in-progress: ${{ !contains(github.event.head_commit.message, 'prepare release')}}
# Uncomment the line below to enable artifacts debugging
# env:
# ACTIONS_RUNNER_DEBUG: true
jobs:
notification:
runs-on: ubuntu-22.04
timeout-minutes: 1
if: ${{ !github.event.pull_request.head.repo.fork && github.event.number }}
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ secrets.ALGOLIA_BOT_TOKEN }}
message: |
### 🪓 The generated code will be pushed at the end of the CI.
Action triggered by commit [`${{ github.sha }}`](${{ github.event.pull_request.base.repo.html_url }}/commit/${{ github.sha }}).
_Please do not push any generated code to this pull request._
setup:
runs-on: ubuntu-22.04
timeout-minutes: 10
env:
CACHE_VERSION: 1.11 # bump this to run all clients on the CI.
steps:
- name: debugging - dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup
id: setup
uses: ./.github/actions/setup
# Computing jobs that should run
- name: Setting diff outputs variables
id: diff
shell: bash
run: |
previousCommit=${{ github.event.before }}
baseRef=${{ github.base_ref }}
origin=$( [[ -z $baseRef ]] && echo $previousCommit || echo "origin/$baseRef" )
yarn workspace scripts setRunVariables "$origin"
- name: Compute specs matrix
id: spec-matrix
shell: bash
run: yarn workspace scripts createMatrix ${{ steps.diff.outputs.ORIGIN_BRANCH }}
- name: Compute the client codegen matrix
id: gen-matrix
shell: bash
run: yarn workspace scripts createMatrix ${{ steps.diff.outputs.ORIGIN_BRANCH }} clients
- name: check that custom actions are built
run: |
yarn workspace scripts build:actions
diff=$(git status --porcelain ./scripts/ci/actions | wc -l)
if [[ $diff > 0 ]]; then
echo "Build the custom github actions by running \`yarn workspace scripts build:actions\`"
git status --porcelain ./scripts/ci/actions
fi
exit $diff
- name: Lint GitHub actions
run: yarn github-actions:lint
- name: Lint generators
run: |
yarn cli format java generators
diff=$(git status --porcelain ./generators | wc -l)
if [[ $diff > 0 ]]; then
echo "Format the generators folder by running 'apic format java generators'"
fi
exit $diff
- name: Lint json files
run: |
yarn eslint --ext=json .
echo 'Use yarn fix:json to fix issues'
outputs:
RUN_SCRIPTS: ${{ steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 }}
RUN_WEBSITE: ${{ steps.diff.outputs.WEBSITE_CHANGED > 0 }}
SPECS_MATRIX: ${{ steps.spec-matrix.outputs.MATRIX }}
RUN_GEN: ${{ steps.gen-matrix.outputs.RUN_GEN }}
GEN_MATRIX: ${{ steps.gen-matrix.outputs.GEN_MATRIX }}
JAVASCRIPT_DATA: ${{ steps.gen-matrix.outputs.JAVASCRIPT_DATA }}
RUN_GEN_JAVASCRIPT: ${{ steps.gen-matrix.outputs.RUN_GEN_JAVASCRIPT }}
SWIFT_DATA: ${{ steps.gen-matrix.outputs.SWIFT_DATA }}
RUN_MACOS_SWIFT_CTS: ${{ steps.gen-matrix.outputs.RUN_MACOS_SWIFT_CTS }}
KOTLIN_DATA: ${{ steps.gen-matrix.outputs.KOTLIN_DATA }}
RUN_MACOS_KOTLIN_BUILD: ${{ steps.gen-matrix.outputs.RUN_MACOS_KOTLIN_BUILD }}
scripts:
runs-on: ubuntu-22.04
timeout-minutes: 10
needs: setup
if: ${{ needs.setup.outputs.RUN_SCRIPTS == 'true' }}
steps:
- uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
with:
type: minimal
- name: Check script linting
run: yarn scripts:lint
- name: Test scripts
run: yarn scripts:test
- name: Lint custom eslint plugin
run: yarn cli format javascript eslint
- name: Test custom eslint plugin
run: yarn workspace eslint-plugin-automation-custom test
specs:
runs-on: ubuntu-22.04
timeout-minutes: 10
needs: setup
steps:
- uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
with:
type: minimal
- name: Building specs
run: yarn cli build specs ${{ fromJSON(needs.setup.outputs.SPECS_MATRIX).toRun }}
- name: Store bundled specs
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: specs
path: ${{ fromJSON(needs.setup.outputs.SPECS_MATRIX).bundledPath }}
client_gen_javascript:
timeout-minutes: 15
runs-on: ubuntu-22.04
needs:
- setup
- specs
- scripts
if: |
always() &&
needs.setup.outputs.RUN_GEN_JAVASCRIPT == 'true' &&
!contains(needs.*.result, 'cancelled') &&
!contains(needs.*.result, 'failure')
env:
ALGOLIA_APPLICATION_ID: ${{ secrets.ALGOLIA_APPLICATION_ID }}
ALGOLIA_ADMIN_KEY: ${{ secrets.ALGOLIA_ADMIN_KEY }}
MONITORING_API_KEY: ${{ secrets.MONITORING_API_KEY }}
METIS_APPLICATION_ID: ${{ secrets.METIS_APPLICATION_ID }}
METIS_API_KEY: ${{ secrets.METIS_API_KEY }}
name: client javascript${{ needs.setup.outputs.RUN_GEN_JAVASCRIPT == 'true' && format('@{0}', fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).version) || '' }}
steps:
- uses: actions/checkout@v4
- name: Download specs artifacts
uses: ./scripts/ci/actions/restore-artifacts
with:
type: specs
- name: Remove generated clients
if: ${{ startsWith(github.head_ref, 'chore/prepare-release-') }}
run: |
cd clients/algoliasearch-client-javascript/packages
find . -mindepth 1 -maxdepth 1 ! -name 'requester-*' ! -name 'logger-*' ! -name 'client-common' -type d -exec rm -rf {}/src {}/model {}/dist {}/builds \;
- name: Setup
uses: ./.github/actions/setup
with:
language: javascript
version: ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).version }}
- name: Generate clients
run: yarn cli generate javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }}
- name: Update `yarn.lock` for JavaScript
run: cd clients/algoliasearch-client-javascript && YARN_ENABLE_HARDENED_MODE=0 YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install
- name: Build clients
run: ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).buildCommand }}
- name: Build the playground
run: yarn cli build playground javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }}
- name: Run common and requester tests
run: cd clients/algoliasearch-client-javascript && yarn test ${{ !contains(fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun, 'algoliasearch') && '--ignore algoliasearch' || '' }}
- name: Test JavaScript bundle size
if: ${{ startsWith(github.head_ref, 'chore/prepare-release-') }}
run: cd clients/algoliasearch-client-javascript && yarn test:size
- name: Test JavaScript bundle and types
if: ${{ startsWith(github.head_ref, 'chore/prepare-release-') }}
run: cd clients/algoliasearch-client-javascript && yarn test:bundle
- name: Remove previous CTS output
run: rm -rf ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).testsToDelete }}
- name: Generate CTS
run: yarn cli cts generate javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }}
# JavaScript test deps (needs to be cached because they are huge and inefficient)
- name: Get yarn js test cache directory path
shell: bash
id: yarn-cache-dir-tests
run: echo "dir=$(cd tests/output/javascript && yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- name: Restore Yarn js tests
uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache-dir-tests.outputs.dir || 'tests/output/javascript/.yarn/cache' }}
key: yarn-cache-tests-${{ hashFiles('tests/output/javascript/yarn.lock') }}
- name: Cache js tests node modules
uses: actions/cache@v4
with:
path: tests/output/javascript/node_modules
key: node-modules-tests-${{ hashFiles('tests/output/javascript/yarn.lock') }}
- name: Run unit CTS
run: yarn cli cts run javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }} --no-e2e
- name: Run e2e CTS
id: cts-e2e
continue-on-error: true
if: ${{ !github.event.pull_request.head.repo.fork && !contains(format('{0} {1}', github.event.pull_request.title, github.event.head_commit.message), '[skip-e2e]') }}
run: yarn cli cts run javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }} --no-client --no-requests
- name: Retry e2e CTS
if: ${{ steps.cts-e2e.outcome == 'failure' }}
run: yarn cli cts run javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }} --no-client --no-requests
- name: Run benchmarks
run: yarn cli cts run javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }} --benchmark --no-client --no-requests --no-e2e
- name: Generate code snippets
run: yarn cli snippets javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }}
- name: Build the snippets to check validity
run: yarn cli build snippets javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }}
- name: Generate code guides
run: yarn cli guides javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }}
- name: Build the guides to check validity
run: yarn cli build guides javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }}
- name: Zip artifact before storing
run: zip -r -y clients-javascript.zip clients/algoliasearch-client-javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).testsToStore }} ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).guidesToStore }} -x "**/node_modules**" "**/.yarn/cache/**" "**/.yarn/install-state.gz" "**/build/**" "**/dist/**" "**/.gradle/**" "**/bin/**" "**/.nx/**"
- name: Store javascript clients
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: clients-javascript
path: clients-javascript.zip
client_gen:
timeout-minutes: 15
runs-on: ubuntu-22.04
needs:
- setup
- specs
- scripts
if: |
always() &&
needs.setup.outputs.RUN_GEN == 'true' &&
!contains(needs.*.result, 'cancelled') &&
!contains(needs.*.result, 'failure')
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.setup.outputs.GEN_MATRIX) }}
env:
ALGOLIA_APPLICATION_ID: ${{ secrets.ALGOLIA_APPLICATION_ID }}
ALGOLIA_ADMIN_KEY: ${{ secrets.ALGOLIA_ADMIN_KEY }}
MONITORING_API_KEY: ${{ secrets.MONITORING_API_KEY }}
name: client ${{ matrix.client.language }}@${{ matrix.client.version }}
steps:
- uses: actions/checkout@v4
- name: Download specs artifacts
uses: ./scripts/ci/actions/restore-artifacts
with:
type: specs
- name: Setup
uses: ./.github/actions/setup
with:
language: ${{ matrix.client.language }}
version: ${{ matrix.client.version }}
- name: Generate clients
run: yarn cli generate ${{ matrix.client.language }} ${{ matrix.client.toRun }}
- name: Update composer.lock
if: ${{ matrix.client.language == 'php' && startsWith(github.head_ref, 'chore/renovateBaseBranch') && matrix.client.isMainVersion }}
run: cd ${{ matrix.client.path }} && composer update
- name: Check for file duplicates in Swift
if: ${{ matrix.client.language == 'swift' && matrix.client.isMainVersion }}
run: |
set -eo pipefail
cd clients/algoliasearch-client-swift
find Sources -type f | rev | cut -d '/' -f1 | rev | sort | uniq -d
[ $(find Sources -type f | rev | cut -d '/' -f1 | rev | sort | uniq -d | wc -l) -gt 0 ] && echo "Duplicates found" && exit 1 || echo "No duplicate found"
- name: Build clients
run: ${{ matrix.client.buildCommand }}
- name: Build the playground
run: yarn cli build playground ${{ matrix.client.language }}
- name: Run Java 'algoliasearch' public API validation
if: ${{ github.base_ref == 'main' && matrix.client.language == 'java' && matrix.client.isMainVersion && !contains(format('{0} {1}', github.event.pull_request.title, github.event.head_commit.message), '[skip-bc]') }}
run: |
cd ${{ matrix.client.path }}
exit_code=0
./gradlew :api:japicmp || exit_code=$?
FILE=./api/build/reports/japi.txt
if [[ -f "$FILE" ]]; then
cat $FILE
fi
exit $exit_code
- name: Remove previous CTS output
run: rm -rf ${{ matrix.client.testsToDelete }} || true
- name: Generate CTS
run: yarn cli cts generate ${{ matrix.client.language }} ${{ matrix.client.toRun }} --language-version ${{ matrix.client.version }}
- name: Run unit CTS
run: yarn cli cts run ${{ matrix.client.language }} ${{ matrix.client.toRun }} --no-e2e
- name: Run e2e CTS
id: cts-e2e
continue-on-error: true
if: ${{ !github.event.pull_request.head.repo.fork && !contains(format('{0} {1}', github.event.pull_request.title, github.event.head_commit.message), '[skip-e2e]') }}
run: yarn cli cts run ${{ matrix.client.language }} ${{ matrix.client.toRun }} --no-client --no-requests
- name: Retry e2e CTS
if: ${{ steps.cts-e2e.outcome == 'failure' }}
run: yarn cli cts run ${{ matrix.client.language }} ${{ matrix.client.toRun }} --no-client --no-requests
- name: Run benchmarks
if: ${{ matrix.client.isMainVersion }}
run: yarn cli cts run ${{ matrix.client.language }} ${{ matrix.client.toRun }} --benchmark --no-client --no-requests --no-e2e
- name: Generate code snippets
run: yarn cli snippets ${{ matrix.client.language }} ${{ matrix.client.toRun }}
- name: Build the snippets to check validity
run: yarn cli build snippets ${{ matrix.client.language }}
- name: Generate code guides
run: yarn cli guides ${{ matrix.client.language }} ${{ matrix.client.toRun }}
- name: Build the guides to check validity
run: yarn cli build guides ${{ matrix.client.language }}
- name: Zip artifact before storing
if: ${{ matrix.client.isMainVersion }}
run: zip -r -y clients-${{ matrix.client.language }}.zip ${{ matrix.client.path }} ${{ matrix.client.testsToStore }} ${{ matrix.client.guidesToStore }} -x "**/node_modules**" "**/__pycache__/**" "**/.yarn/cache/**" "**/build/**" "**/.build/**" "**/dist/**" "**/.gradle/**" "**/bin/**" "**/vendor/**" "**/target/**" "**/.dart_tool/**"
- name: Store ${{ matrix.client.language }} clients
if: ${{ matrix.client.isMainVersion }}
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: clients-${{matrix.client.language }}
path: clients-${{matrix.client.language }}.zip
kotlin_build_macos:
timeout-minutes: 15
runs-on: macos-latest
needs:
- setup
- client_gen
if: |
always() &&
needs.setup.outputs.RUN_GEN == 'true' &&
needs.setup.outputs.RUN_MACOS_KOTLIN_BUILD == 'true' &&
!contains(needs.*.result, 'cancelled') &&
!contains(needs.*.result, 'failure')
outputs:
success: ${{ steps.setoutput.outputs.success }}
name: client kotlin${{ needs.setup.outputs.RUN_MACOS_KOTLIN_BUILD == 'true' && format('@{0}', fromJSON(needs.setup.outputs.KOTLIN_DATA).version) || '' }} macos
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: ./scripts/ci/actions/restore-artifacts
with:
type: languages
languages: |
kotlin
- name: Setup
uses: ./.github/actions/setup
with:
type: minimal
language: kotlin
- name: Build clients for macOS
id: build
continue-on-error: true
run: yarn cli build clients kotlin
- name: Retry build
if: ${{ steps.build.outcome == 'failure' }}
run: yarn cli build clients kotlin
- name: Set output
id: setoutput
run: echo "success=true" >> "$GITHUB_OUTPUT"
swift_cts_macos:
timeout-minutes: 20
runs-on: macos-latest
needs:
- setup
- client_gen
if: |
always() &&
needs.setup.outputs.RUN_GEN == 'true' &&
needs.setup.outputs.RUN_MACOS_SWIFT_CTS == 'true' &&
!contains(needs.*.result, 'cancelled') &&
!contains(needs.*.result, 'failure')
env:
ALGOLIA_APPLICATION_ID: ${{ secrets.ALGOLIA_APPLICATION_ID }}
ALGOLIA_ADMIN_KEY: ${{ secrets.ALGOLIA_ADMIN_KEY }}
MONITORING_API_KEY: ${{ secrets.MONITORING_API_KEY }}
outputs:
success: ${{ steps.setoutput.outputs.success }}
name: client swift${{ needs.setup.outputs.RUN_MACOS_SWIFT_CTS == 'true' && format('@{0}', fromJSON(needs.setup.outputs.SWIFT_DATA).version) || '' }} macos
steps:
- uses: actions/checkout@v4
if: ${{ env.ALGOLIA_APPLICATION_ID != '' }}
- name: Download artifacts
uses: ./scripts/ci/actions/restore-artifacts
if: ${{ env.ALGOLIA_APPLICATION_ID != '' }}
with:
type: languages
languages: |
swift
- name: Setup
uses: ./.github/actions/setup
if: ${{ env.ALGOLIA_APPLICATION_ID != '' }}
with:
type: minimal
language: swift
version: ${{ fromJSON(needs.setup.outputs.SWIFT_DATA).version }}
- name: Run tests on macOS
id: run-test
if: ${{ env.ALGOLIA_APPLICATION_ID != '' }}
continue-on-error: true
run: yarn cli cts run swift ${{ fromJSON(needs.setup.outputs.SWIFT_DATA).toRun }} -v ${{ !contains(format('{0} {1}', github.event.pull_request.title, github.event.head_commit.message), '[skip-e2e]') && '--no-e2e' || '' }}
- name: Retry tests
if: ${{ steps.run-test.outcome == 'failure' }}
run: yarn cli cts run swift ${{ fromJSON(needs.setup.outputs.SWIFT_DATA).toRun }} -v ${{ !contains(format('{0} {1}', github.event.pull_request.title, github.event.head_commit.message), '[skip-e2e]') && '--no-e2e' || '' }}
- name: Set output
id: setoutput
run: echo "success=true" >> "$GITHUB_OUTPUT"
codegen:
runs-on: ubuntu-22.04
timeout-minutes: 15
needs:
- setup
- client_gen
- client_gen_javascript
if: |
always() &&
!contains(needs.*.result, 'cancelled') &&
!contains(needs.*.result, 'failure')
permissions:
pull-requests: write
outputs:
success: ${{ steps.setoutput.outputs.success }}
generatedCommit: ${{ steps.pushGeneratedCode.outputs.GENERATED_COMMIT || github.event.pull_request.head.ref }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.ALGOLIA_BOT_TOKEN != '' && secrets.ALGOLIA_BOT_TOKEN || secrets.GITHUB_TOKEN }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Download all artifacts
uses: ./scripts/ci/actions/restore-artifacts
with:
type: all
- name: Setup
uses: ./.github/actions/setup
with:
type: minimal
- name: Generate documentation specs with code snippets
run: yarn cli build specs ${{ fromJSON(needs.setup.outputs.SPECS_MATRIX).toRun }} --docs
- name: Read benchmark results
id: benchmark
run: |
if [[ $(find tests/output -name benchmarkResult.json | wc -l) -eq 0 ]]; then
echo "No benchmark results found"
exit 0
fi
# merge all benchmark results into a single json, and remove the files
results=$(jq -s 'add' -c tests/output/**/benchmarkResult.json)
{
echo 'BENCHMARK_SECTION<<EOF'
echo "<details>"
echo "<summary>📊 Benchmark results</summary>"
echo "" # empty line is required to make the table work
echo "Benchmarks performed on the `search` method using a mock server, the results might not reflect the real-world performance."
# format the json to a markdown table with column "Language" and "rate"
echo "| Language | Req/s |"
echo "| :------- | ----: |"
echo "$results" | jq -r 'to_entries | map([.key, .value.rate]) | sort_by(.[1]) | reverse | .[] | @tsv' | awk -F'\t' '{printf "| %-10s | %10d |\n", $1, $2}'
echo "</details>"
echo 'EOF'
} >> "$GITHUB_OUTPUT"
rm -rf tests/output/**/benchmarkResult.json
- name: Push generated code
id: pushGeneratedCode
run: yarn workspace scripts pushGeneratedCode
env:
GITHUB_TOKEN: ${{ secrets.ALGOLIA_BOT_TOKEN != '' && secrets.ALGOLIA_BOT_TOKEN || secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
- name: update generation comment
uses: marocchino/sticky-pull-request-comment@v2
if: ${{ steps.pushGeneratedCode.outputs.GENERATED_COMMIT == '' }}
with:
GITHUB_TOKEN: ${{ secrets.ALGOLIA_BOT_TOKEN != '' && secrets.ALGOLIA_BOT_TOKEN || secrets.GITHUB_TOKEN }}
message: |
### No code generated
_If you believe code should've been generated, please, [report the issue](https://github.com/algolia/api-clients-automation/issues/new?assignees=&labels=bug%2Ctriage&projects=&template=Bug_report.yml&title=%5Bbug%5D%3A+)._
${{ steps.benchmark.outputs.BENCHMARK_SECTION }}
- name: update generation comment
uses: marocchino/sticky-pull-request-comment@v2
if: ${{ steps.pushGeneratedCode.outputs.GENERATED_COMMIT != '' }}
with:
GITHUB_TOKEN: ${{ secrets.ALGOLIA_BOT_TOKEN != '' && secrets.ALGOLIA_BOT_TOKEN || secrets.GITHUB_TOKEN }}
message: |
### ✔️ Code generated!
| Name | Link |
|---------------------------------|------------------------|
| 🪓 Triggered by | [`${{ github.sha }}`](${{ github.event.pull_request.base.repo.html_url }}/commit/${{ github.sha }}) |
| 🍃 Generated commit | [`${{ steps.pushGeneratedCode.outputs.GENERATED_COMMIT }}`](${{ github.event.pull_request.base.repo.html_url }}/commit/${{ steps.pushGeneratedCode.outputs.GENERATED_COMMIT }}) |
| 🌲 Generated branch | [`generated/${{ github.head_ref }}`](${{ github.event.pull_request.base.repo.html_url }}/tree/generated/${{ github.head_ref }}) |
${{ steps.benchmark.outputs.BENCHMARK_SECTION }}
- name: Build website
if: ${{ github.ref == 'refs/heads/main' || github.base_ref == 'main' && needs.setup.outputs.RUN_WEBSITE == 'true' }}
run: yarn website:build
- name: Deploy documentation
if: ${{ github.ref == 'refs/heads/main' || github.base_ref == 'main' && needs.setup.outputs.RUN_WEBSITE == 'true' }}
uses: nwtgck/[email protected]
with:
publish-dir: 'website/build'
production-branch: main
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: 'Deploy from GitHub Actions'
enable-pull-request-comment: true
enable-commit-comment: true
overwrites-pull-request-comment: true
netlify-config-path: ./netlify.toml
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 5
- name: Set output
id: setoutput
run: echo "success=true" >> "$GITHUB_OUTPUT"
check_green:
runs-on: ubuntu-22.04
timeout-minutes: 10
needs:
- codegen
- swift_cts_macos
- kotlin_build_macos
if: always()
steps:
- run: |
if [[ ("${{ needs.codegen.outputs.success }}" != "true") || ("${{ needs.swift_cts_macos.result }}" != "skipped" && "${{ needs.swift_cts_macos.outputs.success }}" != "true") || ("${{ needs.kotlin_build_macos.result }}" != "skipped" && "${{ needs.kotlin_build_macos.outputs.success }}" != "true")]]; then
echo "a needed step failed"
exit 1
fi
push_and_release:
runs-on: ubuntu-22.04
timeout-minutes: 30
needs:
- codegen
- check_green
if: |
always() &&
!contains(needs.*.result, 'cancelled') &&
!contains(needs.*.result, 'failure') &&
github.ref == 'refs/heads/main'
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ needs.codegen.outputs.generatedCommit }}
token: ${{ secrets.ALGOLIA_BOT_TOKEN }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Setup
uses: ./.github/actions/setup
with:
type: minimal
- name: Spread generation to each repository
id: spreadGeneration
run: yarn workspace scripts spreadGeneration
env:
GITHUB_TOKEN: ${{ secrets.ALGOLIA_BOT_TOKEN }}
- name: Wait for all release CI
run: yarn workspace scripts waitForAllReleases ${{ steps.spreadGeneration.outputs.PUSHED_LANGUAGES }}
env:
GITHUB_TOKEN: ${{ secrets.ALGOLIA_BOT_TOKEN }}
- name: Create GitHub release
run: yarn workspace scripts createGitHubReleases ${{ steps.spreadGeneration.outputs.PUSHED_LANGUAGES }}
env:
GITHUB_TOKEN: ${{ secrets.ALGOLIA_BOT_TOKEN }}
- name: Push generated files to repositories
run: yarn workspace scripts pushToRepository
env:
GITHUB_TOKEN: ${{ secrets.ALGOLIA_BOT_TOKEN }}