Skip to content

Commit 4b32208

Browse files
authored
PHPC-2435: Support libmongoc 2.0 (#1829)
* Bump libmongoc to 2.0.1 and libmongocrypt to 1.14.0 This fixes the following issues: * PHPC-2581: Bump to libmongoc 2.0.1 * PHPC-2578: Bump to libmongocrypt 1.14.0 * PHPC-2548: Remove MONGOC_WRITE_CONCERN_W_ERRORS_IGNORED * PHPC-2540: Use const for mongoc_host_list_t * PHPC-2547: Remove MONGOC_NO_AUTOMATIC_GLOBALS * PHPC-2549: Remove BSON_EXTRA_ALIGN * PHPC-1548: Add tests for empty authSource URI option * PHPC-2542: Add test coverage for auth mechanism errors * PHPC-2584: Run driver test with system libraries (#1831) * Add build action to build libmongoc system libraries * Build driver with system libs * Install libmongocrypt as system library * Run tests with system libs * Move system library tests to tests workflow * PHPC-2545: Drop support for compiling with LibreSSL (#1836) * PHPC-2545: Drop support for compiling with LibreSSL * Warn when explicitly building with libressl * Fix usage of wrong version variable * PHPC-2367: Add SSPI SASL, drop Cyrus on Windows (#1837) * Support building with SSPI support under Windows * Remove support for building with Cyrus SASL on Windows * Apply feedback from Copilot * Apply code review feedback * Fix handling of missing SASL libs when relying on default value for with-mongodb-sasl * Apply feedback from code review
1 parent 5d2036e commit 4b32208

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+469
-272
lines changed

.evergreen/compile-unix.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,6 @@ if [ -n "$LIBMONGOC_VERSION" ]; then
7272
echo "Finding Python3 binary... done."
7373

7474
php scripts/update-submodule-sources.php
75-
76-
# We invoke python manually as it may not be in the path
77-
pushd src/libmongoc/
78-
$PYTHON build/calc_release_version.py > ../LIBMONGOC_VERSION_CURRENT
79-
popd
8075
fi
8176

8277
phpize

.evergreen/config/functions.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ functions:
140140
echo "Checking out libmongoc version: ${LIBMONGOC_VERSION}"
141141
git fetch
142142
git checkout ${LIBMONGOC_VERSION}
143-
# Note: compile-unix.sh will run `make libmongoc-version-current`
144143
fi
145144
- command: subprocess.exec
146145
type: test

.evergreen/config/generate-config.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
'4.2',
2222
];
2323

24-
// TODO: Change when PHP 8.4 is stable
25-
// $latestPhpVersion = max($phpVersions);
26-
$latestPhpVersion = '8.3';
24+
$latestPhpVersion = max($phpVersions);
2725

2826
// Only test the latest PHP version for libmongoc
2927
$libmongocBuildPhpVersions = [ $latestPhpVersion ];

.evergreen/config/generated/build/build-libmongoc.yml

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.evergreen/config/generated/test-variant/libmongoc.yml

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.evergreen/config/templates/build/build-libmongoc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
- func: "compile driver"
1111
vars:
1212
PHP_VERSION: "%phpVersion%"
13-
LIBMONGOC_VERSION: "1.30.1"
13+
LIBMONGOC_VERSION: "2.0.1"
1414
- func: "upload build"
1515

1616
- name: "build-php-%phpVersion%-libmongoc-next-stable"
@@ -19,7 +19,7 @@
1919
- func: "compile driver"
2020
vars:
2121
PHP_VERSION: "%phpVersion%"
22-
LIBMONGOC_VERSION: "r1.30"
22+
LIBMONGOC_VERSION: "r2.0"
2323
- func: "upload build"
2424

2525
- name: "build-php-%phpVersion%-libmongoc-latest"
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: "Build libmongoc"
2+
description: "Builds and install libmongoc"
3+
inputs:
4+
prefix:
5+
description: "Prefix to install libmongoc to"
6+
default: "/usr/local"
7+
version:
8+
description: "Libmongoc version to build"
9+
required: true
10+
runs:
11+
using: composite
12+
13+
steps:
14+
- name: Download libmongoc
15+
shell: bash
16+
working-directory: /tmp
17+
run: wget "https://github.com/mongodb/mongo-c-driver/archive/refs/tags/${LIBMONGOC_VERSION}.tar.gz" --output-document="mongo-c-driver.tar.gz"
18+
env:
19+
LIBMONGOC_VERSION: ${{ inputs.version }}
20+
21+
- name: Extract libmongoc
22+
shell: bash
23+
working-directory: /tmp
24+
run: tar xf "mongo-c-driver.tar.gz"
25+
26+
- name: Configure cmake
27+
shell: bash
28+
working-directory: /tmp
29+
run: |
30+
cmake \
31+
-S "mongo-c-driver-${LIBMONGOC_VERSION}" \
32+
-B _build \
33+
-D CMAKE_BUILD_TYPE=RelWithDebInfo \
34+
-D BUILD_VERSION="${LIBMONGOC_VERSION}" \
35+
-D ENABLE_MONGOC=ON \
36+
-D ENABLE_TRACING=ON \
37+
-D ENABLE_CLIENT_SIDE_ENCRYPTION=ON
38+
env:
39+
LIBMONGOC_VERSION: ${{ inputs.version }}
40+
41+
- name: Build libmongoc
42+
shell: bash
43+
working-directory: /tmp
44+
run: cmake --build _build --config RelWithDebInfo --parallel
45+
46+
- name: Install libmongoc
47+
shell: bash
48+
working-directory: /tmp
49+
run: sudo cmake --install _build --prefix "${PREFIX}" --config RelWithDebInfo
50+
env:
51+
PREFIX: ${{ inputs.prefix }}
52+
53+
- name: Check pkg-config availability
54+
shell: bash
55+
run: pkg-config --modversion mongoc2
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: "Build libmongocrypt"
2+
description: "Installs libmongocrypt"
3+
inputs:
4+
version:
5+
description: "Libmongocrypt version to install (major.minor)"
6+
required: true
7+
runs:
8+
using: composite
9+
10+
steps:
11+
- name: Add repository key
12+
shell: bash
13+
run: sudo sh -c 'curl -s --location https://pgp.mongodb.com/libmongocrypt.asc | gpg --dearmor >/etc/apt/trusted.gpg.d/libmongocrypt.gpg'
14+
15+
- name: Add repository
16+
shell: bash
17+
working-directory: /tmp
18+
# Note: no packages for Ubuntu 24.04 noble exist, so we use those for 22.04
19+
run: echo "deb https://libmongocrypt.s3.amazonaws.com/apt/ubuntu jammy/libmongocrypt/${LIBMONGOCRYPT_VERSION} universe" | sudo tee /etc/apt/sources.list.d/libmongocrypt.list
20+
env:
21+
LIBMONGOCRYPT_VERSION: ${{ inputs.version }}
22+
23+
- name: Update apt sources
24+
shell: bash
25+
run: sudo apt-get update
26+
27+
- name: Install libmongocrypt
28+
shell: bash
29+
run: sudo apt-get install -y libmongocrypt-dev

.github/actions/linux/build/action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ inputs:
44
version:
55
description: "PHP version to build for"
66
required: true
7+
configureOpts:
8+
description: "Extra options to use for the call to ./configure"
9+
default: ""
10+
711
runs:
812
using: composite
913
steps:
@@ -17,6 +21,8 @@ runs:
1721
- name: "Configure driver"
1822
run: .github/workflows/configure.sh
1923
shell: bash
24+
env:
25+
CONFIGURE_OPTS: ${{ inputs.configureOpts }}
2026

2127
- name: "Build driver"
2228
run: "make all"

.github/workflows/tests.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,54 @@ jobs:
128128
php: [ "8.1", "8.2", "8.3", "8.4" ]
129129
arch: [ x64, x86 ]
130130
ts: [ ts, nts ]
131+
132+
test-system-libs:
133+
name: "System Library Tests"
134+
runs-on: "ubuntu-latest"
135+
env:
136+
PHP_VERSION: "8.3"
137+
LIBMONGOCRYPT_VERSION: "1.14"
138+
LIBMONGOC_VERSION: "2.0.1"
139+
SERVER_VERSION: "8.0"
140+
141+
steps:
142+
- name: "Checkout"
143+
uses: "actions/checkout@v4"
144+
with:
145+
submodules: true
146+
147+
- name: "Install libmongocrypt"
148+
uses: ./.github/actions/linux/build-libmongocrypt
149+
with:
150+
version: ${{ env.LIBMONGOCRYPT_VERSION }}
151+
152+
- name: "Build libmongoc"
153+
uses: ./.github/actions/linux/build-libmongoc
154+
with:
155+
version: ${{ env.LIBMONGOC_VERSION }}
156+
157+
- name: "Build Driver"
158+
uses: ./.github/actions/linux/build
159+
with:
160+
version: ${{ env.PHP_VERSION }}
161+
configureOpts: "--with-mongodb-system-libs=yes"
162+
163+
- name: "Check driver version"
164+
shell: bash
165+
run: make show-config
166+
167+
- uses: actions/setup-python@v5
168+
with:
169+
python-version: "3.13"
170+
171+
- name: Setup MongoDB
172+
id: setup-mongodb
173+
uses: ./tests/drivers-evergreen-tools
174+
with:
175+
version: ${{ ENV.SERVER_VERSION }}
176+
topology: "server"
177+
178+
- name: "Run Tests"
179+
run: TEST_PHP_ARGS="-q -x --show-diff -g FAIL,XFAIL,BORK,WARN,LEAK,SKIP" make test
180+
env:
181+
MONGODB_URI: ${{ steps.setup-mongodb.outputs.cluster-uri }}

CONTRIBUTING.md

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ always refer to libmongoc.
203203
```shell
204204
cd src/libmongoc
205205
git fetch
206-
git checkout 1.20.0
206+
git checkout 2.1.0
207207
```
208208

209209
During development, it may be necessary to temporarily point the submodule to a
@@ -218,24 +218,16 @@ git submodules set-url src/libmongoc https://github.com/<owner>/<repo>.git
218218
git submodules set-branch -b <branch> src/libmongoc
219219
```
220220

221-
#### Ensure version information is correct
221+
#### Ensure version information is correct (libmongocrypt only)
222222

223-
Various build processes and tools rely on the version files to infer version
224-
information. This file can be regenerated using Makefile targets:
223+
For libmongocrypt, version information needs to be updated after updating to
224+
a newer submodule version. This can be done by running the corresponding make
225+
target:
225226

226227
```shell
227-
make libmongoc-version-current
228+
make libmongocrypt-version-current
228229
```
229230

230-
Alternatively, the `build/calc_release_version.py` script in the submodule can
231-
be executed directly.
232-
233-
Note: If the submodule points to a non-release, non-master branch, the script
234-
may fail to correctly detect the version. This issue is being tracked in
235-
[CDRIVER-3315](https://jira.mongodb.org/browse/CDRIVER-3315) and can be safely ignored since this should only happen
236-
during development (any PHP driver release should point to a tagged submodule
237-
version).
238-
239231
#### Update sources in build configurations
240232

241233
The Autotools and Windows build configurations (`config.m4` and `config.w32`,
@@ -261,11 +253,11 @@ libmongoc and libbson.
261253
For example, the following lines might be updated for libmongoc:
262254

263255
```
264-
if $PKG_CONFIG libmongoc-1.0 --atleast-version 1.20.0; then
256+
if $PKG_CONFIG mongoc2 --atleast-version 2.1.0; then
265257
266258
...
267259
268-
AC_MSG_ERROR(system libmongoc must be upgraded to version >= 1.20.0)
260+
AC_MSG_ERROR(system libmongoc must be upgraded to version >= 2.1.0)
269261
```
270262

271263
#### Update tested versions in Evergreen configuration (libmongoc only)
@@ -277,7 +269,7 @@ information about the build tasks and where they are used. In general, we test
277269
against two additional versions of libmongoc:
278270

279271
- The upcoming patch release of the current libmongoc minor version (e.g. the
280-
`r1.x` branch)
272+
`r2.x` branch)
281273
- The upcoming minor release of libmongoc (e.g. the `master` branch)
282274

283275
#### Update sources in PECL package generation script
@@ -307,5 +299,6 @@ test suite passes. Once done, commit the changes to all of the above
307299
files/paths. For example:
308300

309301
```shell
310-
git commit -m "Bump libmongoc to 1.20.0" config.m4 config.w32 src/libmongoc src/LIBMONGOC_VERSION_CURRENT sbom.json
302+
git commit -m "Bump libmongoc to 2.1.0" config.m4 config.w32 src/libmongoc sbom.
303+
json
311304
```

0 commit comments

Comments
 (0)