Repository navigation
159 lines (151 loc) · 5.59 KB
/
Copy pathpr-tests.yml
File metadata and controls
159 lines (151 loc) · 5.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# Runs the unit test shards on PRs.
#
# The test logic lives in the composite action .github/actions/unit-tests;
# only the matrix lives here.
name: Run tests on PRs
on:
workflow_call:
inputs:
run-tests:
type: boolean
description: "Whether to run unit tests"
required: false
default: true
permissions:
contents: read
jobs:
run-tests:
name: Run unit test shards
if: ${{ inputs.run-tests == true }}
# Shards that only need Docker run on Blacksmith. The orchestrator shard
# stays on infra-tests: it needs modprobe nbd and /dev/kvm (smoketest).
runs-on: ${{ matrix.runner }}
env:
GIN_MODE: test
# Parallel `go test ./...` binaries derive the same Ryuk session id
# and race on `reaper_<hash>` creation. Disable Ryuk; t.Cleanup
# handles normal exit, and every shard runs on a fresh VM, so
# containers left by an abnormal exit die with it.
TESTCONTAINERS_RYUK_DISABLED: "true"
# The shards that set postgres share one server: each test copies its
# own database from a migrated template on it.
PG_TEST_DATABASE_URL: ${{ matrix.postgres && 'postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable' || '' }}
# The shards that set redis share one server: each test's client
# namespaces its keys (go.segfaultmedaddy.com/redistest).
REDIS_TEST_DATABASE_URL: ${{ matrix.redis && 'redis://localhost:6379/0' || '' }}
# Service containers take no server flags, so the settings go in through
# POSTGRES_INITDB_ARGS, which writes them into postgresql.conf. Durability
# is traded for speed, and max_connections covers the parallel tests of
# every package go test runs at once. An empty image skips the service.
services:
postgres:
image: ${{ matrix.postgres && 'postgres:18-alpine' || '' }}
env:
POSTGRES_PASSWORD: postgres
POSTGRES_INITDB_ARGS: >-
--no-sync
-c max_connections=500
-c fsync=off
-c synchronous_commit=off
-c full_page_writes=off
ports:
- 5432:5432
options: >-
--tmpfs /var/lib/postgresql
--health-cmd "pg_isready --host 127.0.0.1 --username postgres"
--health-interval 2s
--health-start-period 30s
--health-start-interval 200ms
--health-timeout 5s
--health-retries 30
redis:
image: ${{ matrix.redis && 'redis:8-alpine' || '' }}
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 2s
--health-start-period 30s
--health-start-interval 200ms
--health-timeout 5s
--health-retries 30
strategy:
matrix:
include:
- package: packages/api
test_path: ./...
postgres: true
redis: true
sudo: false
runner: blacksmith-4vcpu-ubuntu-2404
- package: packages/client-proxy
test_path: ./...
redis: true
sudo: false
runner: blacksmith-4vcpu-ubuntu-2404
# The batcher, event and host-stats helpers, and the guard that keeps
# the embedded migrations equal to the directory. The module had no
# unit shard before this entry.
- package: packages/clickhouse
test_path: ./...
sudo: false
runner: blacksmith-4vcpu-ubuntu-2404
- package: packages/db
test_path: ./...
postgres: true
sudo: false
runner: blacksmith-4vcpu-ubuntu-2404
# envd mounts via bindfs (FUSE, no modprobe); this shard doubles as
# the FUSE-on-Blacksmith canary — if it fails, pin it back to
# infra-tests.
- package: packages/envd
test_path: ./...
sudo: true
runner: blacksmith-4vcpu-ubuntu-2404
# The database seed: the key-resolution table and one Postgres-backed
# run on the shared server.
- package: packages/local-dev
test_path: ./...
postgres: true
sudo: false
runner: blacksmith-4vcpu-ubuntu-2404
# The one shard whose code carries cross-goroutine ownership
# invariants (network slot pool, netns state) — race-checked.
- package: packages/orchestrator
test_path: ./...
sudo: true
race: true
runner: infra-tests
- package: packages/shared
test_path: ./pkg/...
redis: true
sudo: false
runner: blacksmith-4vcpu-ubuntu-2404
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Run unit tests
uses: ./.github/actions/unit-tests
with:
package: ${{ matrix.package }}
test-path: ${{ matrix.test_path }}
sudo: ${{ matrix.sudo }}
race: ${{ matrix.race || false }}
unit_tests:
needs: run-tests
if: ${{ always() }}
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Aggregate unit test result
run: |
if [[ "${{ inputs.run-tests }}" != "true" ]]; then
echo "unit tests skipped because test inputs did not change"
exit 0
fi
if [[ "${{ needs.run-tests.result }}" != "success" ]]; then
echo "unit tests result: ${{ needs.run-tests.result }}"
exit 1
fi
echo "all unit test shards succeeded"