Skip to content

PHPC-2584: Run driver test with system libraries #1831

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/actions/linux/build-libmongoc/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
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 \
-D ENABLE_CLIENT_SIDE_ENCRYPTION=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
29 changes: 29 additions & 0 deletions .github/actions/linux/build-libmongocrypt/action.yml
Original file line number Diff line number Diff line change
@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any plans to have one later? If not, it will get complicated when the upgrade to Ubuntu 24.04 is enforced by GitHub.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created MONGOCRYPT-813 for this. Note that I'm already using 24.04 and the PPA works for the time being. Once the ticket is resolved, I'd update this accordingly.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be possible to cache the apt dependency: https://github.com/marketplace/actions/cache-apt-packages

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted for a separate PR.

6 changes: 6 additions & 0 deletions .github/actions/linux/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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"
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
24 changes: 23 additions & 1 deletion Makefile.frag
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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`; \
Expand Down
Loading