@@ -336,21 +336,23 @@ jobs:
336
336
# a separate repository to allow its use before actions/checkout.
337
337
- name : Setup RAM Disks
338
338
if : runner.os == 'Windows'
339
- uses : coder/setup-ramdisk-action@81c5c441bda00c6c3d6bcee2e5a33ed4aadbbcc1
339
+ uses : coder/setup-ramdisk-action@a4b59caa8be2e88c348abeef042d7c1a33d8743e
340
340
341
341
- name : Checkout
342
342
uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
343
343
with :
344
344
fetch-depth : 1
345
345
346
+ - name : Setup Go Paths
347
+ uses : ./.github/actions/setup-go-paths
348
+
346
349
- name : Setup Go
347
350
uses : ./.github/actions/setup-go
348
351
with :
349
352
# Runners have Go baked-in and Go will automatically
350
353
# download the toolchain configured in go.mod, so we don't
351
354
# need to reinstall it. It's faster on Windows runners.
352
355
use-preinstalled-go : ${{ runner.os == 'Windows' }}
353
- use-temp-cache-dirs : ${{ runner.os == 'Windows' }}
354
356
355
357
- name : Setup Terraform
356
358
uses : ./.github/actions/setup-tf
@@ -490,21 +492,33 @@ jobs:
490
492
# a separate repository to allow its use before actions/checkout.
491
493
- name : Setup RAM Disks
492
494
if : runner.os == 'Windows'
493
- uses : coder/setup-ramdisk-action@79dacfe70c47ad6d6c0dd7f45412368802641439
495
+ uses : coder/setup-ramdisk-action@a4b59caa8be2e88c348abeef042d7c1a33d8743e
494
496
495
497
- name : Checkout
496
498
uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
497
499
with :
498
500
fetch-depth : 1
499
501
502
+ - name : Setup Go Paths
503
+ id : go-paths
504
+ uses : ./.github/actions/setup-go-paths
505
+
506
+ - name : Download Go Build Cache
507
+ id : download-go-build-cache
508
+ uses : ./.github/actions/test-cache/download
509
+ with :
510
+ key-prefix : test-go-build-${{ runner.os }}-${{ runner.arch }}
511
+ cache-path : ${{ steps.go-paths.outputs.cached-dirs }}
512
+
500
513
- name : Setup Go
501
514
uses : ./.github/actions/setup-go
502
515
with :
503
516
# Runners have Go baked-in and Go will automatically
504
517
# download the toolchain configured in go.mod, so we don't
505
518
# need to reinstall it. It's faster on Windows runners.
506
519
use-preinstalled-go : ${{ runner.os == 'Windows' }}
507
- use-temp-cache-dirs : ${{ runner.os == 'Windows' }}
520
+ # Cache is already downloaded above
521
+ use-cache : false
508
522
509
523
- name : Setup Terraform
510
524
uses : ./.github/actions/setup-tf
@@ -515,14 +529,27 @@ jobs:
515
529
with :
516
530
key-prefix : test-go-pg-${{ runner.os }}-${{ runner.arch }}
517
531
532
+ - name : Normalize File and Directory Timestamps
533
+ shell : bash
534
+ # Normalize file modification timestamps so that go test can use the
535
+ # cache from the previous CI run. See https://github.com/golang/go/issues/58571
536
+ # for more details.
537
+ run : |
538
+ find . -type f ! -path ./.git/\*\* | mtimehash
539
+ find . -type d ! -path ./.git/\*\* -exec touch -t 200601010000 {} +
540
+
518
541
- name : Test with PostgreSQL Database
519
542
env :
520
543
POSTGRES_VERSION : " 13"
521
544
TS_DEBUG_DISCO : " true"
522
545
LC_CTYPE : " en_US.UTF-8"
523
546
LC_ALL : " en_US.UTF-8"
547
+
524
548
shell : bash
525
549
run : |
550
+ set -o errexit
551
+ set -o pipefail
552
+
526
553
if [ "${{ runner.os }}" == "Windows" ]; then
527
554
# Create a temp dir on the R: ramdisk drive for Windows. The default
528
555
# C: drive is extremely slow: https://github.com/actions/runner-images/issues/8755
@@ -533,6 +560,8 @@ jobs:
533
560
mkdir -p /tmp/tmpfs
534
561
sudo mount_tmpfs -o noowners -s 8g /tmp/tmpfs
535
562
go run scripts/embedded-pg/main.go -path /tmp/tmpfs/embedded-pg
563
+ elif [ "${{ runner.os }}" == "Linux" ]; then
564
+ make test-postgres-docker
536
565
fi
537
566
538
567
# if macOS, install google-chrome for scaletests
@@ -542,10 +571,6 @@ jobs:
542
571
brew install google-chrome
543
572
fi
544
573
545
- # By default Go will use the number of logical CPUs, which
546
- # is a fine default.
547
- PARALLEL_FLAG=""
548
-
549
574
# macOS will output "The default interactive shell is now zsh"
550
575
# intermittently in CI...
551
576
if [ "${{ matrix.os }}" == "macos-latest" ]; then
@@ -572,16 +597,32 @@ jobs:
572
597
NUM_PARALLEL_TESTS=8
573
598
fi
574
599
575
- if [ "${{ runner.os }}" == "Linux" ]; then
576
- make test-postgres
577
- else
578
- # We rerun failing tests to counteract flakiness coming from Postgres
579
- # choking on macOS and Windows sometimes.
580
- DB=ci gotestsum --rerun-fails=2 --rerun-fails-max-failures=50 \
581
- --format standard-quiet --packages "./..." \
582
- -- -v -p $NUM_PARALLEL_PACKAGES -parallel=$NUM_PARALLEL_TESTS -count=1
600
+ # by default, run tests with cache
601
+ TESTCOUNT=""
602
+ if [ "${{ github.ref }}" == "refs/heads/main" ]; then
603
+ # on main, run tests without cache
604
+ TESTCOUNT="-count=1"
583
605
fi
584
606
607
+ mkdir -p "$RUNNER_TEMP/sym"
608
+ source scripts/normalize_path.sh
609
+ # terraform gets installed in a random directory, so we need to normalize
610
+ # the path to the terraform binary or a bunch of cached tests will be
611
+ # invalidated. See scripts/normalize_path.sh for more details.
612
+ normalize_path_with_symlinks "$RUNNER_TEMP/sym" "$(dirname $(which terraform))"
613
+
614
+ # We rerun failing tests to counteract flakiness coming from Postgres
615
+ # choking on macOS and Windows sometimes.
616
+ DB=ci gotestsum --rerun-fails=2 --rerun-fails-max-failures=50 \
617
+ --format standard-quiet --packages "./..." \
618
+ -- -timeout=20m -v -p $NUM_PARALLEL_PACKAGES -parallel=$NUM_PARALLEL_TESTS $TESTCOUNT
619
+
620
+ - name : Upload Go Build Cache
621
+ uses : ./.github/actions/test-cache/upload
622
+ with :
623
+ cache-key : ${{ steps.download-go-build-cache.outputs.cache-key }}
624
+ cache-path : ${{ steps.go-paths.outputs.cached-dirs }}
625
+
585
626
- name : Upload Test Cache
586
627
uses : ./.github/actions/test-cache/upload
587
628
with :
0 commit comments