-
Notifications
You must be signed in to change notification settings - Fork 1
768 lines (750 loc) · 22 KB
/
pull-request.yaml
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
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
name: Pull Request
on:
pull_request
# A note on debugging a github step:
# You can ssh into the github action environment and poke around by using
# https://github.com/marketplace/actions/debugging-with-tmate
# Use `limit-access-to-actor: true` so only you can ssh into the environment!
#
# For example, to debug a failure, append this to the jobs list within the failing step
# - name: Setup tmate session
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3
# with:
# limit-access-to-actor: true
#
# build docker image: actions/upload-artifact@v3, with path: /bin
# - build UX
# - validate codebase
# - test UX unit tests
# - agent tests
# - build agent
# - UX e2e tests
jobs:
build-docker-image:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Setup Buildx
uses: docker/setup-buildx-action@v2
-
name: Restore Cache docker image
id: cache-docker-image-restore
uses: actions/cache/restore@v3
env:
cache-name: cache-docker-image
with:
path: /tmp/build-image.tar
key: ${{ runner.os }}-docker-image-${{ env.cache-name }}-${{ hashFiles('build/package/Dockerfile') }}
-
if: ${{ steps.cache-docker-image-restore.outputs.cache-hit != 'true' }}
name: Build and Export Docker Image
uses: docker/build-push-action@v3
with:
context: .
build-args: BUILDKIT_INLINE_CACHE=1
pull: True
file: build/package/Dockerfile
tags: rstudio/connect-client:latest
outputs: type=docker,dest=/tmp/build-image.tar
-
if: ${{ steps.cache-docker-image-restore.outputs.cache-hit != 'true' }}
name: Cache docker image (update)
id: cache-docker-image-save
uses: actions/cache/save@v3
env:
cache-name: cache-docker-image
with:
path: /tmp/build-image.tar
key: ${{ runner.os }}-docker-image-${{ env.cache-name }}-${{ hashFiles('build/package/Dockerfile') }}
build-ux:
needs: build-docker-image
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Setup Just
uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Cache docker image (restore)
id: cache-docker-image
uses: actions/cache/restore@v3
env:
cache-name: cache-docker-image
with:
path: /tmp/build-image.tar
key: ${{ runner.os }}-docker-image-${{ env.cache-name }}-${{ hashFiles('/tmp/build-image.tar') }}
-
name: Load Docker Image
run: |
docker load --input /tmp/build-image.tar
-
name: Restore Cache UX node_modules
id: node_modules
uses: actions/cache/restore@v3
env:
cache-name: node-modules
with:
path: ./web/node_modules
key: ${{ runner.os }}-node-modules-${{ env.cache-name }}-${{ hashFiles('./web/package.json') }}
-
if: ${{ steps.node_modules.outputs.cache-hit != 'true' }}
name: Build up node_modules
run: |
just web/bootstrap
-
if: ${{ steps.node_modules.outputs.cache-hit != 'true' }}
name: Create the cache of UX node_modules (save)
id: create_node_modules
uses: actions/cache/save@v3
env:
cache-name: node-modules
with:
path: ./web/node_modules
key: ${{ runner.os }}-node-modules-${{ env.cache-name }}-${{ hashFiles('./web/package.json') }}
-
name: Build the UX
run: |
just build-web
-
name: Upload Web-UX Artifacts
uses: actions/upload-artifact@v3
with:
name: web-ux
path: ./web/dist
validate-codebase:
needs: build-ux
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Setup Just
uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Restore Cache docker image
id: cache-docker-image
uses: actions/cache/restore@v3
env:
cache-name: cache-docker-image
with:
path: /tmp/build-image.tar
key: ${{ runner.os }}-docker-image-${{ env.cache-name }}-${{ hashFiles('/tmp/build-image.tar') }}
-
name: Load Docker Image
run: |
docker load --input /tmp/build-image.tar
-
name: Download Web-UX Artifacts
uses: actions/download-artifact@v3
with:
name: web-ux
path: ./web/dist
-
name: Restore Cache UX node_modules
id: node_modules
uses: actions/cache/restore@v3
env:
cache-name: node-modules
with:
path: ./web/node_modules
key: ${{ runner.os }}-node-modules-${{ env.cache-name }}-${{ hashFiles('./web/package.json') }}
-
name: Validate the codebase
# Docker run will only fail step if last command fails... so must do multiple commands as one.
run: |
just validate
test-ux:
needs: build-ux
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Setup Just
uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Restore Cache docker image
id: cache-docker-image
uses: actions/cache/restore@v3
env:
cache-name: cache-docker-image
with:
path: /tmp/build-image.tar
key: ${{ runner.os }}-docker-image-${{ env.cache-name }}-${{ hashFiles('/tmp/build-image.tar') }}
-
name: Load Docker Image
run: |
docker load --input /tmp/build-image.tar
-
name: Restore Cache UX node_modules
id: node_modules
uses: actions/cache/restore@v3
env:
cache-name: node-modules
with:
path: ./web/node_modules
key: ${{ runner.os }}-node-modules-${{ env.cache-name }}-${{ hashFiles('./web/package.json') }}
-
name: Download Web-UX Artifacts
uses: actions/download-artifact@v3
with:
name: web-ux
path: ./web/dist
-
name: UX Unit Tests
run: |
just web/test-unit
-
name: UX Go Race Tests
run: |
just web/test-race
agent-tests:
needs: build-ux
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Setup Just
uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Restore Cache docker image
id: cache-docker-image
uses: actions/cache/restore@v3
env:
cache-name: cache-docker-image
with:
path: /tmp/build-image.tar
key: ${{ runner.os }}-docker-image-${{ env.cache-name }}-${{ hashFiles('/tmp/build-image.tar') }}
-
name: Load Docker Image
run: |
docker load --input /tmp/build-image.tar
-
name: Download Web-UX SPA Artifacts
uses: actions/download-artifact@v3
with:
name: web-ux
path: ./web/dist
-
name: Agent Unit Tests
run: |
just test-agent
build-agent:
needs: build-ux
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Setup Just
uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Restore Cache docker image
id: cache-docker-image
uses: actions/cache/restore@v3
env:
cache-name: cache-docker-image
with:
path: /tmp/build-image.tar
key: ${{ runner.os }}-docker-image-${{ env.cache-name }}-${{ hashFiles('/tmp/build-image.tar') }}
-
name: Load Docker Image
run: |
docker load --input /tmp/build-image.tar
-
name: Download Web-UX SPA Artifacts
uses: actions/download-artifact@v3
with:
name: web-ux
path: ./web/dist
-
name: Build agent
run: |
just build-agent
-
name: Make agents executable
run: |
sudo chmod -R +x ./bin/**/connect-client
-
name: Agent build artifacts
uses: actions/upload-artifact@v3
with:
name: agent-artifacts
path: bin/
ux-e2e-tests:
needs: build-agent
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Setup Just
uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Restore Cache docker image
id: cache-docker-image
uses: actions/cache/restore@v3
env:
cache-name: cache-docker-image
with:
path: /tmp/build-image.tar
key: ${{ runner.os }}-docker-image-${{ env.cache-name }}-${{ hashFiles('/tmp/build-image.tar') }}
-
name: Load Docker Image
run: |
docker load --input /tmp/build-image.tar
-
name: Download built agents
uses: actions/download-artifact@v3
with:
name: agent-artifacts
path: ./bin
-
name: Make agents executable
run: |
chmod -R +x ./bin/**/connect-client
-
name: Restore Cache UX node_modules
id: node_modules
uses: actions/cache/restore@v3
env:
cache-name: node-modules
with:
path: ./web/node_modules
key: ${{ runner.os }}-node-modules-${{ env.cache-name }}-${{ hashFiles('./web/package.json') }}
-
name: UX E2E Tests
run: |
PATH="${PATH}:/usr/local/bin" just web/test-e2e
start-connect:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: python
uses: actions/setup-python@v4
with:
python-version: 3.11
-
name: run Connect in fuzzbucket
env:
FUZZBUCKET_SSH_KEY: ${{ secrets.FUZZBUCKET_SSH_KEY }}
FUZZBUCKET_URL: ${{ secrets.FUZZBUCKET_URL }}
FUZZBUCKET_CREDENTIALS: ${{ secrets.FUZZBUCKET_CREDENTIALS }}
run: |
pip install -r ./test/setup/requirements.txt
echo "${FUZZBUCKET_SSH_KEY}" > .fuzzbucket-ssh-key
chmod 600 .fuzzbucket-ssh-key
export SSH_OPTIONS="-i.fuzzbucket-ssh-key"
export CONNECT_IP="$(python ./test/setup/connect-setup.py)"
echo ${CONNECT_IP} > connect_ip.txt
-
name: Upload connect_ip file
uses: actions/upload-artifact@v3
with:
name: connect_ip
path: connect_ip.txt
test-windows:
needs: build-agent
runs-on: windows-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Setup Just
uses: extractions/setup-just@v1
-
name: Download binary
uses: actions/download-artifact@v3
with:
name: agent-artifacts
path: bin/
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
name: Make agents executable
run: |
chmod -R +x ./bin/**/connect-client
-
name: Run Windows CLI Tests
env:
os: windows-latest
# bats reads the load libraries from relative path only in Windows
BATS_SUPPORT_LIB: ..\..\libs\bats-support\load.bash
BATS_ASSERT_LIB: ..\..\libs\bats-assert\load
# WARNING: Docker run will only fail step if last command fails...
run: |
just test/bats-install
$env:Path += ";$env:GITHUB_WORKSPACE\test\libs\bats-core\bin"
$env:BINARY_PATH = "$env:GITHUB_WORKSPACE\bin\windows-amd64\connect-client"
cd $env:GITHUB_WORKSPACE\test
just run-client $env:os
-
name: Download connect_ip
uses: actions/download-artifact@v3
with:
name: connect_ip
-
name: Run Windows Cypress Tests
env:
os: windows-latest
DOCKER: "false"
FUZZBUCKET_SSH_KEY: ${{ secrets.FUZZBUCKET_SSH_KEY }}
FUZZBUCKET_URL: ${{ secrets.FUZZBUCKET_URL }}
FUZZBUCKET_CREDENTIALS: ${{ secrets.FUZZBUCKET_CREDENTIALS }}
run: |
set CONNECT_IP="$(cat connect_ip.txt)"
just test/publishing-tests $env:os
test-macos:
needs: build-agent
runs-on: macos-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: python
uses: actions/setup-python@v4
with:
python-version: 3.11
-
name: Setup Just
uses: extractions/setup-just@v1
-
name: Download binary
uses: actions/download-artifact@v3
with:
name: agent-artifacts
path: bin/
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
name: Make agents executable
run: |
chmod -R +x ./bin/**/connect-client
-
name: Run MacOs CLI Tests
env:
os: macos-latest
BATS_SUPPORT_LIB: ${{ github.workspace }}/test/libs/bats-support/load
BATS_ASSERT_LIB: ${{ github.workspace }}/test/libs/bats-assert/load
BINARY_PATH: ${{ github.workspace }}/bin/darwin-amd64/connect-client
# WARNING Docker run will only fail step if last command fails...
run: |
just test/bats-install
PATH="$PATH:${{ github.workspace }}/test/libs/bats-core/bin"
cd ${{ github.workspace }}/test
just run-client ${os}
-
name: Download connect_ip
uses: actions/download-artifact@v3
with:
name: connect_ip
-
name: Run MacOS Cypress Tests
env:
os: macos-latest
DOCKER: "false"
run: |
export CONNECT_IP="$(cat connect_ip.txt)"
just test/publishing-tests ${os}
build-linux-amd64:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
needs: build-agent
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Download artifacts
uses: actions/download-artifact@v3
with:
path: bin/
# these are required to run docker on amd64 and arm64 platforms
-
name: Setup qemu
uses: docker/setup-qemu-action@v2
-
name: Setup buildx
uses: docker/setup-buildx-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
name: Restore Cached linux-amd64 image
id: cache-linux-amd64-restore
uses: actions/cache/restore@v3
with:
path: /tmp/linux-amd64-image.tar
key: ${{ env.cache-name }}-${{ hashFiles('test/docker/Dockerfile') }}
env:
cache-name: cache-linux-amd64-image
os: linux-amd64
-
if: ${{ steps.cache-linux-amd64-restore.outputs.cache-hit != 'true' }}
name: Build and Export Docker Image
uses: docker/build-push-action@v3
with:
context: .
build-args: |
BUILDKIT_INLINE_CACHE=1
platform=linux-amd64
pull: True
file: test/docker/Dockerfile
platforms: linux/amd64
tags: rstudio/connect-client-linux-amd64:latest
outputs: type=docker,dest=/tmp/linux-amd64-image.tar
-
if: ${{ steps.cache-linux-amd64-restore.outputs.cache-hit != 'true' }}
name: Cache docker image (update)
id: cache-linux-amd64-image-save
uses: actions/cache/save@v3
env:
cache-name: cache-linux-amd64-image
with:
path: /tmp/linux-amd64-image.tar
key: ${{ env.cache-name }}-${{ hashFiles('test/docker/Dockerfile') }}
test-linux-amd64:
needs: build-linux-amd64
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Setup Just
uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
name: Get binary
uses: actions/download-artifact@v3
with:
name: agent-artifacts
path: bin/
-
name: Make agents executable
run: |
chmod -R +x ./bin/**/connect-client
-
name: Cache docker image (restore)
id: cache-linux-amd64-image
uses: actions/cache/restore@v3
env:
cache-name: cache-linux-amd64-image
with:
path: /tmp/linux-amd64-image.tar
key: ${{ env.cache-name }}-${{ hashFiles('test/docker/Dockerfile') }}
-
name: Load Docker Image
run: |
docker load --input /tmp/linux-amd64-image.tar
-
name: Run linux-amd64 CLI Tests
env:
os: linux-amd64
run: |
just test/run-client ${os}
-
name: Download connect_ip
uses: actions/download-artifact@v3
with:
name: connect_ip
-
name: Run linux-amd64 Cypress Tests
env:
os: linux-amd64
DOCKER: "false"
run: |
export CONNECT_IP="$(cat connect_ip.txt)"
just test/ui-client ${os}
build-linux-arm64:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
needs: build-agent
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Download artifacts
uses: actions/download-artifact@v3
with:
path: bin/
# these are required to run docker on amd64 and arm64 platforms
-
name: Setup qemu
uses: docker/setup-qemu-action@v2
-
name: Setup buildx
uses: docker/setup-buildx-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
name: Restore Cached linux-arm64 image
id: cache-linux-arm64-restore
uses: actions/cache/restore@v3
with:
path: /tmp/linux-arm64-image.tar
key: ${{ env.cache-name }}-${{ hashFiles('test/docker/Dockerfile') }}
env:
cache-name: cache-linux-arm64-image
os: linux-arm64
-
if: ${{ steps.cache-linux-arm64-restore.outputs.cache-hit != 'true' }}
name: Build and Export Docker Image
uses: docker/build-push-action@v3
with:
context: .
build-args: |
BUILDKIT_INLINE_CACHE=1
platform=linux-arm64
pull: True
file: test/docker/Dockerfile
platforms: linux/arm64
tags: rstudio/connect-client-linux-arm64:latest
outputs: type=docker,dest=/tmp/linux-arm64-image.tar
-
if: ${{ steps.cache-linux-arm64-restore.outputs.cache-hit != 'true' }}
name: Cache docker image (update)
id: cache-linux-arm64-image-save
uses: actions/cache/save@v3
env:
cache-name: cache-linux-arm64-image
with:
path: /tmp/linux-arm64-image.tar
key: ${{ env.cache-name }}-${{ hashFiles('test/docker/Dockerfile') }}
test-linux-arm64:
needs: build-linux-arm64
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Setup Just
uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
name: Get binary
uses: actions/download-artifact@v3
with:
name: agent-artifacts
path: bin/
-
name: Make agents executable
run: |
chmod -R +x ./bin/**/connect-client
# these are required to run docker on amd64 and arm64 platforms
-
name: Setup qemu
uses: docker/setup-qemu-action@v2
-
name: Setup buildx
uses: docker/setup-buildx-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
name: Cache docker image (restore)
id: cache-linux-arm64-image
uses: actions/cache/restore@v3
env:
cache-name: cache-linux-arm64-image
with:
path: /tmp/linux-arm64-image.tar
key: ${{ env.cache-name }}-${{ hashFiles('test/docker/Dockerfile') }}
-
name: Load Docker Image
run: |
docker load --input /tmp/linux-arm64-image.tar
-
name: Download connect_ip
uses: actions/download-artifact@v3
with:
name: connect_ip
-
name: Run linux-arm64 CLI Tests
env:
os: linux-arm64
run: |
just test/run-client ${os}
# -
# name: Run linux-arm64 Cypress Tests
# env:
# os: linux-arm64
# DOCKER: "false"
# run: |
# export CONNECT_IP="$(cat connect_ip.txt)"
# just test/ui-client ${os}
teardown-connect:
runs-on: ubuntu-latest
needs: [test-linux-arm64, test-linux-amd64, test-windows, test-macos]
if: always()
steps:
-
name: python
uses: actions/setup-python@v4
with:
python-version: 3.11
-
name: Teardown Fuzzbucket
env:
FUZZBUCKET_SSH_KEY: ${{ secrets.FUZZBUCKET_SSH_KEY }}
FUZZBUCKET_URL: ${{ secrets.FUZZBUCKET_URL }}
FUZZBUCKET_CREDENTIALS: ${{ secrets.FUZZBUCKET_CREDENTIALS }}
run: |
pip install fuzzbucket-client
fuzzbucket-client rm connect-ci