@@ -12,8 +12,9 @@ permissions:
12
12
13
13
jobs :
14
14
test-go-pg :
15
- runs-on : ${{ matrix.os == 'macos-latest' && github.repository_owner == 'coder' && 'depot-macos-latest' || matrix.os == 'windows-2022' && github.repository_owner == 'coder' && 'windows-latest-16-cores' || matrix.os }}
16
- if : github.ref == 'refs/heads/main'
15
+ # make sure to adjust NUM_PARALLEL_PACKAGES and NUM_PARALLEL_TESTS below
16
+ # when changing runner sizes
17
+ runs-on : ${{ matrix.os == 'macos-latest' && github.repository_owner == 'coder' && 'depot-macos-latest' || matrix.os == 'windows-2022' && github.repository_owner == 'coder' && 'depot-windows-2022-16' || matrix.os }}
17
18
# This timeout must be greater than the timeout set by `go test` in
18
19
# `make test-postgres` to ensure we receive a trace of running
19
20
# goroutines. Setting this to the timeout +5m should work quite well
@@ -31,22 +32,39 @@ jobs:
31
32
with :
32
33
egress-policy : audit
33
34
35
+ # macOS indexes all new files in the background. Our Postgres tests
36
+ # create and destroy thousands of databases on disk, and Spotlight
37
+ # tries to index all of them, seriously slowing down the tests.
38
+ - name : Disable Spotlight Indexing
39
+ if : runner.os == 'macOS'
40
+ run : |
41
+ sudo mdutil -a -i off
42
+ sudo mdutil -X /
43
+ sudo launchctl bootout system /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
44
+
45
+ # Set up RAM disks to speed up the rest of the job. This action is in
46
+ # a separate repository to allow its use before actions/checkout.
47
+ - name : Setup RAM Disks
48
+ if : runner.os == 'Windows'
49
+ uses : coder/setup-ramdisk-action@79dacfe70c47ad6d6c0dd7f45412368802641439
50
+
34
51
- name : Checkout
35
52
uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
36
53
with :
37
54
fetch-depth : 1
38
55
39
56
- name : Setup Go
40
57
uses : ./.github/actions/setup-go
58
+ with :
59
+ # Runners have Go baked-in and Go will automatically
60
+ # download the toolchain configured in go.mod, so we don't
61
+ # need to reinstall it. It's faster on Windows runners.
62
+ use-preinstalled-go : ${{ runner.os == 'Windows' }}
63
+ use-temp-cache-dirs : ${{ runner.os == 'Windows' }}
41
64
42
65
- name : Setup Terraform
43
66
uses : ./.github/actions/setup-tf
44
67
45
- # Sets up the ImDisk toolkit for Windows and creates a RAM disk on drive R:.
46
- - name : Setup ImDisk
47
- if : runner.os == 'Windows'
48
- uses : ./.github/actions/setup-imdisk
49
-
50
68
- name : Test with PostgreSQL Database
51
69
env :
52
70
POSTGRES_VERSION : " 13"
55
73
LC_ALL : " en_US.UTF-8"
56
74
shell : bash
57
75
run : |
76
+ if [ "${{ runner.os }}" == "Windows" ]; then
77
+ # Create a temp dir on the R: ramdisk drive for Windows. The default
78
+ # C: drive is extremely slow: https://github.com/actions/runner-images/issues/8755
79
+ mkdir -p "R:/temp/embedded-pg"
80
+ go run scripts/embedded-pg/main.go -path "R:/temp/embedded-pg"
81
+ fi
82
+ if [ "${{ runner.os }}" == "macOS" ]; then
83
+ # Postgres runs faster on a ramdisk on macOS too
84
+ mkdir -p /tmp/tmpfs
85
+ sudo mount_tmpfs -o noowners -s 8g /tmp/tmpfs
86
+ go run scripts/embedded-pg/main.go -path /tmp/tmpfs/embedded-pg
87
+ fi
88
+
58
89
# if macOS, install google-chrome for scaletests
59
90
# As another concern, should we really have this kind of external dependency
60
91
# requirement on standard CI?
@@ -72,19 +103,29 @@ jobs:
72
103
touch ~/.bash_profile && echo "export BASH_SILENCE_DEPRECATION_WARNING=1" >> ~/.bash_profile
73
104
fi
74
105
106
+ # Golang's default for these 2 variables is the number of logical CPUs.
107
+ # Our Windows and Linux runners have 16 cores, so they match up there.
108
+ NUM_PARALLEL_PACKAGES=16
109
+ NUM_PARALLEL_TESTS=16
75
110
if [ "${{ runner.os }}" == "Windows" ]; then
76
- # Create a temp dir on the R: ramdisk drive for Windows. The default
77
- # C: drive is extremely slow: https://github.com/actions/runner-images/issues/8755
78
- mkdir -p "R:/temp/embedded-pg"
79
- go run scripts/embedded-pg/main.go -path "R:/temp/embedded-pg"
80
- else
81
- go run scripts/embedded-pg/main.go
111
+ # On Windows Postgres chokes up when we have 16x16=256 tests
112
+ # running in parallel, and dbtestutil.NewDB starts to take more than
113
+ # 10s to complete sometimes causing test timeouts. With 16x8=128 tests
114
+ # Postgres tends not to choke.
115
+ NUM_PARALLEL_PACKAGES=8
116
+ fi
117
+ if [ "${{ runner.os }}" == "macOS" ]; then
118
+ # Our macOS runners have 8 cores. We leave NUM_PARALLEL_TESTS at 16
119
+ # because the tests complete faster and Postgres doesn't choke. It seems
120
+ # that macOS's tmpfs is faster than the one on Windows.
121
+ NUM_PARALLEL_PACKAGES=8
82
122
fi
83
123
84
- # Reduce test parallelism, mirroring what we do for race tests.
85
- # We'd been encountering issues with timing related flakes, and
86
- # this seems to help.
87
- DB=ci gotestsum --format standard-quiet -- -v -short -count=1 -parallel 4 -p 4 ./...
124
+ # We rerun failing tests to counteract flakiness coming from Postgres
125
+ # choking on macOS and Windows sometimes.
126
+ DB=ci gotestsum --rerun-fails=2 --rerun-fails-max-failures=1000 \
127
+ --format standard-quiet --packages "./..." \
128
+ -- -v -p $NUM_PARALLEL_PACKAGES -parallel=$NUM_PARALLEL_TESTS -count=1
88
129
89
130
- name : Upload test stats to Datadog
90
131
timeout-minutes : 1
0 commit comments