Skip to content

Commit eb80ef9

Browse files
committed
Extract build env preparation to separate action
1 parent e69aa8c commit eb80ef9

File tree

2 files changed

+64
-55
lines changed

2 files changed

+64
-55
lines changed

.github/workflows/windows-tests.yml

Lines changed: 11 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -36,47 +36,25 @@ jobs:
3636
fetch-depth: 2
3737
submodules: true
3838

39-
- name: Setup PHP SDK
40-
id: setup-php
41-
uses: cmb69/[email protected]
39+
- name: Prepare build environment
40+
id: prepare-build
41+
uses: ./.github/workflows/windows/prepare-build
4242
with:
4343
version: ${{ matrix.php }}
4444
arch: ${{ matrix.arch }}
4545
ts: ${{ matrix.ts }}
46-
deps: openssl
4746

48-
- name: Enable Developer Command Prompt
49-
uses: ilammy/msvc-dev-cmd@v1
50-
with:
51-
arch: ${{ matrix.arch }}
52-
toolset: ${{ steps.setup-php.outputs.toolset }}
53-
54-
- name: phpize
55-
run: phpize
56-
57-
- name: configure
58-
run: configure --enable-mongodb --with-mongodb-sasl=yes --with-mongodb-client-side-encryption=yes --enable-debug-pack --with-prefix=${{ steps.setup-php.outputs.prefix }}
59-
60-
- name: nmake
47+
- name: Build driver
6148
run: nmake /nologo
6249

63-
- name: Get build directory
64-
id: get-build-dir
65-
run: |
66-
cp .github/workflows/get-build-dir.bat .
67-
for /F "usebackq tokens=*" %%i in (`get-build-dir.bat`) do set BUILD_DIR=%%i
68-
echo BUILD_DIR=%BUILD_DIR%
69-
@chcp 65001>nul
70-
echo build_dir=%BUILD_DIR%>> %GITHUB_OUTPUT%
71-
7250
- name: Cache build artifacts for subsequent builds
7351
id: cache-build-artifacts
7452
uses: actions/cache/save@v3
7553
with:
7654
key: ${{ github.sha }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}
7755
path: |
78-
${{ steps.get-build-dir.outputs.build_dir }}\php_mongodb.dll
79-
${{ steps.get-build-dir.outputs.build_dir }}\php_mongodb.pdb
56+
${{ steps.prepare-build.outputs.build-dir }}\php_mongodb.dll
57+
${{ steps.prepare-build.outputs.build-dir }}\php_mongodb.pdb
8058
8159
test:
8260
name: "Windows Tests"
@@ -101,35 +79,13 @@ jobs:
10179
fetch-depth: 2
10280
submodules: true
10381

104-
- name: Setup PHP SDK
105-
id: setup-php
106-
uses: cmb69/[email protected]
82+
- name: Prepare build environment
83+
id: prepare-build
84+
uses: ./.github/workflows/windows/prepare-build
10785
with:
10886
version: ${{ matrix.php }}
10987
arch: ${{ matrix.arch }}
11088
ts: ${{ matrix.ts }}
111-
deps: openssl
112-
113-
- name: Enable Developer Command Prompt
114-
uses: ilammy/msvc-dev-cmd@v1
115-
with:
116-
arch: ${{ matrix.arch }}
117-
toolset: ${{ steps.setup-php.outputs.toolset }}
118-
119-
- name: phpize
120-
run: phpize
121-
122-
- name: configure
123-
run: configure --enable-mongodb --with-mongodb-sasl=yes --with-mongodb-client-side-encryption=yes --enable-debug-pack --with-prefix=${{ steps.setup-php.outputs.prefix }}
124-
125-
- name: Get build directory
126-
id: get-build-dir
127-
run: |
128-
cp .github/workflows/get-build-dir.bat .
129-
for /F "usebackq tokens=*" %%i in (`get-build-dir.bat`) do set BUILD_DIR=%%i
130-
echo BUILD_DIR=%BUILD_DIR%
131-
@chcp 65001>nul
132-
echo build_dir=%BUILD_DIR%>> %GITHUB_OUTPUT%
13389

13490
- name: Restore cached build artifacts
13591
id: cache-build-artifacts
@@ -138,8 +94,8 @@ jobs:
13894
fail-on-cache-miss: true
13995
key: ${{ github.sha }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}
14096
path: |
141-
${{ steps.get-build-dir.outputs.build_dir }}\php_mongodb.dll
142-
${{ steps.get-build-dir.outputs.build_dir }}\php_mongodb.pdb
97+
${{ steps.prepare-build.outputs.build-dir }}\php_mongodb.dll
98+
${{ steps.prepare-build.outputs.build-dir }}\php_mongodb.pdb
14399
144100
- name: Start MongoDB
145101
run: |
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/[email protected]
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)