Skip to content

Commit e69aa8c

Browse files
committed
Add new workflow to run windows builds and tests separately
1 parent cc31f3a commit e69aa8c

File tree

1 file changed

+157
-0
lines changed

1 file changed

+157
-0
lines changed

.github/workflows/windows-tests.yml

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
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: Setup PHP SDK
40+
id: setup-php
41+
uses: cmb69/[email protected]
42+
with:
43+
version: ${{ matrix.php }}
44+
arch: ${{ matrix.arch }}
45+
ts: ${{ matrix.ts }}
46+
deps: openssl
47+
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
61+
run: nmake /nologo
62+
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+
72+
- name: Cache build artifacts for subsequent builds
73+
id: cache-build-artifacts
74+
uses: actions/cache/save@v3
75+
with:
76+
key: ${{ github.sha }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}
77+
path: |
78+
${{ steps.get-build-dir.outputs.build_dir }}\php_mongodb.dll
79+
${{ steps.get-build-dir.outputs.build_dir }}\php_mongodb.pdb
80+
81+
test:
82+
name: "Windows Tests"
83+
runs-on: windows-2022
84+
# Run tests only when pushing to a branch. When pushing a tag, we're only interested in building the DLLs.
85+
if: ${{ github.ref_type == 'branch' }}
86+
needs: build
87+
defaults:
88+
run:
89+
shell: cmd
90+
91+
strategy:
92+
fail-fast: true
93+
matrix:
94+
php: [ "7.4", "8.0", "8.1", "8.2" ]
95+
arch: [ x64, x86 ]
96+
ts: [ ts, nts ]
97+
98+
steps:
99+
- uses: actions/checkout@v3
100+
with:
101+
fetch-depth: 2
102+
submodules: true
103+
104+
- name: Setup PHP SDK
105+
id: setup-php
106+
uses: cmb69/[email protected]
107+
with:
108+
version: ${{ matrix.php }}
109+
arch: ${{ matrix.arch }}
110+
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%
133+
134+
- name: Restore cached build artifacts
135+
id: cache-build-artifacts
136+
uses: actions/cache/restore@v3
137+
with:
138+
fail-on-cache-miss: true
139+
key: ${{ github.sha }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}
140+
path: |
141+
${{ steps.get-build-dir.outputs.build_dir }}\php_mongodb.dll
142+
${{ steps.get-build-dir.outputs.build_dir }}\php_mongodb.pdb
143+
144+
- name: Start MongoDB
145+
run: |
146+
sc config MongoDB start= auto
147+
sc start MongoDB
148+
149+
- name: Wait until MongoDB is available
150+
run: .github/workflows/wait-for-mongodb.bat
151+
152+
- name: Run Tests
153+
run: nmake /nologo test
154+
env:
155+
NO_INTERACTION: 1
156+
REPORT_EXIT_STATUS: 1
157+
TESTS: --show-diff

0 commit comments

Comments
 (0)