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