Skip to content

Commit fddaf7f

Browse files
committed
enable test-go-pg on macos and windows
1 parent 34494fb commit fddaf7f

File tree

1 file changed

+81
-8
lines changed

1 file changed

+81
-8
lines changed

.github/workflows/ci.yaml

Lines changed: 81 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,9 @@ jobs:
454454
api-key: ${{ secrets.DATADOG_API_KEY }}
455455

456456
test-go-pg:
457-
runs-on: ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'depot-ubuntu-22.04-8' || matrix.os }}
457+
# make sure to adjust NUM_PARALLEL_PACKAGES and NUM_PARALLEL_TESTS below
458+
# when changing runner sizes
459+
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 }}
458460
needs: changes
459461
if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
460462
# This timeout must be greater than the timeout set by `go test` in
@@ -466,28 +468,47 @@ jobs:
466468
matrix:
467469
os:
468470
- ubuntu-latest
471+
- macos-latest
472+
- windows-2022
469473
steps:
470474
- name: Harden Runner
471475
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
472476
with:
473477
egress-policy: audit
474478

479+
# macOS indexes all new files in the background. Our Postgres tests
480+
# create and destroy thousands of databases on disk, and Spotlight
481+
# tries to index all of them, seriously slowing down the tests.
482+
- name: Disable Spotlight Indexing
483+
if: runner.os == 'macOS'
484+
run: |
485+
sudo mdutil -a -i off
486+
sudo mdutil -X /
487+
sudo launchctl bootout system /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
488+
489+
# Set up RAM disks to speed up the rest of the job. This action is in
490+
# a separate repository to allow its use before actions/checkout.
491+
- name: Setup RAM Disks
492+
if: runner.os == 'Windows'
493+
uses: coder/setup-ramdisk-action@79dacfe70c47ad6d6c0dd7f45412368802641439
494+
475495
- name: Checkout
476496
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
477497
with:
478498
fetch-depth: 1
479499

480500
- name: Setup Go
481501
uses: ./.github/actions/setup-go
502+
with:
503+
# Runners have Go baked-in and Go will automatically
504+
# download the toolchain configured in go.mod, so we don't
505+
# need to reinstall it. It's faster on Windows runners.
506+
use-preinstalled-go: ${{ runner.os == 'Windows' }}
507+
use-temp-cache-dirs: ${{ runner.os == 'Windows' }}
482508

483509
- name: Setup Terraform
484510
uses: ./.github/actions/setup-tf
485511

486-
# Sets up the ImDisk toolkit for Windows and creates a RAM disk on drive R:.
487-
- name: Setup ImDisk
488-
if: runner.os == 'Windows'
489-
uses: ./.github/actions/setup-imdisk
490-
491512
- name: Download Test Cache
492513
id: download-cache
493514
uses: ./.github/actions/test-cache/download
@@ -500,14 +521,66 @@ jobs:
500521
TS_DEBUG_DISCO: "true"
501522
LC_CTYPE: "en_US.UTF-8"
502523
LC_ALL: "en_US.UTF-8"
503-
TEST_RETRIES: 2
504524
shell: bash
505525
run: |
526+
if [ "${{ runner.os }}" == "Windows" ]; then
527+
# Create a temp dir on the R: ramdisk drive for Windows. The default
528+
# C: drive is extremely slow: https://github.com/actions/runner-images/issues/8755
529+
mkdir -p "R:/temp/embedded-pg"
530+
go run scripts/embedded-pg/main.go -path "R:/temp/embedded-pg"
531+
elif [ "${{ runner.os }}" == "macOS" ]; then
532+
# Postgres runs faster on a ramdisk on macOS too
533+
mkdir -p /tmp/tmpfs
534+
sudo mount_tmpfs -o noowners -s 8g /tmp/tmpfs
535+
go run scripts/embedded-pg/main.go -path /tmp/tmpfs/embedded-pg
536+
fi
537+
538+
# if macOS, install google-chrome for scaletests
539+
# As another concern, should we really have this kind of external dependency
540+
# requirement on standard CI?
541+
if [ "${{ matrix.os }}" == "macos-latest" ]; then
542+
brew install google-chrome
543+
fi
544+
506545
# By default Go will use the number of logical CPUs, which
507546
# is a fine default.
508547
PARALLEL_FLAG=""
509548
510-
make test-postgres
549+
# macOS will output "The default interactive shell is now zsh"
550+
# intermittently in CI...
551+
if [ "${{ matrix.os }}" == "macos-latest" ]; then
552+
touch ~/.bash_profile && echo "export BASH_SILENCE_DEPRECATION_WARNING=1" >> ~/.bash_profile
553+
fi
554+
555+
if [ "${{ runner.os }}" == "Windows" ]; then
556+
# Our Windows runners have 16 cores.
557+
# On Windows Postgres chokes up when we have 16x16=256 tests
558+
# running in parallel, and dbtestutil.NewDB starts to take more than
559+
# 10s to complete sometimes causing test timeouts. With 16x8=128 tests
560+
# Postgres tends not to choke.
561+
NUM_PARALLEL_PACKAGES=8
562+
NUM_PARALLEL_TESTS=16
563+
elif [ "${{ runner.os }}" == "macOS" ]; then
564+
# Our macOS runners have 8 cores. We set NUM_PARALLEL_TESTS to 16
565+
# because the tests complete faster and Postgres doesn't choke. It seems
566+
# that macOS's tmpfs is faster than the one on Windows.
567+
NUM_PARALLEL_PACKAGES=8
568+
NUM_PARALLEL_TESTS=16
569+
elif [ "${{ runner.os }}" == "Linux" ]; then
570+
# Our Linux runners have 8 cores.
571+
NUM_PARALLEL_PACKAGES=8
572+
NUM_PARALLEL_TESTS=8
573+
fi
574+
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
583+
fi
511584
512585
- name: Upload Test Cache
513586
uses: ./.github/actions/test-cache/upload

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