Skip to content

Use drivers-evergreen-tools for Windows testing #1615

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 4 commits into from
Jul 24, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/package-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
strategy:
fail-fast: false
matrix:
# Note: keep this in sync with the Windows matrix in windows-tests.yml
# Note: keep this in sync with the Windows matrix in tests.yml
php: [ "7.4", "8.0", "8.1", "8.2", "8.3" ]
arch: [ x64, x86 ]
ts: [ ts, nts ]
16 changes: 16 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,19 @@ jobs:

- name: "Install release archive to verify correctness"
run: sudo pecl install ${{ env.PACKAGE_FILE }}

test-windows:
name: "Windows Tests"
uses: ./.github/workflows/windows-tests.yml
with:
php: ${{ matrix.php }}
arch: ${{ matrix.arch }}
ts: ${{ matrix.ts }}
secrets: inherit
strategy:
fail-fast: false
matrix:
# Note: keep this in sync with the Windows matrix in package-release.yml
php: [ "7.4", "8.0", "8.1", "8.2", "8.3" ]
arch: [ x64, x86 ]
ts: [ ts, nts ]
82 changes: 37 additions & 45 deletions .github/workflows/windows-tests.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
name: "Windows Tests"
run-name: "Windows Tests (PHP ${{ inputs.php }} ${{ inputs.arch }} ${{ inputs.ts }})"

on:
pull_request:
branches:
- "v*.*"
- "master"
- "feature/*"
push:
branches:
- "v*.*"
- "master"
- "feature/*"
workflow_call:
inputs:
php:
description: "The PHP version to build for"
type: string
required: true
arch:
description: "The architecture to build for (x64 or x86)"
type: string
required: true
ts:
description: "Thread safety (ts or nts)"
type: string
required: true
upload_release_asset:
description: "Whether to upload a release asset"
type: boolean
default: false

jobs:
build:
name: "Build Windows DLLs"
name: "Build Driver"
runs-on: windows-2022
defaults:
run:
shell: cmd

strategy:
# This matrix intentionally uses fail-fast: false to ensure other builds are finished
fail-fast: false
matrix:
php: [ "7.4", "8.0", "8.1", "8.2", "8.3" ]
arch: [ x64, x86 ]
ts: [ ts, nts ]

steps:
- uses: actions/checkout@v4
with:
Expand All @@ -37,70 +38,61 @@ jobs:
id: build-driver
uses: ./.github/actions/windows/build
with:
version: ${{ matrix.php }}
arch: ${{ matrix.arch }}
ts: ${{ matrix.ts }}
version: ${{ inputs.php }}
arch: ${{ inputs.arch }}
ts: ${{ inputs.ts }}

- name: Cache build artifacts for subsequent builds
id: cache-build-artifacts
uses: actions/cache/save@v4
with:
key: ${{ github.sha }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}
key: ${{ github.sha }}-${{ inputs.php }}-${{ inputs.ts }}-${{ inputs.arch }}
path: |
${{ steps.build-driver.outputs.build-dir }}\php_mongodb.dll
${{ steps.build-driver.outputs.build-dir }}\php_mongodb.pdb

test:
name: "Windows Tests"
name: "Run Tests"
runs-on: windows-2022
needs: build
defaults:
run:
shell: cmd

strategy:
# Timeouts starting the MongoDB service are common and should not
# interrupt the overall test matrix.
fail-fast: false
matrix:
php: [ "7.4", "8.0", "8.1", "8.2", "8.3" ]
arch: [ x64, x86 ]
ts: [ ts, nts ]

steps:
- uses: actions/checkout@v4
with:
submodules: true

- id: setup-mongodb
uses: mongodb-labs/drivers-evergreen-tools@master
with:
version: "7.0"
topology: "server"

- name: Prepare build environment
id: prepare-build
uses: ./.github/actions/windows/prepare-build
with:
version: ${{ matrix.php }}
arch: ${{ matrix.arch }}
ts: ${{ matrix.ts }}
version: ${{ inputs.php }}
arch: ${{ inputs.arch }}
ts: ${{ inputs.ts }}

- name: Restore cached build artifacts
id: cache-build-artifacts
uses: actions/cache/restore@v4
with:
fail-on-cache-miss: true
key: ${{ github.sha }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}
key: ${{ github.sha }}-${{ inputs.php }}-${{ inputs.ts }}-${{ inputs.arch }}
path: |
${{ steps.prepare-build.outputs.build-dir }}\php_mongodb.dll
${{ steps.prepare-build.outputs.build-dir }}\php_mongodb.pdb

- name: Start MongoDB
run: |
sc config MongoDB start= auto
sc start MongoDB

- name: Wait until MongoDB is available
run: .github/workflows/wait-for-mongodb.bat

- name: Run Tests
run: nmake /nologo test
env:
NO_INTERACTION: 1
REPORT_EXIT_STATUS: 1
TESTS: --show-diff
MONGODB_URI: ${{ steps.setup-mongodb.outputs.cluster-uri }}
CRYPT_SHARED_LIB_PATH: ${{ steps.setup-mongodb.outputs.crypt-shared-lib-path }}
1 change: 1 addition & 0 deletions src/MongoDB/Monitoring/ServerHeartbeatSucceededEvent.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ static HashTable* php_phongo_serverheartbeatsucceededevent_get_debug_info(phongo
ADD_ASSOC_STRING(&retval, "host", intern->host.host);
ADD_ASSOC_LONG_EX(&retval, "port", intern->host.port);
ADD_ASSOC_BOOL_EX(&retval, "awaited", intern->awaited);
ADD_ASSOC_INT64(&retval, "durationMicros", intern->duration_micros);

if (!php_phongo_bson_to_zval_ex(intern->reply, &reply_state)) {
zval_ptr_dtor(&reply_state.zchild);
Expand Down
4 changes: 2 additions & 2 deletions src/phongo_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ typedef struct {

typedef struct {
bool awaited;
uint64_t duration_micros;
int64_t duration_micros;
zval z_error;
mongoc_host_list_t host;
zend_object std;
Expand All @@ -355,7 +355,7 @@ typedef struct {

typedef struct {
bool awaited;
uint64_t duration_micros;
int64_t duration_micros;
mongoc_host_list_t host;
bson_t* reply;
zend_object std;
Expand Down
2 changes: 2 additions & 0 deletions tests/apm/serverHeartbeatSucceededEvent-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ object(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent)#%d (%d) {
int(%d)
["awaited"]=>
bool(%s)
["durationMicros"]=>
int(%d)
Comment on lines +71 to +72
Copy link
Member

Choose a reason for hiding this comment

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

I understand that this value was already exposed with an getDurationMicros method, but now it becomes accessible with var_dump.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's correct :)

["reply"]=>
object(stdClass)#%d (%d) {%A
}
Expand Down