forked from baserow/baserow
-
Notifications
You must be signed in to change notification settings - Fork 0
1393 lines (1266 loc) · 48.9 KB
/
ci.yml
File metadata and controls
1393 lines (1266 loc) · 48.9 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: CI Pipeline
on:
push:
branches:
- develop
- master
pull_request:
workflow_dispatch:
inputs:
clear_cache:
description: "Clear Docker build cache before building"
required: false
default: false
type: boolean
# Customize the workflow run name to show branch/PR info
run-name: "CI: ${{ github.event_name == 'pull_request' && github.event.pull_request.title || github.ref_name }}${{ inputs.clear_cache && ' (cache cleared)' || '' }}"
# Automatically cancel in-progress workflows for the same branch/PR
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
IMAGE_REPO: ${{ github.repository }}
CI_IMAGE_TAG_PREFIX: ci-
DEVELOP_BRANCH_NAME: develop
REAL_GITHUB_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
jobs:
check-build-and-publish:
name: Check build and publish
runs-on: ubuntu-latest
outputs:
should_build_and_publish: ${{ steps.setflag.outputs.should_build_and_publish }}
should_trigger_saas: ${{ steps.setflag.outputs.should_trigger_saas }}
steps:
- id: setflag
shell: bash
run: |
if [[ -n "${{ secrets.RELEASE_DOCKER_REPOSITORY }}" && \
-n "${{ secrets.RELEASE_DOCKER_REGISTRY }}" && \
-n "${{ secrets.RELEASE_DOCKER_USERNAME }}" && \
-n "${{ secrets.RELEASE_DOCKER_PASSWORD }}" ]]; then
echo "should_build_and_publish=true" >> "$GITHUB_OUTPUT"
else
echo "should_build_and_publish=false" >> "$GITHUB_OUTPUT"
fi
if [[ -n "${{ secrets.GITLAB_SAAS_PAT }}" ]]; then
echo "should_trigger_saas=true" >> "$GITHUB_OUTPUT"
else
echo "should_trigger_saas=false" >> "$GITHUB_OUTPUT"
fi
# ==========================================================================
# BUILD STAGE - Build Docker images for backend and frontend
# ==========================================================================
build-backend:
name: Build Backend CI Image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
image: ${{ steps.image.outputs.full }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate image tag
id: image
run: |
IMAGE_NAME="${{ env.REGISTRY }}/${{ env.IMAGE_REPO }}/backend_dev"
IMAGE_TAG="${{ env.CI_IMAGE_TAG_PREFIX }}${{ env.REAL_GITHUB_SHA }}"
FULL_IMAGE="${IMAGE_NAME}:${IMAGE_TAG}"
echo "full=${FULL_IMAGE}" >> $GITHUB_OUTPUT
- name: Build and push backend CI image
uses: docker/build-push-action@v5
with:
context: .
file: backend/Dockerfile
target: ci
push: true
tags: ${{ steps.image.outputs.full }}
cache-from: ${{ inputs.clear_cache != true && 'type=gha,scope=backend-ci' || '' }}
cache-to: type=gha,scope=backend-ci,mode=max
labels: |
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.revision=${{ env.REAL_GITHUB_SHA }}
org.opencontainers.image.created=${{ github.event.head_commit.timestamp }}
build-frontend:
name: Build Web-Frontend CI Image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
image: ${{ steps.image.outputs.full }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate image tag
id: image
run: |
IMAGE_NAME="${{ env.REGISTRY }}/${{ env.IMAGE_REPO }}/web-frontend_dev"
IMAGE_TAG="${{ env.CI_IMAGE_TAG_PREFIX }}${{ env.REAL_GITHUB_SHA }}"
FULL_IMAGE="${IMAGE_NAME}:${IMAGE_TAG}"
echo "full=${FULL_IMAGE}" >> $GITHUB_OUTPUT
- name: Build and push web-frontend CI image
uses: docker/build-push-action@v5
with:
context: .
file: web-frontend/Dockerfile
target: ci
push: true
tags: ${{ steps.image.outputs.full }}
cache-from: ${{ inputs.clear_cache != true && 'type=gha,scope=frontend-ci' || '' }}
cache-to: type=gha,scope=frontend-ci,mode=max
labels: |
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.revision=${{ env.REAL_GITHUB_SHA }}
org.opencontainers.image.created=${{ github.event.head_commit.timestamp }}
# ==========================================================================
# LINT STAGE - Run linting on backend, frontend, and Dockerfiles
# ==========================================================================
# Detect which files have changed to skip unnecessary jobs
detect-changes:
name: Detect Changed Files
runs-on: ubuntu-latest
outputs:
backend: ${{ steps.filter.outputs.backend }}
frontend: ${{ steps.filter.outputs.frontend }}
dockerfiles: ${{ steps.filter.outputs.dockerfiles }}
mjml: ${{ steps.filter.outputs.mjml }}
zapier: ${{ steps.filter.outputs.zapier }}
helm: ${{ steps.filter.outputs.helm }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Check changed files
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
backend:
- 'backend/**'
- 'premium/backend/**'
- 'enterprise/backend/**'
- '.github/workflows/ci.yml'
frontend:
- 'web-frontend/**'
- 'premium/web-frontend/**'
- 'enterprise/web-frontend/**'
- '.github/workflows/ci.yml'
dockerfiles:
- '**/Dockerfile'
- '.github/workflows/ci.yml'
mjml:
- '**/*.eta'
- '.github/workflows/ci.yml'
zapier:
- 'integrations/zapier/**'
- '.github/workflows/ci.yml'
helm:
- 'deploy/helm/**'
- '.github/workflows/ci.yml'
- '.github/workflows/trigger-helm-chart-upload.yml'
backend-lint:
name: Backend Lint
runs-on: ubuntu-latest
needs:
- detect-changes
if: needs.detect-changes.outputs.backend == 'true' || github.ref_name == 'develop' || github.ref_name == 'master'
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "0.9.29"
- name: Run ruff
working-directory: backend
run: |
uv run ruff check src/ ../premium/backend/src/ ../enterprise/backend/src/ tests/ ../premium/backend/tests/ ../enterprise/backend/tests/
uv run ruff format --check src/ ../premium/backend/src/ ../enterprise/backend/src/ tests/ ../premium/backend/tests/ ../enterprise/backend/tests/
frontend-lint:
name: Web-Frontend Lint
runs-on: ubuntu-latest
needs:
- build-frontend
- detect-changes
if: needs.detect-changes.outputs.frontend == 'true' || github.ref_name == 'develop' || github.ref_name == 'master'
permissions:
contents: read
packages: read
steps:
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run frontend lint
run: |
docker run --rm \
${{ needs.build-frontend.outputs.image }} lint
dockerfile-lint:
name: Dockerfile Lint (hadolint)
runs-on: ubuntu-latest
needs:
- detect-changes
if: needs.detect-changes.outputs.dockerfiles == 'true' || github.ref_name == 'develop' || github.ref_name == 'master'
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run hadolint on all Dockerfiles
run: |
mkdir -p reports
docker run --rm -i \
-v "$(pwd)":/opt/hadolint \
-w /opt/hadolint \
hadolint/hadolint:2.9.3-debian \
hadolint --ignore DL3008 -f json \
backend/Dockerfile \
web-frontend/Dockerfile \
heroku.Dockerfile \
deploy/*/Dockerfile > reports/hadolint.json || true
- name: Display hadolint results
run: |
if [ -s reports/hadolint.json ]; then
cat reports/hadolint.json
else
echo "No hadolint issues found!"
fi
- name: Upload hadolint results
uses: actions/upload-artifact@v4
if: always()
with:
name: hadolint-results
path: reports/hadolint.json
retention-days: 7
helm-chart-lint:
name: Helm Chart Lint
runs-on: ubuntu-latest
needs:
- detect-changes
if: needs.detect-changes.outputs.helm == 'true' || github.ref_name == 'develop' || github.ref_name == 'master'
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Helm
uses: azure/setup-helm@v4
- name: Lint Helm Chart
run: |
cd deploy/helm
rm -f baserow/Chart.lock
# Add Helm repositories
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo add caddy https://caddyserver.github.io/ingress
# Build dependencies
helm dependency build baserow
# Lint the chart with strict mode
helm lint baserow --strict
# ==========================================================================
# TEST STAGE - Run backend and frontend tests
# ==========================================================================
backend-check-startup:
name: Backend Startup Check
runs-on: ubuntu-latest
needs:
- build-backend
- detect-changes
if: needs.detect-changes.outputs.backend == 'true' || github.ref_name == 'develop' || github.ref_name == 'master'
permissions:
contents: read
packages: read
services:
db:
image: pgvector/pgvector:pg14
env:
POSTGRES_USER: baserow
POSTGRES_PASSWORD: baserow
POSTGRES_DB: baserow
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--tmpfs /var/lib/postgresql/data:rw,noexec,nosuid,size=4g
--shm-size=512m
steps:
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Check backend startup
run: |
docker run --rm --network="${{ job.services.db.network }}" \
-e DATABASE_HOST=db \
-e DATABASE_PORT=5432 \
-e DATABASE_NAME=baserow \
-e DATABASE_USER=baserow \
-e DATABASE_PASSWORD=baserow \
${{ needs.build-backend.outputs.image }} ci-check-startup
docker run --rm --network="${{ job.services.db.network }}" \
-e DATABASE_HOST=db \
-e DATABASE_PORT=5432 \
-e DATABASE_NAME=baserow \
-e DATABASE_USER=baserow \
-e DATABASE_PASSWORD=baserow \
${{ needs.build-backend.outputs.image }} ci-check-startup-oss-only
- name: Check backend migrations
run: |
docker run --rm --network="${{ job.services.db.network }}" \
-e DATABASE_HOST=db \
-e DATABASE_PORT=5432 \
-e DATABASE_NAME=baserow \
-e DATABASE_USER=baserow \
-e DATABASE_PASSWORD=baserow \
${{ needs.build-backend.outputs.image }} ci-check-migrations
test-backend:
name: Backend Tests (Group ${{ matrix.group }})
runs-on: ubuntu-latest
needs:
- build-backend
- backend-lint
- detect-changes
if: needs.detect-changes.outputs.backend == 'true' || github.ref_name == 'develop' || github.ref_name == 'master'
permissions:
contents: read
packages: read
checks: write
pull-requests: write
strategy:
fail-fast: false
matrix:
group: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
services:
db:
image: pgvector/pgvector:pg14
env:
POSTGRES_USER: baserow
POSTGRES_PASSWORD: baserow
POSTGRES_DB: baserow
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--tmpfs /var/lib/postgresql/data:rw,noexec,nosuid,size=4g
--shm-size=512m
steps:
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run backend tests for group ${{ matrix.group }}
run: |
mkdir -p reports
docker run \
--name=baserow_backend_test_container \
--network="${{ job.services.db.network }}" \
-e PYTEST_SPLITS=10 \
-e PYTEST_SPLIT_GROUP=${{ matrix.group }} \
-e DATABASE_HOST=db \
-e DATABASE_PORT=5432 \
-e DATABASE_NAME=baserow \
-e DATABASE_USER=baserow \
-e DATABASE_PASSWORD=baserow \
-e SECRET_KEY=test-secret-key \
${{ needs.build-backend.outputs.image }} ci-test
docker cp baserow_backend_test_container:/baserow/backend/reports/. ./reports
docker rm baserow_backend_test_container
- name: Upload test reports
uses: actions/upload-artifact@v4
if: always()
with:
name: backend-test-reports-group-${{ matrix.group }}
path: reports/
retention-days: 7
include-hidden-files: true
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: reports/report.xml
check_name: Backend Tests (Group ${{ matrix.group }})
comment_mode: off
test-frontend:
name: Web-Frontend Tests (Shard ${{ matrix.shard }})
runs-on: ubuntu-latest
needs:
- build-frontend
- detect-changes
if: needs.detect-changes.outputs.frontend == 'true' || github.ref_name == 'develop' || github.ref_name == 'master'
permissions:
contents: read
packages: read
checks: write
pull-requests: write
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3]
steps:
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run web-frontend tests for shard ${{ matrix.shard }}
env:
CI: "true"
EXTRA_VITEST_PARAMS: --shard=${{ matrix.shard }}/3 --reporter=junit --outputFile=./reports/junit.xml
run: |
mkdir -p reports
set -o pipefail
docker run \
--name=webfrontend_test \
-e EXTRA_VITEST_PARAMS="$EXTRA_VITEST_PARAMS" \
${{ needs.build-frontend.outputs.image }} ci-test | tee reports/stdout.txt
docker cp webfrontend_test:/baserow/web-frontend/reports/junit.xml ./reports
docker rm webfrontend_test
- name: Upload test reports
uses: actions/upload-artifact@v4
if: always()
with:
name: web-frontend-test-reports-shard-${{ matrix.shard }}
path: reports/
retention-days: 7
include-hidden-files: true
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: reports/junit.xml
check_name: Web-Frontend Tests (Shard ${{ matrix.shard }})
comment_mode: off
test-zapier:
name: Zapier Integration Tests
runs-on: ubuntu-latest
needs:
- detect-changes
if: needs.detect-changes.outputs.zapier == 'true' || github.ref_name == 'develop' || github.ref_name == 'master'
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
cache: "yarn"
cache-dependency-path: "integrations/zapier/yarn.lock"
- name: Run Zapier tests
run: |
cd integrations/zapier
yarn install
yarn run zapier test
check-mjml-compiled:
name: Check MJML Email Templates Compiled
runs-on: ubuntu-latest
needs:
- detect-changes
if: needs.detect-changes.outputs.mjml == 'true' || github.ref_name == 'develop' || github.ref_name == 'master'
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
cache: "yarn"
cache-dependency-path: "backend/email_compiler/yarn.lock"
- name: Compile MJML templates
run: |
cd backend/email_compiler
yarn install
yarn run compile
- name: Check for uncompiled changes
run: |
if ! git diff --exit-code; then
echo "Error: Uncompiled changes found to MJML email templates"
echo "Please run the compiler in backend/email_compiler/ and commit the changes"
exit 1
fi
# ==========================================================================
# E2E TESTS - End-to-end tests with Playwright
# ==========================================================================
test-e2e:
name: E2E Tests (Shard ${{ matrix.shard }})
timeout-minutes: 60
runs-on: ubuntu-latest
needs:
- detect-changes
- build-backend
- build-frontend
if: needs.detect-changes.outputs.backend == 'true' || needs.detect-changes.outputs.frontend == 'true' || needs.detect-changes.outputs.dockerfiles == 'true' || github.ref_name == 'develop' || github.ref_name == 'master'
permissions:
contents: read
packages: read
checks: write
pull-requests: write
strategy:
fail-fast: false
matrix:
shard: [1, 2]
services:
db:
image: pgvector/pgvector:pg14
env:
POSTGRES_USER: baserow
POSTGRES_PASSWORD: baserow
POSTGRES_DB: baserow
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--tmpfs /var/lib/postgresql/data:rw,noexec,nosuid,size=4g
--shm-size=512m
redis:
image: redis:6-alpine
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
--tmpfs /data:rw,noexec,nosuid,size=256m
s3mock:
image: adobe/s3mock:3.12.0
env:
initialBuckets: testbucket
ports:
- 9090:9090
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "24"
cache: "yarn"
cache-dependency-path: "e2e-tests/yarn.lock"
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Restore database from dump
run: |
echo "Restoring database from dump to container ${{ job.services.db.id }}..."
# Drop and recreate database
docker exec ${{ job.services.db.id }} psql -U baserow -d postgres -c "DROP DATABASE IF EXISTS baserow;"
docker exec ${{ job.services.db.id }} psql -U baserow -d postgres -c "CREATE DATABASE baserow;"
# Restore from dump (migrations and templates already applied)
docker exec -i ${{ job.services.db.id }} pg_restore -U baserow -d baserow --no-owner --no-acl < e2e-tests/fixtures/e2e-db.dump || true
echo "Database restored successfully!"
- name: Start all services in parallel
run: |
# Start backend
docker run -d --network="${{ job.services.db.network }}" \
--name backend \
-e DATABASE_HOST=db \
-e DATABASE_NAME=baserow \
-e DATABASE_USER=baserow \
-e DATABASE_PASSWORD=baserow \
-e REDIS_URL=redis://redis:6379 \
-e SECRET_KEY=test \
-e AWS_ACCESS_KEY_ID=anyvalue \
-e AWS_SECRET_ACCESS_KEY=anyvalue \
-e AWS_STORAGE_BUCKET_NAME=testbucket \
-e AWS_S3_ENDPOINT_URL=http://s3mock:9090 \
-e AWS_S3_CUSTOM_DOMAIN=localhost:9090/testbucket \
-e AWS_S3_USE_SSL=no \
-e AWS_S3_URL_PROTOCOL=http: \
-e FEATURE_FLAGS="*" \
-e DJANGO_SETTINGS_MODULE=baserow.config.settings.e2e \
-e MIGRATE_ON_STARTUP=true \
-e PRIVATE_BACKEND_URL=http://backend:8000 \
-p 8000:8000 \
${{ needs.build-backend.outputs.image }} gunicorn &
# Start celery worker
docker run -d --network="${{ job.services.db.network }}" \
--name celery \
-e DATABASE_HOST=db \
-e DATABASE_NAME=baserow \
-e DATABASE_USER=baserow \
-e DATABASE_PASSWORD=baserow \
-e REDIS_URL=redis://redis:6379 \
-e SECRET_KEY=test \
-e AWS_ACCESS_KEY_ID=anyvalue \
-e AWS_SECRET_ACCESS_KEY=anyvalue \
-e AWS_STORAGE_BUCKET_NAME=testbucket \
-e AWS_S3_ENDPOINT_URL=http://s3mock:9090 \
-e AWS_S3_CUSTOM_DOMAIN=localhost:9090/testbucket \
-e AWS_S3_USE_SSL=no \
-e AWS_S3_URL_PROTOCOL=http: \
-e FEATURE_FLAGS="*" \
-e DJANGO_SETTINGS_MODULE=baserow.config.settings.e2e \
-e BASEROW_RUN_MINIMAL=yes \
-e BASEROW_AMOUNT_OF_WORKERS=1 \
${{ needs.build-backend.outputs.image }} celery-worker &
# Start web-frontend
docker run -d --network="${{ job.services.db.network }}" \
--name web-frontend \
-e PUBLIC_BACKEND_URL=http://localhost:8000 \
-e PUBLIC_WEB_FRONTEND_URL=http://localhost:3000 \
-e PRIVATE_BACKEND_URL=http://backend:8000 \
-e FEATURE_FLAGS="*" \
-p 3000:3000 \
${{ needs.build-frontend.outputs.image }} nuxt-prod &
# Wait for all docker run commands to complete
wait
echo "All services started"
- name: Install dependencies
run: |
cd e2e-tests
yarn install
- name: Get Playwright version
id: playwright-version
run: echo "version=$(cd e2e-tests && yarn list @playwright/test --depth=0 | grep @playwright/test | sed 's/.*@//')" >> $GITHUB_OUTPUT
- name: Cache Playwright browsers
uses: actions/cache@v4
id: playwright-cache
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}
- name: Install Playwright browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: |
cd e2e-tests
npx playwright install --with-deps firefox
- name: Wait for services
env:
BASEROW_E2E_STARTUP_MAX_WAIT_TIME_SECONDS: 300
PUBLIC_BACKEND_URL: http://localhost:8000
PUBLIC_WEB_FRONTEND_URL: http://localhost:3000
PRIVATE_BACKEND_URL: http://backend:8000
run: |
cd e2e-tests
./wait-for-services.sh
- name: Show container logs on failure
if: failure()
run: |
echo "=== Backend container logs ==="
docker logs backend 2>&1 | tail -500 || true
echo ""
echo "=== Celery container logs ==="
docker logs celery 2>&1 | tail -200 || true
echo ""
echo "=== Web-frontend container logs ==="
docker logs web-frontend 2>&1 | tail -200 || true
echo ""
echo "=== Container status ==="
docker ps -a
- name: Run E2E tests (shard ${{ matrix.shard }})
env:
PUBLIC_BACKEND_URL: http://localhost:8000
PUBLIC_WEB_FRONTEND_URL: http://localhost:3000
PRIVATE_BACKEND_URL: http://backend:8000
CI: 1
run: |
cd e2e-tests
npx playwright test --timeout=30000 --grep-invert=@slow --shard=${{ matrix.shard }}/2 --project=firefox
- name: Upload E2E test results
uses: actions/upload-artifact@v4
if: always()
with:
name: e2e-test-results-shard-${{ matrix.shard }}
path: e2e-tests/blob-report/
retention-days: 7
include-hidden-files: true
- name: Dump container logs on failure
if: failure()
run: |
echo "=== Backend logs ==="
docker logs backend 2>&1 || true
echo ""
echo "=== Celery logs ==="
docker logs celery 2>&1 || true
echo ""
echo "=== Web-frontend logs ==="
docker logs web-frontend 2>&1 || true
- name: Cleanup containers
if: always()
run: |
docker stop backend web-frontend celery || true
docker rm backend web-frontend celery || true
collect-e2e-reports:
name: Collect E2E Test Reports
runs-on: ubuntu-latest
needs: [test-e2e]
permissions:
contents: read
checks: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "24"
- name: Download all E2E test results
uses: actions/download-artifact@v4
with:
pattern: e2e-test-results-shard-*
path: e2e-tests/blob-report
merge-multiple: true
- name: Merge Playwright reports
run: |
cd e2e-tests
yarn install
npx playwright merge-reports --reporter html blob-report/
- name: Upload merged E2E report
uses: actions/upload-artifact@v4
if: always()
with:
name: e2e-test-report-merged
path: e2e-tests/playwright-report/
retention-days: 30
# ==========================================================================
# COVERAGE STAGE - Collect and report test coverage
# ==========================================================================
collect-coverage:
name: Collect Backend Coverage
runs-on: ubuntu-latest
needs: [test-backend]
permissions:
contents: read
pull-requests: write
issues: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.14"
- name: Install coverage tool
run: pip install coverage
- name: Download all backend test reports
uses: actions/download-artifact@v4
with:
pattern: backend-test-reports-group-*
path: reports-download
merge-multiple: true
- name: Combine coverage reports
run: |
echo "Listing downloaded files:"
find reports-download -type f
cp reports-download/.coverage* $GITHUB_WORKSPACE/ 2>/dev/null || echo "No coverage files found"
cd $GITHUB_WORKSPACE
coverage combine || echo "::warning::No coverage data to combine"
coverage report || echo "::warning::No coverage report generated"
ls -la .coverage* || true
- name: Verify .coverage file exists
run: |
if [ ! -f $GITHUB_WORKSPACE/.coverage ]; then
echo "::error::No .coverage file found after combining coverage!"
exit 1
fi
- name: Upload combined coverage report
uses: actions/upload-artifact@v4
with:
name: backend-coverage-report
path: ${{ github.workspace }}/.coverage
include-hidden-files: true
retention-days: 30
overwrite: true
- name: Comment coverage report on PR
if: github.event_name == 'pull_request'
uses: py-cov-action/python-coverage-comment-action@v3.38
continue-on-error: true
with:
GITHUB_TOKEN: ${{ github.token }}
MERGE_COVERAGE_FILES: false
COVERAGE_PATH: ${{ github.workspace }}
# ==========================================================================
# Build and publish stage - builds production grade images and publishes
# ==========================================================================
build-final-backend:
name: Build Final Backend Image
runs-on: ubuntu-latest
if: needs.check-build-and-publish.outputs.should_build_and_publish == 'true' && (github.ref_name == 'develop' || github.ref_name == 'master' || github.event_name == 'workflow_dispatch')
needs:
- test-backend
- test-e2e
- backend-lint
- check-build-and-publish
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push final backend image
uses: docker/build-push-action@v5
with:
context: .
file: backend/Dockerfile
target: prod
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_REPO }}/backend:ci-tested-${{ env.REAL_GITHUB_SHA }}
cache-from: |
type=gha,scope=backend-ci
type=gha,scope=backend-prod
cache-to: type=gha,scope=backend-prod,mode=max
labels: |
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.revision=${{ env.REAL_GITHUB_SHA }}
org.opencontainers.image.title=backend
org.opencontainers.image.created=${{ github.event.head_commit.timestamp }}
build-final-web-frontend:
name: Build Final Web-Frontend Image
runs-on: ubuntu-latest
if: needs.check-build-and-publish.outputs.should_build_and_publish == 'true' && (github.ref_name == 'develop' || github.ref_name == 'master' || github.event_name == 'workflow_dispatch')
needs:
- test-frontend
- frontend-lint
- test-e2e
- check-build-and-publish
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push final web-frontend image
uses: docker/build-push-action@v5
with:
context: .
file: web-frontend/Dockerfile
target: prod
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_REPO }}/web-frontend:ci-tested-${{ env.REAL_GITHUB_SHA }}
cache-from: |
type=gha,scope=frontend-ci
type=gha,scope=frontend-prod
cache-to: type=gha,scope=frontend-prod,mode=max
labels: |
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.revision=${{ env.REAL_GITHUB_SHA }}
org.opencontainers.image.title=web-frontend
org.opencontainers.image.created=${{ github.event.head_commit.timestamp }}
build-final-all-in-one:
name: Build All-in-One Image
runs-on: ubuntu-latest
if: needs.check-build-and-publish.outputs.should_build_and_publish == 'true' && (github.ref_name == 'develop' || github.ref_name == 'master' || github.event_name == 'workflow_dispatch')
needs:
- build-final-backend
- build-final-web-frontend
- check-build-and-publish
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}