mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
ea2cae0e20
Changes: - use a bigger runner for test-go-pg on Linux - use a depot runner to run postgres tests on Windows - use the same Windows ramdisk action for postgres tests as the one currently used for in-memory tests - put GOTMPDIR on a ramdisk on Windows - tune the number of tests running in parallel on macOS and Windows - use a ramdisk for postgres on macOS - turn off Spotlight indexing on macOS - rerun failing tests to stop flakes from disrupting developers Results: - test-go-pg on Linux completing in 50% of the time it takes to run on main ([run on main](https://github.com/coder/coder/actions/runs/14937632073/job/41968714750), [run on this PR](https://github.com/coder/coder/actions/runs/14956584795/job/42013097674?pr=17756)) - macOS tests completing in 70% of the time ([run on main](https://github.com/coder/coder/actions/runs/14921155015/job/41916639889), [run on this PR](https://github.com/coder/coder/actions/runs/14956590940/job/42013102975)) - Windows tests completing in 50% of the time ([run on main](https://github.com/coder/coder/actions/runs/14921155015/job/41916640058), [run on this PR](https://github.com/coder/coder/actions/runs/14956590940/job/42013103116)) This PR helps unblock https://github.com/coder/coder/issues/15109.
52 lines
1.8 KiB
YAML
52 lines
1.8 KiB
YAML
name: "Setup Go"
|
|
description: |
|
|
Sets up the Go environment for tests, builds, etc.
|
|
inputs:
|
|
version:
|
|
description: "The Go version to use."
|
|
default: "1.24.2"
|
|
use-preinstalled-go:
|
|
description: "Whether to use preinstalled Go."
|
|
default: "false"
|
|
use-temp-cache-dirs:
|
|
description: "Whether to use temporary GOCACHE and GOMODCACHE directories."
|
|
default: "false"
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- name: Override GOCACHE and GOMODCACHE
|
|
shell: bash
|
|
if: inputs.use-temp-cache-dirs == 'true'
|
|
run: |
|
|
# cd to another directory to ensure we're not inside a Go project.
|
|
# That'd trigger Go to download the toolchain for that project.
|
|
cd "$RUNNER_TEMP"
|
|
# RUNNER_TEMP should be backed by a RAM disk on Windows if
|
|
# coder/setup-ramdisk-action was used
|
|
export GOCACHE_DIR="$RUNNER_TEMP""\go-cache"
|
|
export GOMODCACHE_DIR="$RUNNER_TEMP""\go-mod-cache"
|
|
export GOPATH_DIR="$RUNNER_TEMP""\go-path"
|
|
export GOTMP_DIR="$RUNNER_TEMP""\go-tmp"
|
|
mkdir -p "$GOCACHE_DIR"
|
|
mkdir -p "$GOMODCACHE_DIR"
|
|
mkdir -p "$GOPATH_DIR"
|
|
mkdir -p "$GOTMP_DIR"
|
|
go env -w GOCACHE="$GOCACHE_DIR"
|
|
go env -w GOMODCACHE="$GOMODCACHE_DIR"
|
|
go env -w GOPATH="$GOPATH_DIR"
|
|
go env -w GOTMPDIR="$GOTMP_DIR"
|
|
- name: Setup Go
|
|
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
|
|
with:
|
|
go-version: ${{ inputs.use-preinstalled-go == 'false' && inputs.version || '' }}
|
|
|
|
- name: Install gotestsum
|
|
shell: bash
|
|
run: go install gotest.tools/gotestsum@3f7ff0ec4aeb6f95f5d67c998b71f272aa8a8b41 # v1.12.1
|
|
|
|
# It isn't necessary that we ever do this, but it helps
|
|
# separate the "setup" from the "run" times.
|
|
- name: go mod download
|
|
shell: bash
|
|
run: go mod download -x
|