mirror of
https://github.com/coder/coder.git
synced 2026-06-05 05:58:20 +00:00
7d558e76e9
Signed-off-by: Danny Kopping <danny@coder.com>
81 lines
2.5 KiB
YAML
81 lines
2.5 KiB
YAML
name: "Test Go with PostgreSQL"
|
|
description: "Run Go tests with PostgreSQL database"
|
|
|
|
inputs:
|
|
postgres-version:
|
|
description: "PostgreSQL version to use"
|
|
required: false
|
|
default: "13"
|
|
test-parallelism-packages:
|
|
description: "Number of packages to test in parallel (-p flag)"
|
|
required: false
|
|
default: "8"
|
|
test-parallelism-tests:
|
|
description: "Number of tests to run in parallel within each package (-parallel flag)"
|
|
required: false
|
|
default: "8"
|
|
race-detection:
|
|
description: "Enable race detection"
|
|
required: false
|
|
default: "false"
|
|
test-count:
|
|
description: "Number of times to run each test (empty for cached results)"
|
|
required: false
|
|
default: ""
|
|
test-packages:
|
|
description: "Packages to test (default: ./...)"
|
|
required: false
|
|
default: "./..."
|
|
embedded-pg-path:
|
|
description: "Path for embedded postgres data (Windows/macOS only)"
|
|
required: false
|
|
default: ""
|
|
embedded-pg-cache:
|
|
description: "Path for embedded postgres cache (Windows/macOS only)"
|
|
required: false
|
|
default: ""
|
|
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- name: Start PostgreSQL Docker container (Linux)
|
|
if: runner.os == 'Linux'
|
|
shell: bash
|
|
env:
|
|
POSTGRES_VERSION: ${{ inputs.postgres-version }}
|
|
run: make test-postgres-docker
|
|
|
|
- name: Setup Embedded Postgres (Windows/macOS)
|
|
if: runner.os != 'Linux'
|
|
shell: bash
|
|
env:
|
|
POSTGRES_VERSION: ${{ inputs.postgres-version }}
|
|
EMBEDDED_PG_PATH: ${{ inputs.embedded-pg-path }}
|
|
EMBEDDED_PG_CACHE_DIR: ${{ inputs.embedded-pg-cache }}
|
|
run: |
|
|
go run scripts/embedded-pg/main.go -path "${EMBEDDED_PG_PATH}" -cache "${EMBEDDED_PG_CACHE_DIR}"
|
|
|
|
- name: Run tests
|
|
shell: bash
|
|
env:
|
|
TEST_NUM_PARALLEL_PACKAGES: ${{ inputs.test-parallelism-packages }}
|
|
TEST_NUM_PARALLEL_TESTS: ${{ inputs.test-parallelism-tests }}
|
|
TEST_COUNT: ${{ inputs.test-count }}
|
|
TEST_PACKAGES: ${{ inputs.test-packages }}
|
|
RACE_DETECTION: ${{ inputs.race-detection }}
|
|
TS_DEBUG_DISCO: "true"
|
|
LC_CTYPE: "en_US.UTF-8"
|
|
LC_ALL: "en_US.UTF-8"
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
if [[ ${RACE_DETECTION} == true ]]; then
|
|
gotestsum --junitfile="gotests.xml" --packages="${TEST_PACKAGES}" -- \
|
|
-tags=testsmallbatch \
|
|
-race \
|
|
-parallel "${TEST_NUM_PARALLEL_TESTS}" \
|
|
-p "${TEST_NUM_PARALLEL_PACKAGES}"
|
|
else
|
|
make test
|
|
fi
|