-
Notifications
You must be signed in to change notification settings - Fork 214
347 lines (299 loc) · 9.96 KB
/
tests.yml
File metadata and controls
347 lines (299 loc) · 9.96 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
name: "Tests"
on:
pull_request:
branches:
- "v*.*"
- "feature/*"
push:
branches:
- "v*.*"
- "feature/*"
jobs:
linux-test:
name: "Linux Tests"
runs-on: "${{ matrix.os }}"
continue-on-error: ${{ matrix.allow_failures || false }}
strategy:
fail-fast: true
matrix:
os:
- "ubuntu-22.04"
php-version:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
- "8.5"
mongodb-version:
- "6.0"
topology:
- "server"
include:
- os: "ubuntu-24.04"
php-version: "8.1"
mongodb-version: "8.0"
topology: "replica_set"
- os: "ubuntu-24.04"
php-version: "8.1"
mongodb-version: "8.0"
topology: "sharded_cluster"
- os: "ubuntu-22.04"
php-version: "8.1"
mongodb-version: "6.0"
topology: "replica_set"
- os: "ubuntu-22.04"
php-version: "8.1"
mongodb-version: "6.0"
topology: "sharded_cluster"
- os: "ubuntu-24.04"
php-version: "8.6"
mongodb-version: "8.0"
topology: "replica_set"
allow_failures: true
steps:
- name: "Checkout"
uses: "actions/checkout@v6"
with:
submodules: true
- uses: actions/setup-python@v6
with:
python-version: '3.13'
- name: Setup MongoDB
id: setup-mongodb
uses: ./tests/drivers-evergreen-tools
with:
version: ${{ matrix.mongodb-version }}
topology: ${{ matrix.topology }}
- name: "Build Driver"
id: build-driver
uses: ./.github/actions/linux/build
with:
version: ${{ matrix.php-version }}
- name: "Run Tests"
run: make test
env:
TEST_PHP_ARGS: "-q -x --show-diff -g FAIL,XFAIL,BORK,WARN,LEAK,SKIP"
TEST_PHP_JUNIT: "test-results.xml"
MONGODB_URI: ${{ steps.setup-mongodb.outputs.cluster-uri }}
- name: Upload test results to Codecov
uses: codecov/test-results-action@v1
with:
disable_search: true
files: test-results.xml
flags: "${{ matrix.mongodb-version }}-${{ matrix.topology }}"
token: ${{ secrets.CODECOV_TOKEN }}
pecl-test:
name: "Test PECL package"
runs-on: "ubuntu-latest"
env:
PHP_VERSION: "8.3"
steps:
- name: "Checkout"
uses: "actions/checkout@v6"
with:
submodules: true
- name: "Build Driver"
id: build-driver
uses: ./.github/actions/linux/build
with:
version: ${{ env.PHP_VERSION }}
- name: "Write changelog file for packaging"
run: echo "Testing" > changelog
- name: "Build package.xml"
run: "make package.xml RELEASE_NOTES_FILE=$(pwd)/changelog"
- name: "Build PECL package"
run: "make package"
# PECL always uses the version for the package name.
# Read it from the version file and store in env to use when uploading artifacts
- name: "Read current package version"
run: |
PACKAGE_VERSION=$(./bin/update-release-version.php get-version)
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> "$GITHUB_ENV"
echo "PACKAGE_FILE=mongodb-${PACKAGE_VERSION}.tgz" >> "$GITHUB_ENV"
- name: "Install release archive to verify correctness"
run: sudo pecl install ${{ env.PACKAGE_FILE }}
windows-test:
name: "Windows Tests"
runs-on: "${{ matrix.os }}"
defaults:
run:
shell: cmd
strategy:
fail-fast: false
matrix:
os: [ "windows-2022" ]
# Note: keep this in sync with the Windows matrix in build-windows-package.yml
php-version:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
- "8.5"
ts: [ ts, nts ]
steps:
- uses: actions/checkout@v6
with:
submodules: true
- id: setup-mongodb
uses: mongodb-labs/drivers-evergreen-tools@master
with:
version: "7.0"
topology: "server"
- name: "Build and Test"
id: build-driver
uses: ./.github/actions/windows/build
with:
php-version: ${{ matrix.php-version }}
ts: ${{ matrix.ts }}
run-tests: true
env:
NO_INTERACTION: 1
REPORT_EXIT_STATUS: 1
MONGODB_URI: ${{ steps.setup-mongodb.outputs.cluster-uri }}
CRYPT_SHARED_LIB_PATH: ${{ steps.setup-mongodb.outputs.crypt-shared-lib-path }}
test-system-libs:
name: "System Library Tests"
runs-on: "ubuntu-latest"
env:
PHP_VERSION: "8.3"
LIBMONGOCRYPT_VERSION: "1.18.0"
# Note: include the patch version when referring to a libmongoc release tarball
LIBMONGOC_VERSION: "2.3.0"
SERVER_VERSION: "8.0"
steps:
- name: "Checkout"
uses: "actions/checkout@v6"
with:
submodules: true
- name: "Install libmongocrypt"
uses: ./.github/actions/linux/build-libmongocrypt
with:
version: ${{ env.LIBMONGOCRYPT_VERSION }}
- name: "Build libmongoc"
uses: ./.github/actions/linux/build-libmongoc
with:
version: ${{ env.LIBMONGOC_VERSION }}
- name: "Build Driver"
uses: ./.github/actions/linux/build
with:
version: ${{ env.PHP_VERSION }}
configureOpts: "--with-mongodb-system-libs=yes"
- name: "Check driver version"
shell: bash
run: make show-config
- uses: actions/setup-python@v6
with:
python-version: "3.13"
- name: Setup MongoDB
id: setup-mongodb
uses: ./tests/drivers-evergreen-tools
with:
version: ${{ env.SERVER_VERSION }}
topology: "server"
- name: "Run Tests"
run: make test
env:
TEST_PHP_ARGS: "-q -x --show-diff -g FAIL,XFAIL,BORK,WARN,LEAK,SKIP"
TEST_PHP_JUNIT: "test-results.xml"
MONGODB_URI: ${{ steps.setup-mongodb.outputs.cluster-uri }}
- name: Upload test results to Codecov
uses: codecov/test-results-action@v1
with:
disable_search: true
files: test-results.xml
flags: "${{ env.SERVER_VERSION }}-server"
token: ${{ secrets.CODECOV_TOKEN }}
# Verifies that the extension can be compiled statically into PHP (i.e. with
# --enable-mongodb instead of --enable-mongodb=shared), as done by projects
# like StaticPHP. This exercises the PHP in-tree build path where configure
# is invoked from the PHP source root rather than the extension directory.
# Two modes are tested:
# in-source — configure and build run from the PHP source directory
# (PHP source dir = PHP build dir, layout 3)
# out-of-source — configure and build run from a separate build directory
# (PHP source dir ≠ PHP build dir, layout 4)
test-in-tree-build:
name: "Static PHP Build (${{ matrix.mode }})"
runs-on: "ubuntu-latest"
env:
PHP_VERSION: "8.5.5"
strategy:
matrix:
mode: ['in-source', 'out-of-source']
steps:
- name: "Checkout"
uses: "actions/checkout@v6"
with:
submodules: true
path: "mongo-php-driver"
- name: "Install build dependencies"
run: |
sudo apt-get update -q
sudo apt-get install -y \
autoconf \
bison \
libsqlite3-dev \
libssl-dev \
libxml2-dev \
pkg-config \
re2c
- name: "Download PHP ${{ env.PHP_VERSION }} source"
run: |
curl -fsSL "https://www.php.net/distributions/php-${{ env.PHP_VERSION }}.tar.gz" | tar -xz
mv "php-${{ env.PHP_VERSION }}" php-src
- name: "Link extension into PHP source tree"
run: ln -s "$GITHUB_WORKSPACE/mongo-php-driver" "$GITHUB_WORKSPACE/php-src/ext/mongodb"
- name: "Generate PHP build scripts"
run: cd "$GITHUB_WORKSPACE/php-src" && ./buildconf --force
- name: "Set build directory"
run: |
if [ "${{ matrix.mode }}" = "out-of-source" ]; then
mkdir -p /tmp/php-build
echo "PHP_BUILD_DIR=/tmp/php-build" >> "$GITHUB_ENV"
elif [ "${{ matrix.mode }}" = "in-source" ]; then
echo "PHP_BUILD_DIR=$GITHUB_WORKSPACE/php-src" >> "$GITHUB_ENV"
else
echo "Invalid mode"
exit 1
fi
# Note: --with-openssl is needed for the bundled libmongoc's TLS support.
- name: "Configure PHP with MongoDB extension (static)"
run: |
[ -n "$PHP_BUILD_DIR" ] || { echo "PHP_BUILD_DIR is not set"; exit 1; }
"$GITHUB_WORKSPACE/php-src/configure" \
--enable-debug \
--enable-cli \
--enable-mongodb \
--enable-mongodb-developer-flags \
--with-openssl
working-directory: ${{ env.PHP_BUILD_DIR }}
- name: "Build PHP"
run: make -j$(nproc)
working-directory: ${{ env.PHP_BUILD_DIR }}
- name: "Verify MongoDB extension is compiled in"
run: |
"$PHP_BUILD_DIR/sapi/cli/php" -m | grep -ix mongodb
"$PHP_BUILD_DIR/sapi/cli/php" --ri mongodb
test-out-of-source-build:
name: "Out-of-source Build"
runs-on: "ubuntu-latest"
env:
PHP_VERSION: "8.5"
steps:
- name: "Checkout"
uses: "actions/checkout@v6"
with:
submodules: true
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ env.PHP_VERSION }}-debug"
extensions: "none,date,json,spl,standard,xml"
- name: "phpize"
run: phpize
- name: "Build driver (out-of-source)"
run: |
mkdir -p /tmp/mongodb-build
cd /tmp/mongodb-build
${GITHUB_WORKSPACE}/configure --enable-mongodb-developer-flags
make all