-
Notifications
You must be signed in to change notification settings - Fork 409
897 lines (764 loc) · 29.2 KB
/
tests.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
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
name: Tests
on:
push:
branches:
- master
- ci
- "release/*"
pull_request:
branches:
- '**'
schedule:
- cron: "0 */3 * * *"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: false
- uses: actions/checkout@v4
with:
fetch-depth: 50
submodules: true
- name: Set up Python
uses: actions/setup-python@v5
id: setup-python
with:
python-version: '3.12.2'
cache: 'pip'
cache-dependency-path: |
pyproject.toml
# The below is technically a lie as we are technically not
# inside a virtual env, but there is really no reason to bother
# actually creating and activating one as below works just fine.
- name: Export $VIRTUAL_ENV
run: |
venv="$(python -c 'import sys; sys.stdout.write(sys.prefix)')"
echo "VIRTUAL_ENV=${venv}" >> $GITHUB_ENV
- name: Set up uv cache
uses: actions/cache@v4
with:
path: ~/.cache/uv
key: uv-cache-${{ runner.os }}-py-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('pyproject.toml') }}
- name: Cached requirements.txt
uses: actions/cache@v4
id: requirements-cache
with:
path: requirements.txt
key: edb-requirements-${{ hashFiles('pyproject.toml') }}
- name: Compute requirements.txt
if: steps.requirements-cache.outputs.cache-hit != 'true'
run: |
python -m pip install pip-tools
pip-compile --no-strip-extras --all-build-deps \
--extra test,language-server \
--output-file requirements.txt pyproject.toml
- name: Install Python dependencies
run: |
python -c "import sys; print(sys.prefix)"
python -m pip install uv~=0.1.0 && uv pip install -U -r requirements.txt
- name: Compute cache keys and download the running times log
env:
GIST_TOKEN: ${{ secrets.CI_BOT_GIST_TOKEN }}
run: |
mkdir -p shared-artifacts
if [ "$(uname)" = "Darwin" ]; then
find /usr/lib -type f -name 'lib*' -exec stat -f '%N %z' {} + | sort | shasum -a 256 | cut -d ' ' -f1 > shared-artifacts/lib_cache_key.txt
else
find /usr/lib -type f -name 'lib*' -printf '%P %s\n' | sort | sha256sum | cut -d ' ' -f1 > shared-artifacts/lib_cache_key.txt
fi
python setup.py -q ci_helper --type cli > shared-artifacts/edgedbcli_git_rev.txt
python setup.py -q ci_helper --type rust >shared-artifacts/rust_cache_key.txt
python setup.py -q ci_helper --type ext >shared-artifacts/ext_cache_key.txt
python setup.py -q ci_helper --type parsers >shared-artifacts/parsers_cache_key.txt
python setup.py -q ci_helper --type postgres >shared-artifacts/postgres_git_rev.txt
python setup.py -q ci_helper --type libpg_query >shared-artifacts/libpg_query_git_rev.txt
echo 'f8cd94309eaccbfba5dea7835b88c78377608a37' >shared-artifacts/stolon_git_rev.txt
python setup.py -q ci_helper --type bootstrap >shared-artifacts/bootstrap_cache_key.txt
echo EDGEDBCLI_GIT_REV=$(cat shared-artifacts/edgedbcli_git_rev.txt) >> $GITHUB_ENV
echo POSTGRES_GIT_REV=$(cat shared-artifacts/postgres_git_rev.txt) >> $GITHUB_ENV
echo LIBPG_QUERY_GIT_REV=$(cat shared-artifacts/libpg_query_git_rev.txt) >> $GITHUB_ENV
echo STOLON_GIT_REV=$(cat shared-artifacts/stolon_git_rev.txt) >> $GITHUB_ENV
echo BUILD_LIB=$(python setup.py -q ci_helper --type build_lib) >> $GITHUB_ENV
echo BUILD_TEMP=$(python setup.py -q ci_helper --type build_temp) >> $GITHUB_ENV
curl \
-H "Accept: application/vnd.github.v3+json" \
-u edgedb-ci:$GIST_TOKEN \
https://api.github.com/gists/8b722a65397f7c4c0df72f5394efa04c \
| jq '.files."time_stats.csv".raw_url' \
| xargs curl > shared-artifacts/time_stats.csv
- name: Upload shared artifacts
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: shared-artifacts
path: shared-artifacts
retention-days: 1
# Restore binary cache
- name: Handle cached EdgeDB CLI binaries
uses: actions/cache@v4
id: cli-cache
with:
path: build/cli
key: edb-cli-v4-${{ env.EDGEDBCLI_GIT_REV }}
- name: Handle cached Rust extensions
uses: actions/cache@v4
id: rust-cache
with:
path: build/rust_extensions
key: edb-rust-v4-${{ hashFiles('shared-artifacts/rust_cache_key.txt') }}
restore-keys: |
edb-rust-v4-
- name: Handle cached Cython extensions
uses: actions/cache@v4
id: ext-cache
with:
path: build/extensions
key: edb-ext-v6-${{ hashFiles('shared-artifacts/ext_cache_key.txt') }}
- name: Handle cached PostgreSQL build
uses: actions/cache@v4
id: postgres-cache
with:
path: build/postgres/install
key: edb-postgres-v3-${{ env.POSTGRES_GIT_REV }}-${{ hashFiles('shared-artifacts/lib_cache_key.txt') }}
- name: Handle cached Stolon build
uses: actions/cache@v4
id: stolon-cache
with:
path: build/stolon/bin
key: edb-stolon-v2-${{ env.STOLON_GIT_REV }}
- name: Handle cached libpg_query build
uses: actions/cache@v4
id: libpg-query-cache
with:
path: edb/pgsql/parser/libpg_query/libpg_query.a
key: edb-libpg_query-v1-${{ env.LIBPG_QUERY_GIT_REV }}
# Install system dependencies for building
- name: Install system deps
if: |
steps.cli-cache.outputs.cache-hit != 'true' ||
steps.rust-cache.outputs.cache-hit != 'true' ||
steps.ext-cache.outputs.cache-hit != 'true' ||
steps.stolon-cache.outputs.cache-hit != 'true' ||
steps.postgres-cache.outputs.cache-hit != 'true'
run: |
sudo apt-get update
sudo apt-get install -y uuid-dev libreadline-dev bison flex libprotobuf-c-dev
- name: Install Rust toolchain
if: |
steps.cli-cache.outputs.cache-hit != 'true' ||
steps.rust-cache.outputs.cache-hit != 'true'
uses: dsherret/rust-toolchain-file@v1
# Build EdgeDB CLI
- name: Handle EdgeDB CLI build cache
uses: actions/cache@v4
if: steps.cli-cache.outputs.cache-hit != 'true'
with:
path: ${{ env.BUILD_TEMP }}/rust/cli
key: edb-cli-build-v7-${{ env.EDGEDBCLI_GIT_REV }}
restore-keys: |
edb-cli-build-v7-
- name: Build EdgeDB CLI
env:
CARGO_HOME: ${{ env.BUILD_TEMP }}/rust/cli/cargo_home
CACHE_HIT: ${{ steps.cli-cache.outputs.cache-hit }}
run: |
if [[ "$CACHE_HIT" == "true" ]]; then
cp -v build/cli/bin/edgedb edb/cli/edgedb
else
python setup.py -v build_cli
fi
# Build Rust extensions
- name: Handle Rust extensions build cache
uses: actions/cache@v4
if: steps.rust-cache.outputs.cache-hit != 'true'
with:
path: ${{ env.BUILD_TEMP }}/rust/extensions
key: edb-rust-build-v1-${{ hashFiles('shared-artifacts/rust_cache_key.txt') }}
restore-keys: |
edb-rust-build-v1-
- name: Build Rust extensions
env:
CARGO_HOME: ${{ env.BUILD_TEMP }}/rust/extensions/cargo_home
CACHE_HIT: ${{ steps.rust-cache.outputs.cache-hit }}
run: |
if [[ "$CACHE_HIT" != "true" ]]; then
rm -rf ${BUILD_LIB}
mkdir -p build/rust_extensions
rsync -av ./build/rust_extensions/ ${BUILD_LIB}/
python setup.py -v build_rust
rsync -av ${BUILD_LIB}/ build/rust_extensions/
rm -rf ${BUILD_LIB}
fi
rsync -av ./build/rust_extensions/edb/ ./edb/
# Build libpg_query
- name: Build libpg_query
if: |
steps.libpg-query-cache.outputs.cache-hit != 'true' &&
steps.ext-cache.outputs.cache-hit != 'true'
run: |
python setup.py build_libpg_query
# Build extensions
- name: Handle Cython extensions build cache
uses: actions/cache@v4
if: steps.ext-cache.outputs.cache-hit != 'true'
with:
path: ${{ env.BUILD_TEMP }}/edb
key: edb-ext-build-v4-${{ hashFiles('shared-artifacts/ext_cache_key.txt') }}
- name: Build Cython extensions
env:
CACHE_HIT: ${{ steps.ext-cache.outputs.cache-hit }}
BUILD_EXT_MODE: py-only
run: |
if [[ "$CACHE_HIT" != "true" ]]; then
rm -rf ${BUILD_LIB}
mkdir -p ./build/extensions
rsync -av ./build/extensions/ ${BUILD_LIB}/
BUILD_EXT_MODE=py-only python setup.py -v build_ext
rsync -av ${BUILD_LIB}/ ./build/extensions/
rm -rf ${BUILD_LIB}
fi
rsync -av ./build/extensions/edb/ ./edb/
# Build parsers
- name: Handle compiled parsers cache
uses: actions/cache@v4
id: parsers-cache
with:
path: build/lib
key: edb-parsers-v3-${{ hashFiles('shared-artifacts/parsers_cache_key.txt') }}
restore-keys: |
edb-parsers-v3-
- name: Build parsers
env:
CACHE_HIT: ${{ steps.parsers-cache.outputs.cache-hit }}
run: |
if [[ "$CACHE_HIT" != "true" ]]; then
rm -rf ${BUILD_LIB}
mkdir -p ./build/lib
rsync -av ./build/lib/ ${BUILD_LIB}/
python setup.py -v build_parsers
rsync -av ${BUILD_LIB}/ ./build/lib/
rm -rf ${BUILD_LIB}
fi
rsync -av ./build/lib/edb/ ./edb/
# Build PostgreSQL
- name: Build PostgreSQL
env:
CACHE_HIT: ${{ steps.postgres-cache.outputs.cache-hit }}
run: |
if [[ "$CACHE_HIT" == "true" ]]; then
cp build/postgres/install/stamp build/postgres/
else
python setup.py build_postgres
cp build/postgres/stamp build/postgres/install/
fi
# Build Stolon
- name: Set up Go
if: steps.stolon-cache.outputs.cache-hit != 'true'
uses: actions/setup-go@v2
with:
go-version: 1.16
- uses: actions/checkout@v4
if: steps.stolon-cache.outputs.cache-hit != 'true'
with:
repository: edgedb/stolon
path: build/stolon
ref: ${{ env.STOLON_GIT_REV }}
fetch-depth: 0
submodules: false
- name: Build Stolon
if: steps.stolon-cache.outputs.cache-hit != 'true'
run: |
mkdir -p build/stolon/bin/
curl -fsSL https://releases.hashicorp.com/consul/1.10.1/consul_1.10.1_linux_amd64.zip | zcat > build/stolon/bin/consul
chmod +x build/stolon/bin/consul
cd build/stolon && make
# Install edgedb-server and populate egg-info
- name: Install edgedb-server
env:
BUILD_EXT_MODE: skip
run: |
# --no-build-isolation because we have explicitly installed all deps
# and don't want them to be reinstalled in an "isolated env".
pip install --no-build-isolation --no-deps -e .[test,docs]
# Refresh the bootstrap cache
- name: Handle bootstrap cache
uses: actions/cache@v4
id: bootstrap-cache
with:
path: build/cache
key: edb-bootstrap-v2-${{ hashFiles('shared-artifacts/bootstrap_cache_key.txt') }}
restore-keys: |
edb-bootstrap-v2-
- name: Bootstrap EdgeDB Server
if: steps.bootstrap-cache.outputs.cache-hit != 'true'
run: |
edb server --bootstrap-only
cargo-test:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: false
- uses: actions/checkout@v4
with:
fetch-depth: 50
submodules: true
- name: Set up Python
uses: actions/setup-python@v5
id: setup-python
with:
python-version: '3.12.2'
cache: 'pip'
cache-dependency-path: |
pyproject.toml
# The below is technically a lie as we are technically not
# inside a virtual env, but there is really no reason to bother
# actually creating and activating one as below works just fine.
- name: Export $VIRTUAL_ENV
run: |
venv="$(python -c 'import sys; sys.stdout.write(sys.prefix)')"
echo "VIRTUAL_ENV=${venv}" >> $GITHUB_ENV
- name: Set up uv cache
uses: actions/cache@v4
with:
path: ~/.cache/uv
key: uv-cache-${{ runner.os }}-py-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('pyproject.toml') }}
- name: Download requirements.txt
uses: actions/cache@v4
with:
path: requirements.txt
key: edb-requirements-${{ hashFiles('pyproject.toml') }}
- name: Install Python dependencies
run: python -m pip install uv~=0.1.0 && uv pip install -U -r requirements.txt
- name: Download cache key
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: shared-artifacts
path: shared-artifacts
- name: Generate environment variables
run: |
echo BUILD_TEMP=$(python setup.py -q ci_helper --type build_temp) >> $GITHUB_ENV
- name: Handle Rust extensions build cache
uses: actions/cache@v4
id: rust-cache
with:
path: ${{ env.BUILD_TEMP }}/rust/extensions
key: edb-rust-build-v1-${{ hashFiles('shared-artifacts/rust_cache_key.txt') }}
- name: Install Rust toolchain
uses: dsherret/rust-toolchain-file@v1
- name: Cargo test
env:
CARGO_TARGET_DIR: ${{ env.BUILD_TEMP }}/rust/extensions
CARGO_HOME: ${{ env.BUILD_TEMP }}/rust/extensions/cargo_home
run:
cargo test --all-features
python-test:
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shard: [
1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12,
13, 14, 15, 16,
]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: false
- uses: actions/checkout@v4
with:
fetch-depth: 50
submodules: true
- name: Set up Python
uses: actions/setup-python@v5
id: setup-python
with:
python-version: '3.12.2'
cache: 'pip'
cache-dependency-path: |
pyproject.toml
# The below is technically a lie as we are technically not
# inside a virtual env, but there is really no reason to bother
# actually creating and activating one as below works just fine.
- name: Export $VIRTUAL_ENV
run: |
venv="$(python -c 'import sys; sys.stdout.write(sys.prefix)')"
echo "VIRTUAL_ENV=${venv}" >> $GITHUB_ENV
- name: Set up uv cache
uses: actions/cache@v4
with:
path: ~/.cache/uv
key: uv-cache-${{ runner.os }}-py-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('pyproject.toml') }}
- name: Download requirements.txt
uses: actions/cache@v4
with:
path: requirements.txt
key: edb-requirements-${{ hashFiles('pyproject.toml') }}
- name: Install Python dependencies
run: python -m pip install uv~=0.1.0 && uv pip install -U -r requirements.txt
# Restore the artifacts and environment variables
- name: Download shared artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: shared-artifacts
path: shared-artifacts
- name: Set environment variables
run: |
echo EDGEDBCLI_GIT_REV=$(cat shared-artifacts/edgedbcli_git_rev.txt) >> $GITHUB_ENV
echo POSTGRES_GIT_REV=$(cat shared-artifacts/postgres_git_rev.txt) >> $GITHUB_ENV
echo STOLON_GIT_REV=$(cat shared-artifacts/stolon_git_rev.txt) >> $GITHUB_ENV
echo BUILD_LIB=$(python setup.py -q ci_helper --type build_lib) >> $GITHUB_ENV
echo BUILD_TEMP=$(python setup.py -q ci_helper --type build_temp) >> $GITHUB_ENV
# Restore build cache
- name: Restore cached EdgeDB CLI binaries
uses: actions/cache@v4
id: cli-cache
with:
path: build/cli
key: edb-cli-v4-${{ env.EDGEDBCLI_GIT_REV }}
- name: Restore cached Rust extensions
uses: actions/cache@v4
id: rust-cache
with:
path: build/rust_extensions
key: edb-rust-v4-${{ hashFiles('shared-artifacts/rust_cache_key.txt') }}
- name: Restore cached Cython extensions
uses: actions/cache@v4
id: ext-cache
with:
path: build/extensions
key: edb-ext-v6-${{ hashFiles('shared-artifacts/ext_cache_key.txt') }}
- name: Restore compiled parsers cache
uses: actions/cache@v4
id: parsers-cache
with:
path: build/lib
key: edb-parsers-v3-${{ hashFiles('shared-artifacts/parsers_cache_key.txt') }}
- name: Restore cached PostgreSQL build
uses: actions/cache@v4
id: postgres-cache
with:
path: build/postgres/install
key: edb-postgres-v3-${{ env.POSTGRES_GIT_REV }}-${{ hashFiles('shared-artifacts/lib_cache_key.txt') }}
- name: Restore cached Stolon build
uses: actions/cache@v4
id: stolon-cache
with:
path: build/stolon/bin
key: edb-stolon-v2-${{ env.STOLON_GIT_REV }}
- name: Restore bootstrap cache
uses: actions/cache@v4
id: bootstrap-cache
with:
path: build/cache
key: edb-bootstrap-v2-${{ hashFiles('shared-artifacts/bootstrap_cache_key.txt') }}
- name: Stop if we cannot retrieve the cache
if: |
steps.cli-cache.outputs.cache-hit != 'true' ||
steps.rust-cache.outputs.cache-hit != 'true' ||
steps.ext-cache.outputs.cache-hit != 'true' ||
steps.parsers-cache.outputs.cache-hit != 'true' ||
steps.postgres-cache.outputs.cache-hit != 'true' ||
steps.stolon-cache.outputs.cache-hit != 'true' ||
steps.bootstrap-cache.outputs.cache-hit != 'true'
run: |
echo ::error::Cannot retrieve build cache.
exit 1
- name: Validate cached binaries
run: |
# Validate EdgeDB CLI
./build/cli/bin/edgedb --version || exit 1
# Validate Stolon
./build/stolon/bin/stolon-sentinel --version || exit 1
./build/stolon/bin/stolon-keeper --version || exit 1
./build/stolon/bin/stolon-proxy --version || exit 1
# Validate PostgreSQL
./build/postgres/install/bin/postgres --version || exit 1
./build/postgres/install/bin/pg_config --version || exit 1
- name: Restore cache into the source tree
run: |
cp -v build/cli/bin/edgedb edb/cli/edgedb
cp -v build/cli/bin/edgedb edb/cli/gel
rsync -av ./build/rust_extensions/edb/ ./edb/
rsync -av ./build/extensions/edb/ ./edb/
rsync -av ./build/lib/edb/ ./edb/
cp build/postgres/install/stamp build/postgres/
- name: Install edgedb-server
env:
BUILD_EXT_MODE: skip
run: |
# --no-build-isolation because we have explicitly installed all deps
# and don't want them to be reinstalled in an "isolated env".
pip install --no-build-isolation --no-deps -e .[test,docs]
# Run the test
- name: Install Rust toolchain
uses: dsherret/rust-toolchain-file@v1
- name: Test
env:
SHARD: ${{ matrix.shard }}
EDGEDB_TEST_REPEATS: 1
run: |
mkdir -p results/
cp shared-artifacts/time_stats.csv results/running_times_${SHARD}.csv
edb test --jobs 2 --verbose --shard ${SHARD}/16 \
--running-times-log=results/running_times_${SHARD}.csv \
--result-log=results/result_${SHARD}.json
- name: Upload test results
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
if: ${{ always() }}
with:
name: python-test-results-${{ matrix.shard }}
path: results
retention-days: 1
python-test-list:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: false
- uses: actions/checkout@v4
with:
fetch-depth: 50
submodules: true
- name: Set up Python
uses: actions/setup-python@v5
id: setup-python
with:
python-version: '3.12.2'
cache: 'pip'
cache-dependency-path: |
pyproject.toml
# The below is technically a lie as we are technically not
# inside a virtual env, but there is really no reason to bother
# actually creating and activating one as below works just fine.
- name: Export $VIRTUAL_ENV
run: |
venv="$(python -c 'import sys; sys.stdout.write(sys.prefix)')"
echo "VIRTUAL_ENV=${venv}" >> $GITHUB_ENV
- name: Set up uv cache
uses: actions/cache@v4
with:
path: ~/.cache/uv
key: uv-cache-${{ runner.os }}-py-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('pyproject.toml') }}
- name: Download requirements.txt
uses: actions/cache@v4
with:
path: requirements.txt
key: edb-requirements-${{ hashFiles('pyproject.toml') }}
- name: Install Python dependencies
run: python -m pip install uv~=0.1.0 && uv pip install -U -r requirements.txt
# Restore the artifacts and environment variables
- name: Download shared artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: shared-artifacts
path: shared-artifacts
- name: Set environment variables
run: |
echo EDGEDBCLI_GIT_REV=$(cat shared-artifacts/edgedbcli_git_rev.txt) >> $GITHUB_ENV
echo POSTGRES_GIT_REV=$(cat shared-artifacts/postgres_git_rev.txt) >> $GITHUB_ENV
echo STOLON_GIT_REV=$(cat shared-artifacts/stolon_git_rev.txt) >> $GITHUB_ENV
echo BUILD_LIB=$(python setup.py -q ci_helper --type build_lib) >> $GITHUB_ENV
echo BUILD_TEMP=$(python setup.py -q ci_helper --type build_temp) >> $GITHUB_ENV
# Restore build cache
- name: Restore cached EdgeDB CLI binaries
uses: actions/cache@v4
id: cli-cache
with:
path: build/cli
key: edb-cli-v4-${{ env.EDGEDBCLI_GIT_REV }}
- name: Restore cached Rust extensions
uses: actions/cache@v4
id: rust-cache
with:
path: build/rust_extensions
key: edb-rust-v4-${{ hashFiles('shared-artifacts/rust_cache_key.txt') }}
- name: Restore cached Cython extensions
uses: actions/cache@v4
id: ext-cache
with:
path: build/extensions
key: edb-ext-v6-${{ hashFiles('shared-artifacts/ext_cache_key.txt') }}
- name: Restore compiled parsers cache
uses: actions/cache@v4
id: parsers-cache
with:
path: build/lib
key: edb-parsers-v3-${{ hashFiles('shared-artifacts/parsers_cache_key.txt') }}
- name: Restore cached PostgreSQL build
uses: actions/cache@v4
id: postgres-cache
with:
path: build/postgres/install
key: edb-postgres-v3-${{ env.POSTGRES_GIT_REV }}-${{ hashFiles('shared-artifacts/lib_cache_key.txt') }}
- name: Restore cached Stolon build
uses: actions/cache@v4
id: stolon-cache
with:
path: build/stolon/bin
key: edb-stolon-v2-${{ env.STOLON_GIT_REV }}
- name: Restore bootstrap cache
uses: actions/cache@v4
id: bootstrap-cache
with:
path: build/cache
key: edb-bootstrap-v2-${{ hashFiles('shared-artifacts/bootstrap_cache_key.txt') }}
- name: Stop if we cannot retrieve the cache
if: |
steps.cli-cache.outputs.cache-hit != 'true' ||
steps.rust-cache.outputs.cache-hit != 'true' ||
steps.ext-cache.outputs.cache-hit != 'true' ||
steps.parsers-cache.outputs.cache-hit != 'true' ||
steps.postgres-cache.outputs.cache-hit != 'true' ||
steps.stolon-cache.outputs.cache-hit != 'true' ||
steps.bootstrap-cache.outputs.cache-hit != 'true'
run: |
echo ::error::Cannot retrieve build cache.
exit 1
- name: Validate cached binaries
run: |
# Validate EdgeDB CLI
./build/cli/bin/edgedb --version || exit 1
# Validate Stolon
./build/stolon/bin/stolon-sentinel --version || exit 1
./build/stolon/bin/stolon-keeper --version || exit 1
./build/stolon/bin/stolon-proxy --version || exit 1
# Validate PostgreSQL
./build/postgres/install/bin/postgres --version || exit 1
./build/postgres/install/bin/pg_config --version || exit 1
- name: Restore cache into the source tree
run: |
cp -v build/cli/bin/edgedb edb/cli/edgedb
cp -v build/cli/bin/edgedb edb/cli/gel
rsync -av ./build/rust_extensions/edb/ ./edb/
rsync -av ./build/extensions/edb/ ./edb/
rsync -av ./build/lib/edb/ ./edb/
cp build/postgres/install/stamp build/postgres/
- name: Install edgedb-server
env:
BUILD_EXT_MODE: skip
run: |
# --no-build-isolation because we have explicitly installed all deps
# and don't want them to be reinstalled in an "isolated env".
pip install --no-build-isolation --no-deps -e .[test,docs]
# List tests and upload
- name: Generate complete list of tests for verification
env:
SHARD: ${{ matrix.shard }}
EDGEDB_TEST_REPEATS: 1
run: |
edb test --list > shared-artifacts/all_tests.txt
- name: Upload list of tests
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: test-list
path: shared-artifacts
retention-days: 1
test-conclusion:
needs: [cargo-test, python-test, python-test-list]
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12.2'
- name: Install Python deps
run: |
python -m pip install requests click
- uses: actions/checkout@v4
with:
submodules: false
- name: Download python-test results
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
pattern: python-test-results-*
merge-multiple: true
path: results
# Render results and exit if they were unsuccessful
- name: Render results
run: |
python edb/tools/test/results.py 'results/result_*.json'
- name: Download shared artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: shared-artifacts
path: shared-artifacts
- name: Download test list
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: test-list
path: shared-artifacts
- name: Merge stats and verify tests completion
shell: python
env:
GIST_TOKEN: ${{ secrets.CI_BOT_GIST_TOKEN }}
GIT_REF: ${{ github.ref }}
run: |
import csv
import glob
import io
import os
import requests
orig = {}
new = {}
all_tests = set()
with open("shared-artifacts/time_stats.csv") as f:
for name, t, c in csv.reader(f):
assert name not in orig, "duplicate test name in original stats!"
orig[name] = (t, int(c))
with open("shared-artifacts/all_tests.txt") as f:
for line in f:
assert line not in all_tests, "duplicate test name in this run!"
all_tests.add(line.strip())
for new_file in glob.glob("results/running_times_*.csv"):
with open(new_file) as f:
for name, t, c in csv.reader(f):
if int(c) > orig.get(name, (0, 0))[1]:
if name.startswith("setup::"):
new[name] = (t, c)
else:
assert name not in new, f"duplicate test! {name}"
new[name] = (t, c)
all_tests.remove(name)
assert not all_tests, "Tests not run! \n" + "\n".join(all_tests)
if os.environ["GIT_REF"] == "refs/heads/master":
buf = io.StringIO()
writer = csv.writer(buf)
orig.update(new)
for k, v in sorted(orig.items()):
writer.writerow((k,) + v)
resp = requests.patch(
"https://api.github.com/gists/8b722a65397f7c4c0df72f5394efa04c",
headers={"Accept": "application/vnd.github.v3+json"},
auth=("edgedb-ci", os.environ["GIST_TOKEN"]),
json={"files": {"time_stats.csv": {"content": buf.getvalue()}}},
)
resp.raise_for_status()
workflow-notifications:
if: failure() && github.event_name != 'pull_request'
name: Notify in Slack on failures
needs:
- test-conclusion
runs-on: ubuntu-latest
permissions:
actions: 'read'
steps:
- name: Slack Workflow Notification
uses: Gamesight/slack-workflow-status@26a36836c887f260477432e4314ec3490a84f309
with:
repo_token: ${{secrets.GITHUB_TOKEN}}
slack_webhook_url: ${{secrets.ACTIONS_SLACK_WEBHOOK_URL}}
name: 'Workflow notifications'
icon_emoji: ':hammer:'
include_jobs: 'on-failure'