From 45dc64180cb48aefc42b5a1ef69b1f4af1865044 Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Thu, 22 May 2025 10:34:44 +0200 Subject: [PATCH 1/5] Add build action to build libmongoc system libraries --- .../actions/linux/build-libmongoc/action.yml | 54 +++++++++++++++++++ .github/workflows/system-libs.yml | 23 ++++++++ 2 files changed, 77 insertions(+) create mode 100644 .github/actions/linux/build-libmongoc/action.yml create mode 100644 .github/workflows/system-libs.yml diff --git a/.github/actions/linux/build-libmongoc/action.yml b/.github/actions/linux/build-libmongoc/action.yml new file mode 100644 index 000000000..c70b9b952 --- /dev/null +++ b/.github/actions/linux/build-libmongoc/action.yml @@ -0,0 +1,54 @@ +name: "Build libmongoc" +description: "Builds and install libmongoc" +inputs: + prefix: + description: "Prefix to install libmongoc to" + default: "/usr/local" + version: + description: "Libmongoc version to build" + required: true +runs: + using: composite + + steps: + - name: Download libmongoc + shell: bash + working-directory: /tmp + run: wget "https://github.com/mongodb/mongo-c-driver/archive/refs/tags/${LIBMONGOC_VERSION}.tar.gz" --output-document="mongo-c-driver.tar.gz" + env: + LIBMONGOC_VERSION: ${{ inputs.version }} + + - name: Extract libmongoc + shell: bash + working-directory: /tmp + run: tar xf "mongo-c-driver.tar.gz" + + - name: Configure cmake + shell: bash + working-directory: /tmp + run: | + cmake \ + -S "mongo-c-driver-${LIBMONGOC_VERSION}" \ + -B _build \ + -D CMAKE_BUILD_TYPE=RelWithDebInfo \ + -D BUILD_VERSION="${LIBMONGOC_VERSION}" \ + -D ENABLE_MONGOC=ON \ + -D ENABLE_TRACING=ON + env: + LIBMONGOC_VERSION: ${{ inputs.version }} + + - name: Build libmongoc + shell: bash + working-directory: /tmp + run: cmake --build _build --config RelWithDebInfo --parallel + + - name: Install libmongoc + shell: bash + working-directory: /tmp + run: sudo cmake --install _build --prefix "${PREFIX}" --config RelWithDebInfo + env: + PREFIX: ${{ inputs.prefix }} + + - name: Check pkg-config availability + shell: bash + run: pkg-config --modversion mongoc2 diff --git a/.github/workflows/system-libs.yml b/.github/workflows/system-libs.yml new file mode 100644 index 000000000..a680b7f82 --- /dev/null +++ b/.github/workflows/system-libs.yml @@ -0,0 +1,23 @@ +name: "System library tests" + +on: + push: + branches: + - "build-system-libs" + +jobs: + tests: + name: "Build" + runs-on: "ubuntu-24.04" + + steps: + - name: "Checkout" + uses: "actions/checkout@v4" + with: + submodules: true + + - name: "Build libmongoc" + id: build-libmongoc + uses: ./.github/actions/linux/build-libmongoc + with: + version: 2.0.1 From 4cf84bd3c4ee85345eaf30cf7f435fddb57580b4 Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Thu, 22 May 2025 11:32:16 +0200 Subject: [PATCH 2/5] Build driver with system libs --- .github/actions/linux/build/action.yml | 6 ++++++ .github/workflows/system-libs.yml | 11 +++++++++++ Makefile.frag | 24 +++++++++++++++++++++++- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/.github/actions/linux/build/action.yml b/.github/actions/linux/build/action.yml index a66462268..20378e2a7 100644 --- a/.github/actions/linux/build/action.yml +++ b/.github/actions/linux/build/action.yml @@ -4,6 +4,10 @@ inputs: version: description: "PHP version to build for" required: true + configureOpts: + description: "Extra options to use for the call to ./configure" + default: "" + runs: using: composite steps: @@ -17,6 +21,8 @@ runs: - name: "Configure driver" run: .github/workflows/configure.sh shell: bash + env: + CONFIGURE_OPTS: ${{ inputs.configureOpts }} - name: "Build driver" run: "make all" diff --git a/.github/workflows/system-libs.yml b/.github/workflows/system-libs.yml index a680b7f82..fb8886ffe 100644 --- a/.github/workflows/system-libs.yml +++ b/.github/workflows/system-libs.yml @@ -21,3 +21,14 @@ jobs: uses: ./.github/actions/linux/build-libmongoc with: version: 2.0.1 + + - name: "Build Driver" + id: build-driver + uses: ./.github/actions/linux/build + with: + version: "8.4" + configureOpts: "--with-mongodb-system-libs=yes" + + - name: "Check driver version" + shell: bash + run: make show-config diff --git a/Makefile.frag b/Makefile.frag index c1f83b808..46eb786af 100644 --- a/Makefile.frag +++ b/Makefile.frag @@ -1,4 +1,4 @@ -.PHONY: mv-coverage lcov-coveralls lcov-local coverage coveralls format format-changed format-check test-clean package package.xml libmongocrypt-version-current generate-function-map +.PHONY: mv-coverage lcov-coveralls lcov-local coverage coveralls format format-changed format-check test-clean package package.xml libmongocrypt-version-current generate-function-map show-config ifneq (,$(realpath $(EXTENSION_DIR)/json.so)) PHP_TEST_SHARED_EXTENSIONS := "-d" "extension=$(EXTENSION_DIR)/json.so" $(PHP_TEST_SHARED_EXTENSIONS) @@ -88,6 +88,28 @@ generate-function-map: all echo "ERROR: Cannot generate function maps without CLI sapi."; \ fi +show-config: all + @if test ! -z "$(PHP_EXECUTABLE)" && test -x "$(PHP_EXECUTABLE)"; then \ + INI_FILE=`$(PHP_EXECUTABLE) -d 'display_errors=stderr' -r 'echo php_ini_loaded_file();' 2> /dev/null`; \ + if test "$$INI_FILE"; then \ + $(EGREP) -h -v $(PHP_DEPRECATED_DIRECTIVES_REGEX) "$$INI_FILE" > $(top_builddir)/tmp-php.ini; \ + else \ + echo > $(top_builddir)/tmp-php.ini; \ + fi; \ + INI_SCANNED_PATH=`$(PHP_EXECUTABLE) -d 'display_errors=stderr' -r '$$a = explode(",\n", trim(php_ini_scanned_files())); echo $$a[0];' 2> /dev/null`; \ + if test "$$INI_SCANNED_PATH"; then \ + INI_SCANNED_PATH=`$(top_srcdir)/build/shtool path -d $$INI_SCANNED_PATH`; \ + $(EGREP) -h -v $(PHP_DEPRECATED_DIRECTIVES_REGEX) "$$INI_SCANNED_PATH"/*.ini >> $(top_builddir)/tmp-php.ini; \ + fi; \ + CC="$(CC)" \ + $(PHP_EXECUTABLE) -n -c $(top_builddir)/tmp-php.ini -d extension_dir=$(top_builddir)/modules/ $(PHP_TEST_SHARED_EXTENSIONS) --ri mongodb; \ + RESULT_EXIT_CODE=$$?; \ + rm $(top_builddir)/tmp-php.ini; \ + exit $$RESULT_EXIT_CODE; \ + else \ + echo "ERROR: Cannot show config without CLI sapi."; \ + fi + test-no-build: @if test ! -z "$(PHP_EXECUTABLE)" && test -x "$(PHP_EXECUTABLE)"; then \ INI_FILE=`$(PHP_EXECUTABLE) -d 'display_errors=stderr' -r 'echo php_ini_loaded_file();' 2> /dev/null`; \ From 7d9140e155bbb921829dd46b426c325f0f42e19e Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Thu, 22 May 2025 14:33:50 +0200 Subject: [PATCH 3/5] Install libmongocrypt as system library --- .../actions/linux/build-libmongoc/action.yml | 3 +- .../linux/build-libmongocrypt/action.yml | 29 +++++++++++++++++++ .github/workflows/system-libs.yml | 7 +++-- 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 .github/actions/linux/build-libmongocrypt/action.yml diff --git a/.github/actions/linux/build-libmongoc/action.yml b/.github/actions/linux/build-libmongoc/action.yml index c70b9b952..6a804078a 100644 --- a/.github/actions/linux/build-libmongoc/action.yml +++ b/.github/actions/linux/build-libmongoc/action.yml @@ -33,7 +33,8 @@ runs: -D CMAKE_BUILD_TYPE=RelWithDebInfo \ -D BUILD_VERSION="${LIBMONGOC_VERSION}" \ -D ENABLE_MONGOC=ON \ - -D ENABLE_TRACING=ON + -D ENABLE_TRACING=ON \ + -D ENABLE_CLIENT_SIDE_ENCRYPTION=ON env: LIBMONGOC_VERSION: ${{ inputs.version }} diff --git a/.github/actions/linux/build-libmongocrypt/action.yml b/.github/actions/linux/build-libmongocrypt/action.yml new file mode 100644 index 000000000..04c12509e --- /dev/null +++ b/.github/actions/linux/build-libmongocrypt/action.yml @@ -0,0 +1,29 @@ +name: "Build libmongocrypt" +description: "Installs libmongocrypt" +inputs: + version: + description: "Libmongocrypt version to install (major.minor)" + required: true +runs: + using: composite + + steps: + - name: Add repository key + shell: bash + run: sudo sh -c 'curl -s --location https://pgp.mongodb.com/libmongocrypt.asc | gpg --dearmor >/etc/apt/trusted.gpg.d/libmongocrypt.gpg' + + - name: Add repository + shell: bash + working-directory: /tmp + # Note: no packages for Ubuntu 24.04 noble exist, so we use those for 22.04 + run: echo "deb https://libmongocrypt.s3.amazonaws.com/apt/ubuntu jammy/libmongocrypt/${LIBMONGOCRYPT_VERSION} universe" | sudo tee /etc/apt/sources.list.d/libmongocrypt.list + env: + LIBMONGOCRYPT_VERSION: ${{ inputs.version }} + + - name: Update apt sources + shell: bash + run: sudo apt-get update + + - name: Install libmongocrypt + shell: bash + run: sudo apt-get install -y libmongocrypt-dev diff --git a/.github/workflows/system-libs.yml b/.github/workflows/system-libs.yml index fb8886ffe..8fd4b82c3 100644 --- a/.github/workflows/system-libs.yml +++ b/.github/workflows/system-libs.yml @@ -16,14 +16,17 @@ jobs: with: submodules: true + - name: "Install libmongocrypt" + uses: ./.github/actions/linux/build-libmongocrypt + with: + version: 1.14 + - name: "Build libmongoc" - id: build-libmongoc uses: ./.github/actions/linux/build-libmongoc with: version: 2.0.1 - name: "Build Driver" - id: build-driver uses: ./.github/actions/linux/build with: version: "8.4" From e026311980023309a2015c33b6d269a4035f5699 Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Thu, 22 May 2025 15:45:25 +0200 Subject: [PATCH 4/5] Run tests with system libs --- .github/workflows/system-libs.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/system-libs.yml b/.github/workflows/system-libs.yml index 8fd4b82c3..e5acf3165 100644 --- a/.github/workflows/system-libs.yml +++ b/.github/workflows/system-libs.yml @@ -35,3 +35,19 @@ jobs: - name: "Check driver version" shell: bash run: make show-config + + - uses: actions/setup-python@v5 + with: + python-version: "3.13" + + - name: Setup MongoDB + id: setup-mongodb + uses: ./tests/drivers-evergreen-tools + with: + version: "8.0" + topology: "server" + + - name: "Run Tests" + run: TEST_PHP_ARGS="-q -x --show-diff -g FAIL,XFAIL,BORK,WARN,LEAK,SKIP" make test + env: + MONGODB_URI: ${{ steps.setup-mongodb.outputs.cluster-uri }} From 99494853afbd608d51ad87c4cb9c7674aefb49b6 Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Fri, 23 May 2025 09:10:56 +0200 Subject: [PATCH 5/5] Move system library tests to tests workflow --- .github/workflows/system-libs.yml | 53 ------------------------------- .github/workflows/tests.yml | 51 +++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 53 deletions(-) delete mode 100644 .github/workflows/system-libs.yml diff --git a/.github/workflows/system-libs.yml b/.github/workflows/system-libs.yml deleted file mode 100644 index e5acf3165..000000000 --- a/.github/workflows/system-libs.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: "System library tests" - -on: - push: - branches: - - "build-system-libs" - -jobs: - tests: - name: "Build" - runs-on: "ubuntu-24.04" - - steps: - - name: "Checkout" - uses: "actions/checkout@v4" - with: - submodules: true - - - name: "Install libmongocrypt" - uses: ./.github/actions/linux/build-libmongocrypt - with: - version: 1.14 - - - name: "Build libmongoc" - uses: ./.github/actions/linux/build-libmongoc - with: - version: 2.0.1 - - - name: "Build Driver" - uses: ./.github/actions/linux/build - with: - version: "8.4" - configureOpts: "--with-mongodb-system-libs=yes" - - - name: "Check driver version" - shell: bash - run: make show-config - - - uses: actions/setup-python@v5 - with: - python-version: "3.13" - - - name: Setup MongoDB - id: setup-mongodb - uses: ./tests/drivers-evergreen-tools - with: - version: "8.0" - topology: "server" - - - name: "Run Tests" - run: TEST_PHP_ARGS="-q -x --show-diff -g FAIL,XFAIL,BORK,WARN,LEAK,SKIP" make test - env: - MONGODB_URI: ${{ steps.setup-mongodb.outputs.cluster-uri }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ac706fa3e..29c74c922 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -128,3 +128,54 @@ jobs: php: [ "8.1", "8.2", "8.3", "8.4" ] arch: [ x64, x86 ] ts: [ ts, nts ] + + test-system-libs: + name: "System Library Tests" + runs-on: "ubuntu-latest" + env: + PHP_VERSION: "8.3" + LIBMONGOCRYPT_VERSION: "1.14" + LIBMONGOC_VERSION: "2.0.1" + SERVER_VERSION: "8.0" + + steps: + - name: "Checkout" + uses: "actions/checkout@v4" + 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@v5 + 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: TEST_PHP_ARGS="-q -x --show-diff -g FAIL,XFAIL,BORK,WARN,LEAK,SKIP" make test + env: + MONGODB_URI: ${{ steps.setup-mongodb.outputs.cluster-uri }}