Skip to content

Commit 2cd4b43

Browse files
authored
Use drivers-evergreen-tools for Windows testing (#1615)
* Use drivers-evergreen-tools to start MongoDB clusters on Windows * Use workflow_call trigger to test Windows * Fix wrong type for duration in heartbeat events * Expose durationMicros when dumping hearbeatSucceeded events
1 parent d3f3d7b commit 2cd4b43

File tree

6 files changed

+59
-48
lines changed

6 files changed

+59
-48
lines changed

.github/workflows/package-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ jobs:
9797
strategy:
9898
fail-fast: false
9999
matrix:
100-
# Note: keep this in sync with the Windows matrix in windows-tests.yml
100+
# Note: keep this in sync with the Windows matrix in tests.yml
101101
php: [ "7.4", "8.0", "8.1", "8.2", "8.3" ]
102102
arch: [ x64, x86 ]
103103
ts: [ ts, nts ]

.github/workflows/tests.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,19 @@ jobs:
110110
111111
- name: "Install release archive to verify correctness"
112112
run: sudo pecl install ${{ env.PACKAGE_FILE }}
113+
114+
test-windows:
115+
name: "Windows Tests"
116+
uses: ./.github/workflows/windows-tests.yml
117+
with:
118+
php: ${{ matrix.php }}
119+
arch: ${{ matrix.arch }}
120+
ts: ${{ matrix.ts }}
121+
secrets: inherit
122+
strategy:
123+
fail-fast: false
124+
matrix:
125+
# Note: keep this in sync with the Windows matrix in package-release.yml
126+
php: [ "7.4", "8.0", "8.1", "8.2", "8.3" ]
127+
arch: [ x64, x86 ]
128+
ts: [ ts, nts ]

.github/workflows/windows-tests.yml

Lines changed: 37 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
11
name: "Windows Tests"
2+
run-name: "Windows Tests (PHP ${{ inputs.php }} ${{ inputs.arch }} ${{ inputs.ts }})"
23

34
on:
4-
pull_request:
5-
branches:
6-
- "v*.*"
7-
- "master"
8-
- "feature/*"
9-
push:
10-
branches:
11-
- "v*.*"
12-
- "master"
13-
- "feature/*"
5+
workflow_call:
6+
inputs:
7+
php:
8+
description: "The PHP version to build for"
9+
type: string
10+
required: true
11+
arch:
12+
description: "The architecture to build for (x64 or x86)"
13+
type: string
14+
required: true
15+
ts:
16+
description: "Thread safety (ts or nts)"
17+
type: string
18+
required: true
19+
upload_release_asset:
20+
description: "Whether to upload a release asset"
21+
type: boolean
22+
default: false
1423

1524
jobs:
1625
build:
17-
name: "Build Windows DLLs"
26+
name: "Build Driver"
1827
runs-on: windows-2022
1928
defaults:
2029
run:
2130
shell: cmd
2231

23-
strategy:
24-
# This matrix intentionally uses fail-fast: false to ensure other builds are finished
25-
fail-fast: false
26-
matrix:
27-
php: [ "7.4", "8.0", "8.1", "8.2", "8.3" ]
28-
arch: [ x64, x86 ]
29-
ts: [ ts, nts ]
30-
3132
steps:
3233
- uses: actions/checkout@v4
3334
with:
@@ -37,70 +38,61 @@ jobs:
3738
id: build-driver
3839
uses: ./.github/actions/windows/build
3940
with:
40-
version: ${{ matrix.php }}
41-
arch: ${{ matrix.arch }}
42-
ts: ${{ matrix.ts }}
41+
version: ${{ inputs.php }}
42+
arch: ${{ inputs.arch }}
43+
ts: ${{ inputs.ts }}
4344

4445
- name: Cache build artifacts for subsequent builds
4546
id: cache-build-artifacts
4647
uses: actions/cache/save@v4
4748
with:
48-
key: ${{ github.sha }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}
49+
key: ${{ github.sha }}-${{ inputs.php }}-${{ inputs.ts }}-${{ inputs.arch }}
4950
path: |
5051
${{ steps.build-driver.outputs.build-dir }}\php_mongodb.dll
5152
${{ steps.build-driver.outputs.build-dir }}\php_mongodb.pdb
5253
5354
test:
54-
name: "Windows Tests"
55+
name: "Run Tests"
5556
runs-on: windows-2022
5657
needs: build
5758
defaults:
5859
run:
5960
shell: cmd
6061

61-
strategy:
62-
# Timeouts starting the MongoDB service are common and should not
63-
# interrupt the overall test matrix.
64-
fail-fast: false
65-
matrix:
66-
php: [ "7.4", "8.0", "8.1", "8.2", "8.3" ]
67-
arch: [ x64, x86 ]
68-
ts: [ ts, nts ]
69-
7062
steps:
7163
- uses: actions/checkout@v4
7264
with:
7365
submodules: true
7466

67+
- id: setup-mongodb
68+
uses: mongodb-labs/drivers-evergreen-tools@master
69+
with:
70+
version: "7.0"
71+
topology: "server"
72+
7573
- name: Prepare build environment
7674
id: prepare-build
7775
uses: ./.github/actions/windows/prepare-build
7876
with:
79-
version: ${{ matrix.php }}
80-
arch: ${{ matrix.arch }}
81-
ts: ${{ matrix.ts }}
77+
version: ${{ inputs.php }}
78+
arch: ${{ inputs.arch }}
79+
ts: ${{ inputs.ts }}
8280

8381
- name: Restore cached build artifacts
8482
id: cache-build-artifacts
8583
uses: actions/cache/restore@v4
8684
with:
8785
fail-on-cache-miss: true
88-
key: ${{ github.sha }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}
86+
key: ${{ github.sha }}-${{ inputs.php }}-${{ inputs.ts }}-${{ inputs.arch }}
8987
path: |
9088
${{ steps.prepare-build.outputs.build-dir }}\php_mongodb.dll
9189
${{ steps.prepare-build.outputs.build-dir }}\php_mongodb.pdb
9290
93-
- name: Start MongoDB
94-
run: |
95-
sc config MongoDB start= auto
96-
sc start MongoDB
97-
98-
- name: Wait until MongoDB is available
99-
run: .github/workflows/wait-for-mongodb.bat
100-
10191
- name: Run Tests
10292
run: nmake /nologo test
10393
env:
10494
NO_INTERACTION: 1
10595
REPORT_EXIT_STATUS: 1
10696
TESTS: --show-diff
97+
MONGODB_URI: ${{ steps.setup-mongodb.outputs.cluster-uri }}
98+
CRYPT_SHARED_LIB_PATH: ${{ steps.setup-mongodb.outputs.crypt-shared-lib-path }}

src/MongoDB/Monitoring/ServerHeartbeatSucceededEvent.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ static HashTable* php_phongo_serverheartbeatsucceededevent_get_debug_info(phongo
124124
ADD_ASSOC_STRING(&retval, "host", intern->host.host);
125125
ADD_ASSOC_LONG_EX(&retval, "port", intern->host.port);
126126
ADD_ASSOC_BOOL_EX(&retval, "awaited", intern->awaited);
127+
ADD_ASSOC_INT64(&retval, "durationMicros", intern->duration_micros);
127128

128129
if (!php_phongo_bson_to_zval_ex(intern->reply, &reply_state)) {
129130
zval_ptr_dtor(&reply_state.zchild);

src/phongo_structs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ typedef struct {
341341

342342
typedef struct {
343343
bool awaited;
344-
uint64_t duration_micros;
344+
int64_t duration_micros;
345345
zval z_error;
346346
mongoc_host_list_t host;
347347
zend_object std;
@@ -355,7 +355,7 @@ typedef struct {
355355

356356
typedef struct {
357357
bool awaited;
358-
uint64_t duration_micros;
358+
int64_t duration_micros;
359359
mongoc_host_list_t host;
360360
bson_t* reply;
361361
zend_object std;

tests/apm/serverHeartbeatSucceededEvent-001.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ object(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent)#%d (%d) {
6868
int(%d)
6969
["awaited"]=>
7070
bool(%s)
71+
["durationMicros"]=>
72+
int(%d)
7173
["reply"]=>
7274
object(stdClass)#%d (%d) {%A
7375
}

0 commit comments

Comments
 (0)