-
Notifications
You must be signed in to change notification settings - Fork 2.3k
199 lines (168 loc) · 6.26 KB
/
unit_test.yml
File metadata and controls
199 lines (168 loc) · 6.26 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
name: Unit Test
on:
push:
branches:
- "main"
- "release-[0-9]+.[0-9]"
tags: "**"
pull_request:
branches: "**"
concurrency:
group: format('{0}-{1}', ${{ github.ref }}, 'Unit Test')
cancel-in-progress: true
permissions: read-all
env:
LAUNCHABLE_ORGANIZATION: "vitess"
LAUNCHABLE_WORKSPACE: "vitess-app"
GITHUB_PR_HEAD_SHA: "${{ github.event.pull_request.head.sha }}"
jobs:
test:
timeout-minutes: ${{ matrix.race && 45 || 30 }}
strategy:
fail-fast: false
matrix:
include:
# mysql57 tests
- platform: mysql57
evalengine: "0"
flavor: mysql-5.7
java: true
- platform: mysql57
evalengine: "1"
flavor: mysql-5.7
# mysql80 tests
- platform: mysql80
evalengine: "0"
flavor: mysql-8.0
java: true
- platform: mysql80
evalengine: "1"
flavor: mysql-8.0
# mysql84 tests
- platform: mysql84
evalengine: "0"
flavor: mysql-8.4
java: true
- platform: mysql84
evalengine: "1"
flavor: mysql-8.4
# Race tests (mysql80 only)
- platform: mysql80
evalengine: "0"
flavor: mysql-8.0
java: true
race: true
- platform: mysql80
evalengine: "1"
flavor: mysql-8.0
race: true
name: "Unit Test (${{ matrix.race && (matrix.evalengine == '1' && 'Evalengine_' || '') || (matrix.evalengine == '1' && 'evalengine_' || '') }}${{ matrix.race && 'Race' || matrix.platform }})"
runs-on: ${{ matrix.race && github.repository == 'vitessio/vitess' && 'oracle-vm-16cpu-64gb-x86-64' || 'ubuntu-24.04' }}
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
with:
egress-policy: audit
- name: Skip CI
run: |
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'Skip CI') }}" == "true" ]]; then
echo "skipping CI due to the 'Skip CI' label"
exit 1
fi
- name: Check out code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: "false"
- name: Check for changes in relevant files
uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
id: changes
with:
token: ""
filters: |
unit_tests:
- 'test/config.json'
- 'go/**'
- 'test.go'
- 'Makefile'
- 'build.env'
- 'go.sum'
- 'go.mod'
- 'proto/*.proto'
- 'tools/**'
- 'config/**'
- 'bootstrap.sh'
- '.github/workflows/unit_test.yml'
- name: Set up Go
if: steps.changes.outputs.unit_tests == 'true'
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: go.mod
cache: ${{ (github.base_ref == 'main' || (github.base_ref == '' && github.ref_name == 'main')) && 'true' || 'false' }}
- name: Set up python
if: steps.changes.outputs.unit_tests == 'true'
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
- name: Tune the OS
if: steps.changes.outputs.unit_tests == 'true'
timeout-minutes: 5
uses: ./.github/actions/tune-os
- name: Setup MySQL
if: steps.changes.outputs.unit_tests == 'true'
timeout-minutes: 8
uses: ./.github/actions/setup-mysql
with:
flavor: ${{ matrix.flavor }}
- name: Get dependencies
if: steps.changes.outputs.unit_tests == 'true'
timeout-minutes: 5
run: |
export DEBIAN_FRONTEND="noninteractive"
sudo apt-get install -y make unzip g++ curl git wget ${{ matrix.java && 'ant default-jre-headless' || '' }}
go mod download
go install golang.org/x/tools/cmd/goimports@v0.39.0
- name: Run make tools
if: steps.changes.outputs.unit_tests == 'true'
timeout-minutes: 10
run: |
make BUILD_JAVA=${{ matrix.java && '1' || '0' }} BUILD_PROTOC=0 tools
- name: Setup launchable dependencies
if: |
github.event_name == 'pull_request' &&
github.event.pull_request.draft == false &&
steps.changes.outputs.unit_tests == 'true' &&
github.base_ref == 'main'
run: |
pip3 install --user launchable~=1.0 > /dev/null
launchable verify || true
launchable record build --name "$GITHUB_RUN_ID" --no-commit-collection --source .
- name: Run test
if: steps.changes.outputs.unit_tests == 'true'
run: |
set -exo pipefail
export VTDATAROOT="/tmp/"
export NOVTADMINBUILD=1
export VT_GO_PARALLEL_VALUE=$(nproc)
export VTEVALENGINETEST="${{ matrix.evalengine }}"
export CI_DB_PLATFORM="${{ matrix.platform }}"
JUNIT_OUTPUT=report.xml JSON_OUTPUT=report.json make ${{ matrix.race && 'unit_test_race' || 'unit_test' }}
- name: Record test results in launchable
if: |
github.event_name == 'pull_request' &&
github.event.pull_request.draft == false &&
steps.changes.outputs.unit_tests == 'true' &&
github.base_ref == 'main' &&
!cancelled()
run: |
launchable record tests --build "$GITHUB_RUN_ID" go-test . || true
- name: Test Summary
if: steps.changes.outputs.unit_tests == 'true' && failure()
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4
with:
paths: "report.xml"
show: "fail"
- name: Slowest Tests
if: steps.changes.outputs.unit_tests == 'true' && !cancelled()
run: |
echo '## Slowest Tests' >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
go tool gotestsum tool slowest --num 20 --jsonfile report.json | tee -a "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"