Skip to content

Commit 790e20b

Browse files
authored
PHPC-2233: Split Windows Builds (#1460)
* Add new workflow to run windows builds and tests separately * Extract build env preparation to separate action * Publish build artifacts for push events * Remove windows build from tests workflow
1 parent cc31f3a commit 790e20b

File tree

4 files changed

+186
-79
lines changed

4 files changed

+186
-79
lines changed

.github/workflows/tests.yml

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -78,81 +78,3 @@ jobs:
7878
run: TEST_PHP_ARGS="-q -x --show-diff -g FAIL,XFAIL,BORK,WARN,LEAK,SKIP" make test
7979
env:
8080
MONGODB_URI: ${{ steps.setup-mongodb.outputs.cluster-uri }}
81-
82-
windows-tests:
83-
name: "Windows Tests"
84-
runs-on: windows-2022
85-
defaults:
86-
run:
87-
shell: cmd
88-
89-
strategy:
90-
fail-fast: true
91-
matrix:
92-
php: [ "7.4", "8.0", "8.1", "8.2" ]
93-
arch: [ x64, x86 ]
94-
ts: [ ts, nts ]
95-
96-
steps:
97-
- uses: actions/checkout@v3
98-
with:
99-
fetch-depth: 2
100-
submodules: true
101-
102-
- name: Setup PHP SDK
103-
id: setup-php
104-
uses: cmb69/setup-php-sdk@v0.7
105-
with:
106-
version: ${{ matrix.php }}
107-
arch: ${{ matrix.arch }}
108-
ts: ${{ matrix.ts }}
109-
deps: openssl
110-
111-
- name: Enable Developer Command Prompt
112-
uses: ilammy/msvc-dev-cmd@v1
113-
with:
114-
arch: ${{ matrix.arch }}
115-
toolset: ${{ steps.setup-php.outputs.toolset }}
116-
117-
- name: phpize
118-
run: phpize
119-
120-
- name: configure
121-
run: configure --enable-mongodb --with-mongodb-sasl=yes --with-mongodb-client-side-encryption=yes --enable-debug-pack --with-prefix=${{ steps.setup-php.outputs.prefix }}
122-
123-
- name: nmake
124-
run: nmake /nologo
125-
126-
- name: Start MongoDB
127-
run: |
128-
sc config MongoDB start= auto
129-
sc start MongoDB
130-
131-
- name: Wait until MongoDB is available
132-
run: .github/workflows/wait-for-mongodb.bat
133-
134-
- name: Run Tests
135-
run: nmake /nologo test
136-
env:
137-
NO_INTERACTION: 1
138-
REPORT_EXIT_STATUS: 1
139-
TESTS: --show-diff
140-
141-
- name: Copy DLL and PDB files to CWD
142-
if: ${{ github.event_name == 'push' }}
143-
run: |
144-
cp .github/workflows/get-build-dir.bat .
145-
for /F "usebackq tokens=*" %%i in (`get-build-dir.bat`) do set BUILD_DIR=%%i
146-
echo BUILD_DIR=%BUILD_DIR%
147-
cp %BUILD_DIR%\php_mongodb.dll .
148-
cp %BUILD_DIR%\php_mongodb.pdb .
149-
150-
- name: Upload DLL and PDB files as build artifacts
151-
if: ${{ github.event_name == 'push' }}
152-
uses: actions/upload-artifact@v3
153-
with:
154-
name: php_mongodb-${{ github.sha }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}
155-
path: |
156-
php_mongodb.dll
157-
php_mongodb.pdb
158-
retention-days: 3

.github/workflows/windows-release-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
workflow: tests.yml
2626
workflow_conclusion: success
2727
commit: ${{ github.sha }}
28-
# Note: keep this in sync with the uploaded artifact name in tests.yml
28+
# Note: keep this in sync with the uploaded artifact name in windows-tests.yml
2929
name: php_mongodb-${{ github.sha }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}
3030

3131
- name: Create and attach release archive

.github/workflows/windows-tests.yml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: "Windows Tests"
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- "v*.*"
7+
- "master"
8+
- "feature/*"
9+
push:
10+
tags:
11+
- "*"
12+
branches:
13+
- "v*.*"
14+
- "master"
15+
- "feature/*"
16+
17+
jobs:
18+
build:
19+
name: "Build Windows DLLs"
20+
runs-on: windows-2022
21+
defaults:
22+
run:
23+
shell: cmd
24+
25+
strategy:
26+
# This matrix intentionally uses fail-fast: false to ensure other builds are finished
27+
fail-fast: false
28+
matrix:
29+
php: [ "7.4", "8.0", "8.1", "8.2" ]
30+
arch: [ x64, x86 ]
31+
ts: [ ts, nts ]
32+
33+
steps:
34+
- uses: actions/checkout@v3
35+
with:
36+
fetch-depth: 2
37+
submodules: true
38+
39+
- name: Prepare build environment
40+
id: prepare-build
41+
uses: ./.github/workflows/windows/prepare-build
42+
with:
43+
version: ${{ matrix.php }}
44+
arch: ${{ matrix.arch }}
45+
ts: ${{ matrix.ts }}
46+
47+
- name: Build driver
48+
run: nmake /nologo
49+
50+
- name: Cache build artifacts for subsequent builds
51+
id: cache-build-artifacts
52+
uses: actions/cache/save@v3
53+
with:
54+
key: ${{ github.sha }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}
55+
path: |
56+
${{ steps.prepare-build.outputs.build-dir }}\php_mongodb.dll
57+
${{ steps.prepare-build.outputs.build-dir }}\php_mongodb.pdb
58+
59+
- name: Copy DLL and PDB files to CWD
60+
if: ${{ github.event_name == 'push' }}
61+
run: |
62+
cp .github/workflows/get-build-dir.bat .
63+
for /F "usebackq tokens=*" %%i in (`get-build-dir.bat`) do set BUILD_DIR=%%i
64+
echo BUILD_DIR=%BUILD_DIR%
65+
cp %BUILD_DIR%\php_mongodb.dll .
66+
cp %BUILD_DIR%\php_mongodb.pdb .
67+
68+
- name: Upload DLL and PDB files as build artifacts
69+
if: ${{ github.event_name == 'push' }}
70+
uses: actions/upload-artifact@v3
71+
with:
72+
name: php_mongodb-${{ github.sha }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}
73+
path: |
74+
php_mongodb.dll
75+
php_mongodb.pdb
76+
retention-days: 3
77+
78+
test:
79+
name: "Windows Tests"
80+
runs-on: windows-2022
81+
# Run tests only when pushing to a branch. When pushing a tag, we're only interested in building the DLLs.
82+
if: ${{ github.ref_type == 'branch' }}
83+
needs: build
84+
defaults:
85+
run:
86+
shell: cmd
87+
88+
strategy:
89+
fail-fast: true
90+
matrix:
91+
php: [ "7.4", "8.0", "8.1", "8.2" ]
92+
arch: [ x64, x86 ]
93+
ts: [ ts, nts ]
94+
95+
steps:
96+
- uses: actions/checkout@v3
97+
with:
98+
fetch-depth: 2
99+
submodules: true
100+
101+
- name: Prepare build environment
102+
id: prepare-build
103+
uses: ./.github/workflows/windows/prepare-build
104+
with:
105+
version: ${{ matrix.php }}
106+
arch: ${{ matrix.arch }}
107+
ts: ${{ matrix.ts }}
108+
109+
- name: Restore cached build artifacts
110+
id: cache-build-artifacts
111+
uses: actions/cache/restore@v3
112+
with:
113+
fail-on-cache-miss: true
114+
key: ${{ github.sha }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}
115+
path: |
116+
${{ steps.prepare-build.outputs.build-dir }}\php_mongodb.dll
117+
${{ steps.prepare-build.outputs.build-dir }}\php_mongodb.pdb
118+
119+
- name: Start MongoDB
120+
run: |
121+
sc config MongoDB start= auto
122+
sc start MongoDB
123+
124+
- name: Wait until MongoDB is available
125+
run: .github/workflows/wait-for-mongodb.bat
126+
127+
- name: Run Tests
128+
run: nmake /nologo test
129+
env:
130+
NO_INTERACTION: 1
131+
REPORT_EXIT_STATUS: 1
132+
TESTS: --show-diff
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: "Setup PHP driver build environment"
2+
description: "Prepares the PHP build environment for the MongoDB driver"
3+
inputs:
4+
version:
5+
description: "PHP version to build for"
6+
required: true
7+
arch:
8+
description: "The architecture to build for (x64 or x86)"
9+
required: true
10+
ts:
11+
description: "Thread-safety (nts or ts)"
12+
required: true
13+
outputs:
14+
build-dir:
15+
description: "The build directory to be used"
16+
value: ${{steps.get-build-dir.outputs.build_dir}}
17+
runs:
18+
using: composite
19+
steps:
20+
- name: Setup PHP SDK
21+
id: setup-php
22+
uses: cmb69/setup-php-sdk@v0.7
23+
with:
24+
version: ${{ inputs.version }}
25+
arch: ${{ inputs.arch }}
26+
ts: ${{ inputs.ts }}
27+
deps: openssl
28+
29+
- name: Enable Developer Command Prompt
30+
uses: ilammy/msvc-dev-cmd@v1
31+
with:
32+
arch: ${{ matrix.arch }}
33+
toolset: ${{ steps.setup-php.outputs.toolset }}
34+
35+
- name: phpize
36+
run: phpize
37+
shell: cmd
38+
39+
- name: configure
40+
run: configure --enable-mongodb --with-mongodb-sasl=yes --with-mongodb-client-side-encryption=yes --enable-debug-pack --with-prefix=${{ steps.setup-php.outputs.prefix }}
41+
shell: cmd
42+
43+
- name: Get build directory
44+
id: get-build-dir
45+
shell: cmd
46+
# The last echo command to set the output variable intentionally omits a space between the environment variable
47+
# and the output redirector to avoid a trailing space in the generated output variable. Do not add a space.
48+
run: |
49+
cp .github/workflows/get-build-dir.bat .
50+
for /F "usebackq tokens=*" %%i in (`get-build-dir.bat`) do set BUILD_DIR=%%i
51+
echo BUILD_DIR=%BUILD_DIR%
52+
@chcp 65001>nul
53+
echo build_dir=%BUILD_DIR%>> %GITHUB_OUTPUT%

0 commit comments

Comments
 (0)