Skip to content

Commit 25ff4b7

Browse files
committed
update to current test-go-pg from main
1 parent 22099f8 commit 25ff4b7

File tree

1 file changed

+103
-24
lines changed

1 file changed

+103
-24
lines changed

.github/workflows/nightly-gauntlet.yaml

Lines changed: 103 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,23 @@ jobs:
1414
test-go-pg:
1515
# make sure to adjust NUM_PARALLEL_PACKAGES and NUM_PARALLEL_TESTS below
1616
# 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+
runs-on: ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'depot-ubuntu-22.04-8' || matrix.os && 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 }}
18+
needs: changes
19+
if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
1820
# This timeout must be greater than the timeout set by `go test` in
1921
# `make test-postgres` to ensure we receive a trace of running
2022
# goroutines. Setting this to the timeout +5m should work quite well
2123
# even if some of the preceding steps are slow.
2224
timeout-minutes: 25
2325
strategy:
24-
fail-fast: false
2526
matrix:
2627
os:
28+
- ubuntu-latest
2729
- macos-latest
2830
- windows-2022
2931
steps:
3032
- name: Harden Runner
31-
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
33+
uses: step-security/harden-runner@6c439dc8bdf85cadbbce9ed30d1c7b959517bc49 # v2.12.2
3234
with:
3335
egress-policy: audit
3436

@@ -46,25 +48,63 @@ jobs:
4648
# a separate repository to allow its use before actions/checkout.
4749
- name: Setup RAM Disks
4850
if: runner.os == 'Windows'
49-
uses: coder/setup-ramdisk-action@79dacfe70c47ad6d6c0dd7f45412368802641439
51+
uses: coder/setup-ramdisk-action@e1100847ab2d7bcd9d14bcda8f2d1b0f07b36f1b
5052

5153
- name: Checkout
5254
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
5355
with:
5456
fetch-depth: 1
5557

58+
- name: Setup Go Paths
59+
id: go-paths
60+
uses: ./.github/actions/setup-go-paths
61+
62+
- name: Download Go Build Cache
63+
id: download-go-build-cache
64+
uses: ./.github/actions/test-cache/download
65+
with:
66+
key-prefix: test-go-build-${{ runner.os }}-${{ runner.arch }}
67+
cache-path: ${{ steps.go-paths.outputs.cached-dirs }}
68+
5669
- name: Setup Go
5770
uses: ./.github/actions/setup-go
5871
with:
5972
# Runners have Go baked-in and Go will automatically
6073
# download the toolchain configured in go.mod, so we don't
6174
# need to reinstall it. It's faster on Windows runners.
6275
use-preinstalled-go: ${{ runner.os == 'Windows' }}
63-
use-temp-cache-dirs: ${{ runner.os == 'Windows' }}
76+
# Cache is already downloaded above
77+
use-cache: false
6478

6579
- name: Setup Terraform
6680
uses: ./.github/actions/setup-tf
6781

82+
- name: Download Test Cache
83+
id: download-cache
84+
uses: ./.github/actions/test-cache/download
85+
with:
86+
key-prefix: test-go-pg-${{ runner.os }}-${{ runner.arch }}
87+
88+
- name: Setup Embedded Postgres Cache Paths
89+
id: embedded-pg-cache
90+
uses: ./.github/actions/setup-embedded-pg-cache-paths
91+
92+
- name: Download Embedded Postgres Cache
93+
id: download-embedded-pg-cache
94+
uses: ./.github/actions/embedded-pg-cache/download
95+
with:
96+
key-prefix: embedded-pg-${{ runner.os }}-${{ runner.arch }}
97+
cache-path: ${{ steps.embedded-pg-cache.outputs.cached-dirs }}
98+
99+
- name: Normalize File and Directory Timestamps
100+
shell: bash
101+
# Normalize file modification timestamps so that go test can use the
102+
# cache from the previous CI run. See https://github.com/golang/go/issues/58571
103+
# for more details.
104+
run: |
105+
find . -type f ! -path ./.git/\*\* | mtimehash
106+
find . -type d ! -path ./.git/\*\* -exec touch -t 200601010000 {} +
107+
68108
- name: Test with PostgreSQL Database
69109
env:
70110
POSTGRES_VERSION: "13"
@@ -73,17 +113,21 @@ jobs:
73113
LC_ALL: "en_US.UTF-8"
74114
shell: bash
75115
run: |
116+
set -o errexit
117+
set -o pipefail
118+
76119
if [ "${{ runner.os }}" == "Windows" ]; then
77120
# Create a temp dir on the R: ramdisk drive for Windows. The default
78121
# C: drive is extremely slow: https://github.com/actions/runner-images/issues/8755
79122
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
123+
go run scripts/embedded-pg/main.go -path "R:/temp/embedded-pg" -cache "${EMBEDDED_PG_CACHE_DIR}"
124+
elif [ "${{ runner.os }}" == "macOS" ]; then
83125
# Postgres runs faster on a ramdisk on macOS too
84126
mkdir -p /tmp/tmpfs
85127
sudo mount_tmpfs -o noowners -s 8g /tmp/tmpfs
86-
go run scripts/embedded-pg/main.go -path /tmp/tmpfs/embedded-pg
128+
go run scripts/embedded-pg/main.go -path /tmp/tmpfs/embedded-pg -cache "${EMBEDDED_PG_CACHE_DIR}"
129+
elif [ "${{ runner.os }}" == "Linux" ]; then
130+
make test-postgres-docker
87131
fi
88132
89133
# if macOS, install google-chrome for scaletests
@@ -93,39 +137,74 @@ jobs:
93137
brew install google-chrome
94138
fi
95139
96-
# By default Go will use the number of logical CPUs, which
97-
# is a fine default.
98-
PARALLEL_FLAG=""
99-
100140
# macOS will output "The default interactive shell is now zsh"
101141
# intermittently in CI...
102142
if [ "${{ matrix.os }}" == "macos-latest" ]; then
103143
touch ~/.bash_profile && echo "export BASH_SILENCE_DEPRECATION_WARNING=1" >> ~/.bash_profile
104144
fi
105145
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
110146
if [ "${{ runner.os }}" == "Windows" ]; then
147+
# Our Windows runners have 16 cores.
111148
# On Windows Postgres chokes up when we have 16x16=256 tests
112149
# running in parallel, and dbtestutil.NewDB starts to take more than
113150
# 10s to complete sometimes causing test timeouts. With 16x8=128 tests
114151
# Postgres tends not to choke.
115152
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
153+
NUM_PARALLEL_TESTS=16
154+
elif [ "${{ runner.os }}" == "macOS" ]; then
155+
# Our macOS runners have 8 cores. We set NUM_PARALLEL_TESTS to 16
119156
# because the tests complete faster and Postgres doesn't choke. It seems
120157
# that macOS's tmpfs is faster than the one on Windows.
121158
NUM_PARALLEL_PACKAGES=8
159+
NUM_PARALLEL_TESTS=16
160+
elif [ "${{ runner.os }}" == "Linux" ]; then
161+
# Our Linux runners have 8 cores.
162+
NUM_PARALLEL_PACKAGES=8
163+
NUM_PARALLEL_TESTS=8
164+
fi
165+
166+
# by default, run tests with cache
167+
TESTCOUNT=""
168+
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
169+
# on main, run tests without cache
170+
TESTCOUNT="-count=1"
122171
fi
123172
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 \
173+
TEST_RETRIES="--rerun-fails=2 --rerun-fails-max-failures=50"
174+
if [ "${{ github.ref }}" == "refs/heads/hugodutka/disable-test-retries-on-main" ]; then
175+
# on main, run tests without retries
176+
TEST_RETRIES=""
177+
fi
178+
179+
mkdir -p "$RUNNER_TEMP/sym"
180+
source scripts/normalize_path.sh
181+
# terraform gets installed in a random directory, so we need to normalize
182+
# the path to the terraform binary or a bunch of cached tests will be
183+
# invalidated. See scripts/normalize_path.sh for more details.
184+
normalize_path_with_symlinks "$RUNNER_TEMP/sym" "$(dirname $(which terraform))"
185+
186+
DB=ci gotestsum $TEST_RETRIES \
127187
--format standard-quiet --packages "./..." \
128-
-- -v -p $NUM_PARALLEL_PACKAGES -parallel=$NUM_PARALLEL_TESTS -count=1
188+
-- -timeout=20m -v -p $NUM_PARALLEL_PACKAGES -parallel=$NUM_PARALLEL_TESTS $TESTCOUNT
189+
190+
- name: Upload Go Build Cache
191+
uses: ./.github/actions/test-cache/upload
192+
with:
193+
cache-key: ${{ steps.download-go-build-cache.outputs.cache-key }}
194+
cache-path: ${{ steps.go-paths.outputs.cached-dirs }}
195+
196+
- name: Upload Test Cache
197+
uses: ./.github/actions/test-cache/upload
198+
with:
199+
cache-key: ${{ steps.download-cache.outputs.cache-key }}
200+
201+
- name: Upload Embedded Postgres Cache
202+
uses: ./.github/actions/embedded-pg-cache/upload
203+
# We only use the embedded Postgres cache on macOS and Windows runners.
204+
if: runner.OS == 'macOS' || runner.OS == 'Windows'
205+
with:
206+
cache-key: ${{ steps.download-embedded-pg-cache.outputs.cache-key }}
207+
cache-path: "${{ steps.embedded-pg-cache.outputs.embedded-pg-cache }}"
129208

130209
- name: Upload test stats to Datadog
131210
timeout-minutes: 1

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy