Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
72 changes: 72 additions & 0 deletions .github/actions/setup-php/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Setup PHP with MongoDB extension
description: Resolve the latest stable mongodb PHP extension for the requested major, install PHP with a cached build of that extension.

inputs:
php-version:
description: PHP version (e.g. 8.4)
required: true
driver:
description: Major version of the mongodb extension to install (1 or 2)
required: true
extensions:
description: Comma-separated list of extra PHP extensions to install alongside mongodb (the mongodb extension is appended automatically)
required: false
default: ''
coverage:
description: Coverage driver passed to shivammathur/setup-php (e.g. xdebug, none)
required: false
default: none
tools:
description: Tools passed to shivammathur/setup-php
required: false
default: composer

outputs:
extension-version:
description: Resolved mongodb extension version (e.g. 2.3.3)
value: ${{ steps.resolve.outputs.version }}

runs:
using: composite
steps:
- name: Resolve latest mongodb extension release
id: resolve
shell: bash
env:
GH_TOKEN: ${{ github.token }}
DRIVER_MAJOR: ${{ inputs.driver }}
run: |
set -euo pipefail
version=$(gh api repos/mongodb/mongo-php-driver/releases \
--jq "[.[] | select(.prerelease==false) | .tag_name | select(startswith(\"${DRIVER_MAJOR}.\"))] | .[0] // empty")
Comment thread
GromNaN marked this conversation as resolved.
Outdated
if [ -z "${version}" ]; then
echo "Could not resolve latest mongodb extension for major ${DRIVER_MAJOR}" >&2
exit 1
fi
echo "Resolved mongodb-${version}"
echo "version=${version}" >> "$GITHUB_OUTPUT"
echo "spec=mongodb-${version}" >> "$GITHUB_OUTPUT"

- name: Setup cache environment
id: extcache
uses: shivammathur/cache-extensions@v1
Comment thread
GromNaN marked this conversation as resolved.
with:
php-version: ${{ inputs.php-version }}
extensions: ${{ steps.resolve.outputs.spec }}
key: extcache-php${{ inputs.php-version }}-${{ steps.resolve.outputs.spec }}

- name: Cache extensions
uses: actions/cache@v6
Comment thread
GromNaN marked this conversation as resolved.
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}

- name: Install PHP
uses: shivammathur/setup-php@v2
Comment thread
GromNaN marked this conversation as resolved.
with:
php-version: ${{ inputs.php-version }}
extensions: ${{ inputs.extensions != '' && format('{0},{1}', inputs.extensions, steps.resolve.outputs.spec) || steps.resolve.outputs.spec }}

coverage: ${{ inputs.coverage }}
tools: ${{ inputs.tools }}
20 changes: 4 additions & 16 deletions .github/workflows/build-ci-atlas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ on:
- '[0-9]+.[0-9x]+'
- feature/*

env:
MONGODB_EXT_V1: mongodb-1.21.0
MONGODB_EXT_V2: stable

jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -50,21 +46,13 @@ jobs:
sleep 1
done

- name: Setup cache environment
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php }}
extensions: ${{ matrix.driver == 1 && env.MONGODB_EXT_V1 || env.MONGODB_EXT_V2 }}
key: extcache-v1

- name: Installing php
uses: shivammathur/setup-php@v2
- name: Setup PHP with MongoDB extension
uses: ./.github/actions/setup-php
with:
php-version: ${{ matrix.php }}
extensions: curl,mbstring,xdebug,${{ matrix.driver == 1 && env.MONGODB_EXT_V1 || env.MONGODB_EXT_V2 }}
driver: ${{ matrix.driver }}
extensions: curl,mbstring,xdebug
coverage: xdebug
tools: composer

- name: Show Docker version
if: ${{ runner.debug }}
Expand Down
20 changes: 4 additions & 16 deletions .github/workflows/build-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ on:
- '[0-9]+.[0-9x]+'
- feature/*

env:
MONGODB_EXT_V1: mongodb-1.21.0
MONGODB_EXT_V2: stable

jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -69,21 +65,13 @@ jobs:
if [ "${{ matrix.mongodb }}" = "4.4" ]; then MONGOSH_BIN="mongo"; else MONGOSH_BIN="mongosh"; fi
docker exec --tty mongodb $MONGOSH_BIN --eval "db.runCommand({ serverStatus: 1 })"

- name: Setup cache environment
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php }}
extensions: ${{ matrix.driver == 1 && env.MONGODB_EXT_V1 || env.MONGODB_EXT_V2 }}
key: extcache-v1

- name: Installing php
uses: shivammathur/setup-php@v2
- name: Setup PHP with MongoDB extension
uses: ./.github/actions/setup-php
with:
php-version: ${{ matrix.php }}
extensions: curl,mbstring,xdebug,${{ matrix.driver == 1 && env.MONGODB_EXT_V1 || env.MONGODB_EXT_V2 }}
driver: ${{ matrix.driver }}
extensions: curl,mbstring,xdebug
coverage: xdebug
tools: composer

- name: Show Docker version
if: ${{ runner.debug }}
Expand Down
23 changes: 3 additions & 20 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ on:

env:
PHP_VERSION: '8.4'
DRIVER_VERSION: stable

jobs:
phpcs:
Expand All @@ -27,27 +26,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v7

- name: Setup cache environment
id: extcache
uses: shivammathur/cache-extensions@v1
- name: Setup PHP with MongoDB extension
uses: ./.github/actions/setup-php
with:
php-version: ${{ env.PHP_VERSION }}
extensions: mongodb-${{ env.DRIVER_VERSION }}
key: extcache-v1

- name: Cache extensions
uses: actions/cache@v6
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
coverage: none
extensions: mongodb-${{ env.DRIVER_VERSION }}
php-version: ${{ env.PHP_VERSION }}
driver: 2
tools: cs2pr
Comment thread
GromNaN marked this conversation as resolved.

- name: Show driver information
Expand Down
22 changes: 4 additions & 18 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ on:
type: string
required: true

env:
PHP_VERSION: '8.5'
DRIVER_VERSION: stable
MONGODB_EXT_V1: mongodb-1.21.0
MONGODB_EXT_V2: mongodb-mongodb/mongo-php-driver@v2.x

jobs:
phpstan:
name: PHP/${{ matrix.php }} Driver/${{ matrix.driver }}
Expand All @@ -46,21 +40,13 @@ jobs:
run: |
echo CHECKED_OUT_SHA=$(git rev-parse HEAD) >> $GITHUB_ENV

- name: Setup cache environment
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php }}
extensions: ${{ matrix.driver == 1 && env.MONGODB_EXT_V1 || env.MONGODB_EXT_V2 }}
key: extcache-v1

- name: Setup PHP
uses: shivammathur/setup-php@v2
- name: Setup PHP with MongoDB extension
uses: ./.github/actions/setup-php
with:
php-version: ${{ matrix.php }}
extensions: curl,mbstring,${{ matrix.driver == 1 && env.MONGODB_EXT_V1 || env.MONGODB_EXT_V2 }}
driver: ${{ matrix.driver }}
extensions: curl,mbstring
tools: composer:v2
coverage: none

- name: Cache dependencies
id: composer-cache
Expand Down
Loading