forked from appsmithorg/appsmith
-
Notifications
You must be signed in to change notification settings - Fork 0
1030 lines (913 loc) · 41.6 KB
/
TestReuseActions.yml
File metadata and controls
1030 lines (913 loc) · 41.6 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
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
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
name: Test Reuse Actions
on:
# This line enables manual triggering of this workflow.
workflow_dispatch:
# trigger for pushes to release and master
# push:
# branches: [release, release-frozen, master]
# paths:
# - "app/client/**"
# - "app/server/**"
# - "app/rts/**"
# - "!app/client/cypress/manual_TestSuite/**"
jobs:
buildClient:
# If the build has been triggered manually via workflow_dispatch or via a push to protected branches
# then we don't check for the PR approved state
if: |
github.event_name == 'workflow_dispatch' ||
github.event_name == 'push' ||
(github.event_name == 'pull_request_review' &&
github.event.review.state == 'approved' &&
github.event.pull_request.head.repo.full_name == github.repository)
runs-on: ubuntu-latest
defaults:
run:
working-directory: app/client
shell: bash
steps:
- name: Checkout the head commit of the branch
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Figure out the PR number
run: echo ${{ github.event.pull_request.number }}
# Timestamp will be used to create cache key
- id: timestamp
run: echo "::set-output name=timestamp::$(timestamp +'%Y-%m-%dT%H:%M:%S')"
# In case this is second attempt try restoring status of the prior attempt from cache
- name: Restore the previous run result
uses: actions/cache@v2
with:
path: |
~/run_result
key: ${{ github.run_id }}-${{ github.job }}-${{ steps.timestamp.outputs.timestamp }}
restore-keys: |
${{ github.run_id }}-${{ github.job }}-
# Fetch prior run result
- name: Get the previous run result
id: run_result
run: cat ~/run_result 2>/dev/null || echo 'default'
#- uses: actions/checkout@v2
# if: steps.run_result.outputs.run_result != 'success'
# Incase of prior failure run the job
- if: steps.run_result.outputs.run_result != 'success'
run: echo "I'm alive!" && exit 0
# Set status = success
- run: echo "::set-output name=run_result::success" > ~/run_result
- name: Checkout the merged commit from PR and base branch
if: github.event_name == 'pull_request_review'
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: refs/pull/${{ github.event.pull_request.number }}/merge
- name: Use Node.js 14.15.4
if: steps.run_result.outputs.run_result != 'success'
uses: actions/setup-node@v1
with:
node-version: "14.15.4"
- name: Get yarn cache directory path
if: steps.run_result.outputs.run_result != 'success'
id: yarn-dep-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
# Retrieve npm dependencies from cache. After a successful run, these dependencies are cached again
- name: Cache npm dependencies
if: steps.run_result.outputs.run_result != 'success'
id: yarn-dep-cache
uses: actions/cache@v2
env:
cache-name: cache-yarn-dependencies
with:
path: |
${{ steps.yarn-dep-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-dep-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-dep-
# Install all the dependencies
- name: Install dependencies
if: steps.run_result.outputs.run_result != 'success'
run: yarn install
- name: Set the build environment based on the branch
if: steps.run_result.outputs.run_result != 'success'
id: vars
run: |
echo "::set-output name=REACT_APP_ENVIRONMENT::DEVELOPMENT"
if [[ "${{github.ref}}" == "refs/heads/master" ]]; then
echo "::set-output name=REACT_APP_ENVIRONMENT::PRODUCTION"
fi
if [[ "${{github.ref}}" == "refs/heads/release" ]]; then
echo "::set-output name=REACT_APP_ENVIRONMENT::STAGING"
fi
# Since this is an unreleased build, we set the version to incremented version number with
# a `-SNAPSHOT` suffix.
latest_released_version="$(git tag --list 'v*' --sort=-version:refname | head -1)"
echo "latest_released_version = $latest_released_version"
next_version="$(echo "$latest_released_version" | awk -F. -v OFS=. '{ $NF++; print }')"
echo "next_version = $next_version"
echo ::set-output name=version::$next_version-SNAPSHOT
# We burn React environment & the Segment analytics key into the build itself.
# This is to ensure that we don't need to configure it in each installation
- name: Create the bundle
if: steps.run_result.outputs.run_result != 'success'
run: |
if [[ $GITHUB_REF == "refs/heads/release" ]]; then
REACT_APP_SEGMENT_CE_KEY=${{ secrets.APPSMITH_SEGMENT_CE_KEY_RELEASE }}
else
REACT_APP_SEGMENT_CE_KEY=${{ secrets.APPSMITH_SEGMENT_CE_KEY }}
fi
REACT_APP_ENVIRONMENT=${{steps.vars.outputs.REACT_APP_ENVIRONMENT}} \
REACT_APP_FUSIONCHARTS_LICENSE_KEY=${{ secrets.APPSMITH_FUSIONCHARTS_LICENSE_KEY }} \
REACT_APP_SEGMENT_CE_KEY="$REACT_APP_SEGMENT_CE_KEY" \
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }} \
REACT_APP_VERSION_ID=${{ steps.vars.outputs.version }} \
REACT_APP_VERSION_RELEASE_DATE=$(date -u '+%Y-%m-%dT%H:%M:%SZ') \
REACT_APP_GOOGLE_ANALYTICS_ID=${{ secrets.GOOGLE_TAG_MANAGER_ID }} \
REACT_APP_INTERCOM_APP_ID=${{ secrets.APPSMITH_INTERCOM_ID }} \
yarn build
ls -l build
# Restore the previous built bundle if present. If not push the newly built into the cache
- name: Restore the previous bundle
uses: actions/cache@v2
with:
path: |
app/client/build/
key: ${{ github.run_id }}-${{ github.job }}-${{ steps.timestamp.outputs.timestamp }}
restore-keys: |
${{ github.run_id }}-${{ github.job }}
# Upload the build artifact so that it can be used by the test & deploy job in the workflow
- name: Upload react build bundle
uses: actions/upload-artifact@v2
with:
name: client-build
path: app/client/build/
# Set status = success
- run: echo "::set-output name=run_result::success" > ~/run_result
buildServer:
defaults:
run:
working-directory: app/server
runs-on: ubuntu-latest
# Only run this workflow for internally triggered events
if: |
github.event_name == 'workflow_dispatch' ||
github.event_name == 'push' ||
(github.event_name == 'pull_request_review' &&
github.event.review.state == 'approved' &&
github.event.pull_request.head.repo.full_name == github.repository)
# Service containers to run with this job. Required for running tests
services:
# Label used to access the service container
redis:
# Docker Hub image for Redis
image: redis
ports:
# Opens tcp port 6379 on the host and service container
- 6379:6379
mongo:
image: mongo
ports:
- 27017:27017
steps:
# Checkout the code
- uses: actions/checkout@v2
with:
fetch-depth: 0
# Timestamp will be used to create cache key
- id: timestamp
run: echo "::set-output name=timestamp::$(timestamp +'%Y-%m-%dT%H:%M:%S')"
# In case this is second attempt try restoring status of the prior attempt from cache
- name: Restore the previous run result
uses: actions/cache@v2
with:
path: |
~/run_result
key: ${{ github.run_id }}-${{ github.job }}-${{ steps.timestamp.outputs.timestamp }}
restore-keys: |
${{ github.run_id }}-${{ github.job }}-
# Fetch prior run result
- name: Get the previous run result
id: run_result
run: cat ~/run_result 2>/dev/null || echo 'default'
#- uses: actions/checkout@v2
# if: steps.run_result.outputs.run_result != 'success'
# Incase of prior failure run the job
- if: steps.run_result.outputs.run_result != 'success'
run: echo "I'm alive!" && exit 0
# Setup Java
- name: Set up JDK 1.11
if: steps.run_result.outputs.run_result != 'success'
uses: actions/setup-java@v1
with:
java-version: "11.0.10"
# Retrieve maven dependencies from cache. After a successful run, these dependencies are cached again
- name: Cache maven dependencies
if: steps.run_result.outputs.run_result != 'success'
uses: actions/cache@v2
env:
cache-name: cache-maven-dependencies
with:
# maven dependencies are stored in `~/.m2` on Linux/macOS
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
# Here, the GITHUB_REF is of type /refs/head/<branch_name>. We extract branch_name from this by removing the
# first 11 characters. This can be used to build images for several branches
# Since this is an unreleased build, we get the latest released version number, increment the minor number in it,
# append a `-SNAPSHOT` at it's end to prepare the snapshot version number. This is used as the project's version.
- name: Get the version to tag the Docker image
if: steps.run_result.outputs.run_result != 'success'
id: vars
run: |
# Since this is an unreleased build, we set the version to incremented version number with a
# `-SNAPSHOT` suffix.
latest_released_version="$(git tag --list 'v*' --sort=-version:refname | head -1)"
echo "latest_released_version = $latest_released_version"
next_version="$(echo "$latest_released_version" | awk -F. -v OFS=. '{ $NF++; print }')"
echo "next_version = $next_version"
echo ::set-output name=version::$next_version-SNAPSHOT
echo ::set-output name=tag::$(echo ${GITHUB_REF:11})
- name: Test and Build package
if: steps.run_result.outputs.run_result != 'success'
env:
APPSMITH_MONGODB_URI: "mongodb://localhost:27017/mobtools"
APPSMITH_REDIS_URL: "redis://127.0.0.1:6379"
APPSMITH_ENCRYPTION_PASSWORD: "password"
APPSMITH_ENCRYPTION_SALT: "salt"
APPSMITH_IS_SELF_HOSTED: false
APPSMITH_GIT_ROOT: "./container-volumes/git-storage"
working-directory: app/server
run: |
mvn --batch-mode versions:set \
-DnewVersion=${{ steps.vars.outputs.version }} \
-DgenerateBackupPoms=false \
-DprocessAllModules=true
./build.sh -DskipTests
ls -l dist
# Restore the previous built bundle if present. If not push the newly built into the cache
- name: Restore the previous bundle
uses: actions/cache@v2
with:
path: |
app/server/dist/
key: ${{ github.run_id }}-${{ github.job }}-${{ steps.timestamp.outputs.timestamp }}
restore-keys: |
${{ github.run_id }}-${{ github.job }}
# Upload the build artifact so that it can be used by the test & deploy job in the workflow
- name: Upload server build bundle
uses: actions/upload-artifact@v2
with:
name: server-build
path: app/server/dist/
- run: echo "::set-output name=run_result::success" > ~/run_result
buildRts:
defaults:
run:
working-directory: app/rts
runs-on: ubuntu-latest
# Only run this workflow for internally triggered events
if: |
github.event_name == 'workflow_dispatch' ||
github.event_name == 'push' ||
(github.event_name == 'pull_request_review' &&
github.event.review.state == 'approved' &&
github.event.pull_request.head.repo.full_name == github.repository)
steps:
# Checkout the code
- uses: actions/checkout@v2
with:
fetch-depth: 0
# Timestamp will be used to create cache key
- id: timestamp
run: echo "::set-output name=timestamp::$(timestamp +'%Y-%m-%dT%H:%M:%S')"
# In case this is second attempt try restoring status of the prior attempt from cache
- name: Restore the previous run result
uses: actions/cache@v2
with:
path: |
~/run_result
key: ${{ github.run_id }}-${{ github.job }}-${{ steps.timestamp.outputs.timestamp }}
restore-keys: |
${{ github.run_id }}-${{ github.job }}-
# Fetch prior run result
- name: Get the previous run result
id: run_result
run: cat ~/run_result 2>/dev/null || echo 'default'
#- uses: actions/checkout@v2
# if: steps.run_result.outputs.run_result != 'success'
- if: steps.run_result.outputs.run_result != 'success'
run: echo "I'm alive!" && exit 0
- name: Use Node.js 14.15.4
if: steps.run_result.outputs.run_result != 'success'
uses: actions/setup-node@v1
with:
node-version: "14.15.4"
# Here, the GITHUB_REF is of type /refs/head/<branch_name>. We extract branch_name from this by removing the
# first 11 characters. This can be used to build images for several branches
# Since this is an unreleased build, we get the latest released version number, increment the minor number in it,
# append a `-SNAPSHOT` at it's end to prepare the snapshot version number. This is used as the project's version.
- name: Get the version to tag the Docker image
if: steps.run_result.outputs.run_result != 'success'
id: vars
run: |
# Since this is an unreleased build, we set the version to incremented version number with a
# `-SNAPSHOT` suffix.
latest_released_version="$(git tag --list 'v*' --sort=-version:refname | head -1)"
echo "latest_released_version = $latest_released_version"
next_version="$(echo "$latest_released_version" | awk -F. -v OFS=. '{ $NF++; print }')"
echo "next_version = $next_version"
echo ::set-output name=version::$next_version-SNAPSHOT
echo ::set-output name=tag::$(echo ${GITHUB_REF:11})
- name: Build
if: steps.run_result.outputs.run_result != 'success'
run: |
echo 'export const VERSION = "${{ steps.vars.outputs.version }}"' > src/version.js
./build.sh
ls -l dist
# Restore the previous built bundle if present. If not push the newly built into the cache
- name: Restore the previous bundle
uses: actions/cache@v2
with:
path: |
app/rts/dist/
key: ${{ github.run_id }}-${{ github.job }}-${{ steps.timestamp.outputs.timestamp }}
restore-keys: |
${{ github.run_id }}-${{ github.job }}
# Restore the previous built bundle if present. If not push the newly built into the cache
- name: Restore the previous bundle
uses: actions/cache@v2
with:
path: |
app/rts/node_modules/
key: ${{ github.run_id }}-${{ github.job }}-${{ steps.timestamp.outputs.timestamp }}
restore-keys: |
${{ github.run_id }}-${{ github.job }}
# Upload the build artifact so that it can be used by the test & deploy job in the workflow
- name: Upload server build bundle
uses: actions/upload-artifact@v2
with:
name: rts-build
path: app/rts/dist/
- name: Upload RTS dependencies bundle
uses: actions/upload-artifact@v2
with:
name: rts-build-deps
path: app/rts/node_modules/
- run: echo "::set-output name=run_result::success" > ~/run_result
ui-test:
needs: [buildClient, buildServer, buildRts]
# Only run if the build step is successful
# If the build has been triggered manually via workflow_dispatch or via a push to protected branches
# then we don't check for the PR approved state
if: |
success() &&
(github.event_name == 'workflow_dispatch' ||
github.event_name == 'push' ||
(github.event_name == 'pull_request_review' &&
github.event.review.state == 'approved' &&
github.event.pull_request.head.repo.full_name == github.repository))
runs-on: ubuntu-latest
defaults:
run:
working-directory: app/client
shell: bash
strategy:
fail-fast: false
matrix:
job: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]
# Service containers to run with this job. Required for running tests
services:
# Label used to access the service container
redis:
# Docker Hub image for Redis
image: redis
ports:
# Opens tcp port 6379 on the host and service container
- 6379:6379
mongo:
image: mongo
ports:
- 27017:27017
steps:
# Checkout the code
- name: Checkout the merged commit from PR and base branch
if: github.event_name == 'pull_request_review'
uses: actions/checkout@v2
with:
ref: refs/pull/${{ github.event.pull_request.number }}/merge
- name: Checkout the head commit of the branch
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
uses: actions/checkout@v2
# Timestamp will be used to create cache key
- id: timestamp
run: echo "::set-output name=timestamp::$(timestamp +'%Y-%m-%dT%H:%M:%S')"
# In case this is second attempt try restoring status of the prior attempt from cache
- name: Restore the previous run result
uses: martijnhols/actions-cache@v3
with:
path: |
~/run_result
key: ${{ github.run_id }}-${{ github.job }}-${{ steps.timestamp.outputs.timestamp }}-${{ matrix.job }}
restore-keys: |
${{ github.run_id }}-${{ github.job }}-${{ matrix.job }}
# Fetch prior run result
- name: Get the previous run result
id: run_result
run: cat ~/run_result 2>/dev/null || echo 'default'
# In case this is second attempt try restoring failed tests
- name: Restore the previous failed combine result
if: steps.run_result.outputs.run_result == 'failedtest'
uses: martijnhols/actions-cache/restore@v3
with:
path: |
~/combined_failed_spec
key: ${{ github.run_id }}-"ui-test-result"-${{ steps.timestamp.outputs.timestamp }}
restore-keys: |
${{ github.run_id }}-${{ github.job }}
# failed_spec_env will contain list of all failed specs
# We are using evnironment variable instead of regular to support multiline
- name: Get failed_spec
if: steps.run_result.outputs.run_result == 'failedtest'
run: |
failed_spec_env=$(cat ~/combined_failed_spec)
echo "failed_spec_env<<EOF" >> $GITHUB_ENV
echo "$failed_spec_env" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
#- uses: actions/checkout@v2
# if: steps.run_result.outputs.run_result != 'success'
- if: steps.run_result.outputs.run_result != 'success'
run: echo "Starting full run" && exit 0
- if: steps.run_result.outputs.run_result == 'failedtest'
run: echo "Rerunning failed tests" && exit 0
- name: cat run_result
run: echo ${{ steps.run_result.outputs.run_resultc }}
# Setup Java
- name: Set up JDK 1.11
if: steps.run_result.outputs.run_result != 'success'
uses: actions/setup-java@v1
with:
java-version: "11.0.10"
- name: Download the server build artifact
if: steps.run_result.outputs.run_result != 'success'
uses: actions/download-artifact@v2
with:
name: server-build
path: app/server/dist
# Retrieve maven dependencies from cache. After a successful run, these dependencies are cached again
- name: Cache maven dependencies
if: steps.run_result.outputs.run_result != 'success'
uses: actions/cache@v2
env:
cache-name: cache-maven-dependencies
with:
# maven dependencies are stored in `~/.m2` on Linux/macOS
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
# Here, the GITHUB_REF is of type /refs/head/<branch_name>. We extract branch_name from this by removing the
# first 11 characters. This can be used to build images for several branches
# Since this is an unreleased build, we get the latest released version number, increment the minor number in it,
# append a `-SNAPSHOT` at it's end to prepare the snapshot version number. This is used as the project's version.
- name: Get the version to tag the Docker image
if: steps.run_result.outputs.run_result != 'success'
id: vars
run: |
# Since this is an unreleased build, we set the version to incremented version number with a
# `-SNAPSHOT` suffix.
latest_released_version="$(git tag --list 'v*' --sort=-version:refname | head -1)"
echo "latest_released_version = $latest_released_version"
next_version="$(echo "$latest_released_version" | awk -F. -v OFS=. '{ $NF++; print }')"
echo "next_version = $next_version"
echo ::set-output name=version::$next_version-SNAPSHOT
echo ::set-output name=tag::$(echo ${GITHUB_REF:11})
# Start server
- name: Start server
if: steps.run_result.outputs.run_result != 'success'
working-directory: app/server
env:
APPSMITH_MONGODB_URI: "mongodb://localhost:27017/mobtools"
APPSMITH_REDIS_URL: "redis://127.0.0.1:6379"
APPSMITH_ENCRYPTION_PASSWORD: "password"
APPSMITH_ENCRYPTION_SALT: "salt"
APPSMITH_IS_SELF_HOSTED: false
APPSMITH_CLOUD_SERVICES_BASE_URL: "https://release-cs.appsmith.com"
APPSMITH_CLOUD_SERVICES_USERNAME: ""
APPSMITH_CLOUD_SERVICES_PASSWORD: ""
APPSMITH_GIT_ROOT: "./container-volumes/git-storage"
run: |
ls -l
ls -l scripts/
ls -l dist/
# Run the server in the background and redirect logs to a log file
./scripts/start-dev-server.sh &> server-logs.log &
- name: Wait for 30s and check if server is running
if: steps.run_result.outputs.run_result != 'success'
run: |
sleep 30s
if lsof -i :8080; then
echo "Server Found"
else
echo "Server Not Started. Printing logs from server process"
cat app/server/nohup.out
exit 1
fi
- name: Use Node.js 14.15.4
if: steps.run_result.outputs.run_result != 'success'
uses: actions/setup-node@v1
with:
node-version: "14.15.4"
- name: Get yarn cache directory path
if: steps.run_result.outputs.run_result != 'success'
id: yarn-dep-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
# Retrieve npm dependencies from cache. After a successful run, these dependencies are cached again
- name: Cache npm dependencies
if: steps.run_result.outputs.run_result != 'success'
id: yarn-dep-cache
uses: actions/cache@v2
env:
cache-name: cache-yarn-dependencies
with:
path: |
${{ steps.yarn-dep-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-dep-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-dep-
# Install all the dependencies
- name: Install dependencies
if: steps.run_result.outputs.run_result != 'success'
run: yarn install
- name: Download the react build artifact
if: steps.run_result.outputs.run_result != 'success'
uses: actions/download-artifact@v2
with:
name: client-build
path: app/client/build
- name: Installing Yarn serve
if: steps.run_result.outputs.run_result != 'success'
run: |
yarn global add serve
echo "$(yarn global bin)" >> $GITHUB_PATH
- name: Setting up the cypress tests
if: steps.run_result.outputs.run_result != 'success'
shell: bash
env:
APPSMITH_SSL_CERTIFICATE: ${{ secrets.APPSMITH_SSL_CERTIFICATE }}
APPSMITH_SSL_KEY: ${{ secrets.APPSMITH_SSL_KEY }}
CYPRESS_URL: ${{ secrets.CYPRESS_URL }}
CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }}
CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }}
CYPRESS_TESTUSERNAME1: ${{ secrets.CYPRESS_TESTUSERNAME1 }}
CYPRESS_TESTPASSWORD1: ${{ secrets.CYPRESS_TESTPASSWORD1 }}
CYPRESS_TESTUSERNAME2: ${{ secrets.CYPRESS_TESTUSERNAME2 }}
CYPRESS_TESTPASSWORD2: ${{ secrets.CYPRESS_TESTPASSWORD1 }}
CYPRESS_S3_ACCESS_KEY: ${{ secrets.CYPRESS_S3_ACCESS_KEY }}
CYPRESS_S3_SECRET_KEY: ${{ secrets.CYPRESS_S3_SECRET_KEY }}
APPSMITH_DISABLE_TELEMETRY: true
APPSMITH_GOOGLE_MAPS_API_KEY: ${{ secrets.APPSMITH_GOOGLE_MAPS_API_KEY }}
POSTGRES_PASSWORD: postgres
run: |
./cypress/setup-test.sh
# Onyl ru the below step if its a frist attempt
- name: Run the cypress test
if: steps.run_result.outputs.run_result != 'success' && steps.run_result.outputs.run_result != 'failedtest'
uses: cypress-io/github-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }}
CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }}
CYPRESS_TESTUSERNAME1: ${{ secrets.CYPRESS_TESTUSERNAME1 }}
CYPRESS_TESTPASSWORD1: ${{ secrets.CYPRESS_TESTPASSWORD1 }}
CYPRESS_TESTUSERNAME2: ${{ secrets.CYPRESS_TESTUSERNAME2 }}
CYPRESS_TESTPASSWORD2: ${{ secrets.CYPRESS_TESTPASSWORD1 }}
CYPRESS_S3_ACCESS_KEY: ${{ secrets.CYPRESS_S3_ACCESS_KEY }}
CYPRESS_S3_SECRET_KEY: ${{ secrets.CYPRESS_S3_SECRET_KEY }}
APPSMITH_DISABLE_TELEMETRY: true
APPSMITH_GOOGLE_MAPS_API_KEY: ${{ secrets.APPSMITH_GOOGLE_MAPS_API_KEY }}
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}
with:
browser: chrome
headless: true
record: true
install: false
parallel: true
group: "Electrons on Github Action"
spec: "cypress/integration/Smoke_TestSuite/**/*"
working-directory: app/client
# tag will be either "push" or "pull_request"
tag: ${{ github.event_name }}
env: "NODE_ENV=development"
# Incase of second attemtp only run failed specs
- name: Run the cypress test with failed tests
if: steps.run_result.outputs.run_result == 'failedtest'
uses: cypress-io/github-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }}
CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }}
CYPRESS_TESTUSERNAME1: ${{ secrets.CYPRESS_TESTUSERNAME1 }}
CYPRESS_TESTPASSWORD1: ${{ secrets.CYPRESS_TESTPASSWORD1 }}
CYPRESS_TESTUSERNAME2: ${{ secrets.CYPRESS_TESTUSERNAME2 }}
CYPRESS_TESTPASSWORD2: ${{ secrets.CYPRESS_TESTPASSWORD1 }}
CYPRESS_S3_ACCESS_KEY: ${{ secrets.CYPRESS_S3_ACCESS_KEY }}
CYPRESS_S3_SECRET_KEY: ${{ secrets.CYPRESS_S3_SECRET_KEY }}
APPSMITH_DISABLE_TELEMETRY: true
APPSMITH_GOOGLE_MAPS_API_KEY: ${{ secrets.APPSMITH_GOOGLE_MAPS_API_KEY }}
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}
with:
browser: chrome
headless: true
record: true
install: false
parallel: true
group: "Electrons on Github Action"
spec: ${{ env.failed_spec_env }}
working-directory: app/client
# tag will be either "push" or "pull_request"
tag: ${{ github.event_name }}
env: "NODE_ENV=development"
# Set status = failedtest
- name: Set fail if there are test failures
if: failure()
run: echo "::set-output name=run_result::failedtest" > ~/run_result
# Create a directory ~/failed_spec and add a dummy file
# This will ensure upload and download steps are successfull
- name: Create direcotrs for failed tests
if: always()
run: |
mkdir -p ~/failed_spec
echo "empty" >> ~/failed_spec/dummy-${{ matrix.job }}
# add list failed tests to a file
- name: Incase of test failures copy them to a file
if: failure()
run: |
cd ${{ github.workspace }}/app/client/cypress/
find screenshots -type d|grep spec |sed 's/screenshots/cypress\/integration/g' > ~/failed_spec/failed_spec-${{ matrix.job }}
# Upload failed test list using common path for all matrix job
- name: Upload failed test list artifact
if: always()
uses: actions/upload-artifact@v2
with:
name: failed-spec
path: ~/failed_spec
# Force store previous run result to cache
- name: Store the previous run result
if: failure()
uses: martijnhols/actions-cache/save@v3
with:
path: |
~/run_result
key: ${{ github.run_id }}-${{ github.job }}-${{ steps.timestamp.outputs.timestamp }}-${{ matrix.job }}
restore-keys: |
${{ github.run_id }}-${{ github.job }}-${{ matrix.job }}
# Force store previous failed test list to cache
- name: Store the previous failed test result
if: failure()
uses: martijnhols/actions-cache/save@v3
with:
path: |
~/failed_spec
key: ${{ github.run_id }}-${{ github.job }}-${{ steps.timestamp.outputs.timestamp }}-${{ matrix.job }}
restore-keys: |
${{ github.run_id }}-${{ github.job }}-${{ matrix.job }}
# Upload the screenshots as artifacts if there's a failure
- uses: actions/upload-artifact@v1
if: failure()
with:
name: cypress-screenshots-${{ matrix.job }}
path: app/client/cypress/screenshots/
- name: Restore the previous bundle
uses: actions/cache@v2
with:
path: |
app/client/cypress/snapshots/
key: ${{ github.run_id }}-${{ github.job }}-${{ steps.timestamp.outputs.timestamp }}-${{ matrix.job }}
restore-keys: |
${{ github.run_id }}-${{ github.job }}-${{ matrix.job }}
# Upload the snapshots as artifacts for layout validation
- uses: actions/upload-artifact@v1
with:
name: cypress-snapshots-visualRegression
path: app/client/cypress/snapshots/
# Upload the log artifact so that it can be used by the test & deploy job in the workflow
- name: Upload server logs bundle on failure
uses: actions/upload-artifact@v2
if: failure()
with:
name: server-logs-${{ matrix.job }}
path: app/server/server-logs.log
# Set status = success
- run: echo "::set-output name=run_result::success" > ~/run_result
ui-test-result:
needs: ui-test
if: always() &&
(github.event_name == 'workflow_dispatch' ||
github.event_name == 'push' ||
(github.event_name == 'pull_request_review' &&
github.event.review.state == 'approved' &&
github.event.pull_request.head.repo.full_name == github.repository))
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- run: echo "All ui-test matrices completed"
# Download failed_spec list for all jobs
- uses: actions/download-artifact@v2
if: needs.ui-test.result
id: download
with:
name: failed-spec
path: ~/failed_spec
# Incase for any uti-test job failure, create combined failed spec
- name: "combine all specs"
if: needs.ui-test.result != 'success'
run: cat ~/failed_spec/failed_spec* >> ~/combined_failed_spec
# Force save the failed spec list into a cache
- name: Store the combined run result
if: needs.ui-test.result
uses: martijnhols/actions-cache/save@v3
with:
path: |
~/combined_failed_spec
key: ${{ github.run_id }}-"ui-test-result"-${{ steps.timestamp.outputs.timestamp }}
restore-keys: |
${{ github.run_id }}-${{ github.job }}
# Upload combined failed spec list to a file
# This is done for debugging.
- name: upload combined failed spec
if: needs.ui-test.result
uses: actions/upload-artifact@v2
with:
name: combined_failed_spec
path: ~/combined_failed_spec
- name: Return status for ui-matrix
run: |
if [[ "${{ needs.ui-test.result }}" == "success" ]]; then
echo "Integration tests completed successfully!";
exit 0;
elif [[ "${{ needs.ui-test.result }}" == "skipped" ]]; then
echo "Integration tests were skipped";
exit 1;
else
echo "Integration tests have failed";
exit 1;
fi
package:
needs: ui-test
runs-on: ubuntu-latest
# Run this job irrespective of tests failing, if this is the release branch; or only if the tests pass, if this is the master branch.
if: (success() && github.ref == 'refs/heads/master') ||
( always() &&
(
github.event_name == 'workflow_dispatch' ||
github.event_name == 'push' ||
(
github.event_name == 'pull_request_review' &&
github.event.review.state == 'approved' &&
github.event.pull_request.head.repo.full_name == github.repository
)
) &&
github.ref == 'refs/heads/release'
)
steps:
# Checkout the code
- name: Checkout the merged commit from PR and base branch
if: github.event_name == 'pull_request_review'
uses: actions/checkout@v2
with:
ref: refs/pull/${{ github.event.pull_request.number }}/merge
- name: Checkout the head commit of the branch
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
uses: actions/checkout@v2
- name: Download the react build artifact
uses: actions/download-artifact@v2
with:
name: client-build
path: app/client/build
- name: Download the server build artifact
uses: actions/download-artifact@v2
with:
name: server-build
path: app/server/dist
- name: Download the rts build artifact
uses: actions/download-artifact@v2
with:
name: rts-build
path: app/rts/dist
- name: Download the rts build artifact
uses: actions/download-artifact@v2
with:
name: rts-build-deps
path: app/rts/node_modules/
# Here, the GITHUB_REF is of type /refs/head/<branch_name>. We extract branch_name from this by removing the
# first 11 characters. This can be used to build images for several branches
- name: Get the version to tag the Docker image
id: vars
run: echo ::set-output name=tag::$(echo ${GITHUB_REF:11})
- name: Set up QEMU (needed for docker buildx)
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
# Build release Docker image and push to Docker Hub
# Commenting push
#- name: Push client release image to Docker Hub
# if: success() && github.ref == 'refs/heads/release' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
# working-directory: app/client
# run: |
# docker build -t ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-editor:${{steps.vars.outputs.tag}} .
# docker push ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-editor:${{steps.vars.outputs.tag}}
# Build master Docker image and push to Docker Hub
#- name: Push client master image to Docker Hub with commit tag
# if: success() && github.ref == 'refs/heads/master' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
# working-directory: app/client
# run: |
# docker build -t ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-editor:${GITHUB_SHA} .
# docker build -t ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-editor:nightly .
# docker push ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-editor:${GITHUB_SHA}
# docker push ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-editor:nightly
#- name: Build and push release image to Docker Hub
# if: success() && github.ref == 'refs/heads/release' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
# working-directory: "."
# run: |
# tag_args="--tag ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-ce:${{steps.vars.outputs.tag}}"
# docker buildx build \
# --platform linux/arm64,linux/amd64 \
# --push \
# --build-arg APPSMITH_SEGMENT_CE_KEY=${{ secrets.APPSMITH_SEGMENT_CE_KEY_RELEASE }} \
# $tag_args \
# .
#- name: Build and push master image to Docker Hub with commit tag
# if: success() && github.ref == 'refs/heads/master' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
# working-directory: "."
# run: |
# tag_args="--tag ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-ce:${GITHUB_SHA}"
# tag_args="$tag_args --tag ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-ce:nightly"
# docker buildx build \
# --platform linux/arm64,linux/amd64 \
# --push \
# --build-arg APPSMITH_SEGMENT_CE_KEY=${{ secrets.APPSMITH_SEGMENT_CE_KEY }} \
# $tag_args \
# .
# - name: Check and push fat image to Docker Hub with commit tag
# if: success() && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/release') && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
# working-directory: "."
# run: |
# if [[ "${{ github.ref }}" == "refs/heads/master" ]]; then
# tag=nightly
# else
# tag="${{ steps.vars.outputs.tag }}"
# fi
# docker run --detach --publish 80:80 --name appsmith \
# "${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-ce:$tag"
# sleep 180
# cd deploy/docker
# if bash run-test.sh; then
# echo "Fat container test passed. Pushing image."
# docker push --all-tags ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-ce
# else
# echo "Fat container test FAILED. Not pushing image."
# # Temporarily pushing even if test fails.
# docker push --all-tags ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-ce
# fi
# Build release Docker image and push to Docker Hub
#- name: Push server release image to Docker Hub
# if: success() && github.ref == 'refs/heads/release'
# working-directory: app/server
# run: |