Skip to content

Commit a52e40f

Browse files
Lower overhead of Windows CI tests (#610)
* Cache vcpkg libs and reuse * Auto update version * Trigger CI * Fix matrix tests for windows * Add excluded modules for OpenCPPCoverage * Convert dash to underscore * Use optimized build for Windows coverage * Retrigger CI --------- Co-authored-by: Dev version update bot <github-actions[bot]@users.noreply.github.com>
1 parent 38450e9 commit a52e40f

File tree

1 file changed

+116
-89
lines changed

1 file changed

+116
-89
lines changed

.github/workflows/tests_windows.yml

+116-89
Original file line numberDiff line numberDiff line change
@@ -20,76 +20,6 @@ concurrency:
2020
cancel-in-progress: true
2121

2222
jobs:
23-
cpptests:
24-
if: ${{ !contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }}
25-
timeout-minutes: 45
26-
name: C++ tests (Windows)
27-
runs-on: ${{ matrix.os }}
28-
strategy:
29-
matrix:
30-
os: [windows-latest]
31-
pl_backend: ["lightning_qubit"]
32-
steps:
33-
- name: Checkout PennyLane-Lightning
34-
uses: actions/checkout@v3
35-
36-
- name: Configure MSVC for amd64 # Use cl.exe as a default compiler
37-
uses: ilammy/msvc-dev-cmd@v1
38-
with:
39-
arch: amd64
40-
41-
- name: Install lapack with vcpkg
42-
run: |
43-
git clone --quiet --recursive https://github.com/microsoft/vcpkg.git
44-
cd vcpkg
45-
.\bootstrap-vcpkg.bat
46-
vcpkg install lapack
47-
48-
- name: Setup OpenCppCoverage and add to PATH
49-
run: |
50-
choco install OpenCppCoverage -y
51-
echo "C:\Program Files\OpenCppCoverage" >> $env:GITHUB_PATH
52-
53-
- name: Build and run unit tests for code coverage
54-
run: |
55-
cmake -BBuild `
56-
-DBUILD_TESTS=ON `
57-
-DENABLE_OPENMP=OFF `
58-
-DENABLE_PYTHON=OFF `
59-
-DENABLE_GATE_DISPATCHER=OFF `
60-
-DPL_BACKEND=${{ matrix.pl_backend }} `
61-
-DENABLE_LAPACK=ON `
62-
-DCMAKE_TOOLCHAIN_FILE=D:/a/pennylane-lightning/pennylane-lightning/vcpkg/scripts/buildsystems/vcpkg.cmake `
63-
-DENABLE_WARNINGS=OFF
64-
cmake --build .\Build --config Debug
65-
mkdir -p .\Build\tests\results
66-
$test_bins = Get-ChildItem -Include *.exe -Recurse -Path ./Build/Debug
67-
foreach ($file in $test_bins)
68-
{
69-
$filename = $file.ToString() -replace '.{4}$'
70-
$filename = $filename.Substring($filename.LastIndexOf("\")+1)
71-
$test_call = $file.ToString() + " --order lex --reporter junit --out .\Build\tests\results\report_" + $filename + ".xml"
72-
Invoke-Expression $test_call
73-
$cov_call = "OpenCppCoverage --sources pennylane_lightning\core\src --export_type cobertura:coverage.xml " + $file.ToString()
74-
Invoke-Expression $cov_call
75-
}
76-
Move-Item -Path .\coverage.xml -Destination .\coverage-${{ github.job }}-${{ matrix.pl_backend }}.xml
77-
78-
- name: Upload test results
79-
uses: actions/upload-artifact@v3
80-
if: always()
81-
with:
82-
name: windows-test-report-${{ github.job }}-${{ matrix.pl_backend }}
83-
path: .\Build\tests\results\
84-
if-no-files-found: error
85-
86-
- name: Upload coverage results
87-
uses: actions/upload-artifact@v3
88-
with:
89-
name: windows-coverage-report
90-
path: .\coverage-${{ github.job }}-${{ matrix.pl_backend }}.xml
91-
if-no-files-found: error
92-
9323
win-set-matrix-x86:
9424
name: Set builder matrix
9525
runs-on: ubuntu-latest
@@ -110,7 +40,7 @@ jobs:
11040
exec_model: ${{ steps.exec_model.outputs.exec_model }}
11141
kokkos_version: ${{ steps.kokkos_version.outputs.kokkos_version }}
11242

113-
build_dependencies:
43+
build_dependencies_kokkos:
11444
needs: [win-set-matrix-x86]
11545
strategy:
11646
fail-fast: false
@@ -125,7 +55,7 @@ jobs:
12555
steps:
12656
- name: Cache installation directories
12757
id: kokkos-cache
128-
uses: actions/cache@v3
58+
uses: actions/cache@v4
12959
with:
13060
path: D:\a\install_dir\${{ matrix.exec_model }}
13161
key: ${{ matrix.os }}-kokkos${{ matrix.kokkos_version }}-${{ matrix.exec_model }}-Debug
@@ -163,9 +93,111 @@ jobs:
16393
cmake --build ./Build --config Debug --verbose
16494
cmake --install ./Build --config Debug --verbose
16595
96+
build_dependencies_vcpkg:
97+
strategy:
98+
fail-fast: false
99+
matrix:
100+
os: [windows-latest]
101+
timeout-minutes: 30
102+
name: vcpkg dependencies
103+
runs-on: ${{ matrix.os }}
104+
105+
steps:
106+
- name: Cache installation directories
107+
id: vcpkg-cache
108+
uses: actions/cache@v4
109+
with:
110+
path: D:\a\install_dir\vcpkg
111+
key: ${{ matrix.os }}-vcpkg
112+
113+
- name: Clone vcpkg
114+
if: steps.vcpkg-cache.outputs.cache-hit != 'true'
115+
run: |
116+
mkdir -p D:\a\install_dir
117+
cd D:\a\install_dir\
118+
git clone --quiet --recursive https://github.com/microsoft/vcpkg.git
119+
120+
- name: Install dependencies
121+
if: steps.vcpkg-cache.outputs.cache-hit != 'true'
122+
run: |
123+
python -m pip install cmake build ninja
124+
125+
- name: Build Lapack library
126+
if: steps.vcpkg-cache.outputs.cache-hit != 'true'
127+
run: |
128+
cd D:\a\install_dir\vcpkg
129+
.\bootstrap-vcpkg.bat
130+
vcpkg install lapack
131+
132+
cpptests:
133+
needs: [build_dependencies_vcpkg]
134+
if: ${{ !contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }}
135+
timeout-minutes: 30
136+
name: C++ tests (Windows)
137+
runs-on: ${{ matrix.os }}
138+
strategy:
139+
matrix:
140+
os: [windows-latest]
141+
pl_backend: ["lightning_qubit"]
142+
steps:
143+
- name: Checkout PennyLane-Lightning
144+
uses: actions/checkout@v3
145+
146+
- name: Restoring cached vcpkg
147+
id: vcpkg-cache
148+
uses: actions/cache@v4
149+
with:
150+
path: D:\a\install_dir\vcpkg
151+
key: ${{ matrix.os }}-vcpkg
152+
153+
- name: Setup OpenCppCoverage and add to PATH
154+
run: |
155+
choco install OpenCppCoverage -y
156+
echo "C:\Program Files\OpenCppCoverage" >> $env:GITHUB_PATH
157+
158+
- name: Build and run unit tests for code coverage
159+
run: |
160+
cmake -BBuild `
161+
-DBUILD_TESTS=ON `
162+
-DENABLE_OPENMP=OFF `
163+
-DENABLE_PYTHON=OFF `
164+
-DENABLE_GATE_DISPATCHER=OFF `
165+
-DPL_BACKEND=${{ matrix.pl_backend }} `
166+
-DENABLE_LAPACK=ON `
167+
-DCMAKE_TOOLCHAIN_FILE=D:\a\install_dir\vcpkg\scripts\buildsystems\vcpkg.cmake `
168+
-DENABLE_WARNINGS=OFF
169+
cmake --build .\Build --config RelWithDebInfo
170+
mkdir -p .\Build\tests\results
171+
$test_bins = Get-ChildItem -Include *.exe -Recurse -Path ./Build/RelWithDebInfo
172+
foreach ($file in $test_bins)
173+
{
174+
$filename = $file.ToString() -replace '.{4}$'
175+
$filename = $filename.Substring($filename.LastIndexOf("\")+1)
176+
$test_call = $file.ToString() + " --order lex --reporter junit --out .\Build\tests\results\report_" + $filename + ".xml"
177+
Invoke-Expression $test_call
178+
$cov_call = "OpenCppCoverage --sources pennylane_lightning\core\src --excluded_modules D:\a\install_dir\* --excluded_modules C:\Windows\System32\* --export_type cobertura:coverage.xml " + $file.ToString()
179+
Invoke-Expression $cov_call
180+
}
181+
Move-Item -Path .\coverage.xml -Destination .\coverage-${{ github.job }}-${{ matrix.pl_backend }}.xml
182+
183+
- name: Upload test results
184+
uses: actions/upload-artifact@v3
185+
if: always()
186+
with:
187+
name: windows-test-report-${{ github.job }}-${{ matrix.pl_backend }}
188+
path: .\Build\tests\results\
189+
if-no-files-found: error
190+
191+
- name: Upload coverage results
192+
uses: actions/upload-artifact@v3
193+
with:
194+
name: windows-coverage-report
195+
path: .\coverage-${{ github.job }}-${{ matrix.pl_backend }}.xml
196+
if-no-files-found: error
197+
166198
cpptestswithkokkos:
167199
if: ${{ !contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }}
168-
needs: [build_dependencies, win-set-matrix-x86]
200+
needs: [build_dependencies_kokkos, build_dependencies_vcpkg, win-set-matrix-x86]
169201
strategy:
170202
matrix:
171203
os: [windows-latest]
@@ -180,32 +212,27 @@ jobs:
180212
steps:
181213
- name: Restoring cached Kokkos
182214
id: kokkos-cache
183-
uses: actions/cache@v3
215+
uses: actions/cache@v4
184216
with:
185217
path: D:\a\install_dir\${{ matrix.exec_model }}
186218
key: ${{ matrix.os }}-kokkos${{ matrix.kokkos_version }}-${{ matrix.exec_model }}-Debug
219+
220+
- name: Restoring cached vcpkg
221+
id: vcpkg-cache
222+
uses: actions/cache@v4
223+
with:
224+
path: D:\a\install_dir\vcpkg
225+
key: ${{ matrix.os }}-vcpkg
187226

188227
- name: Checkout PennyLane-Lightning
189228
uses: actions/checkout@v3
190229

191-
- name: Copy cached libraries
230+
- name: Copy cached Kokkos libraries
192231
if: steps.kokkos-cache.outputs.cache-hit == 'true'
193232
run: |
194233
Copy-Item -Path "D:\a\install_dir\${{ matrix.exec_model }}\" `
195234
-Destination "D:\a\pennylane-lightning\pennylane-lightning\Kokkos" -Recurse -Force
196235
197-
- name: Configure MSVC for amd64 # Use cl.exe as a default compiler
198-
uses: ilammy/msvc-dev-cmd@v1
199-
with:
200-
arch: amd64
201-
202-
- name: Install lapack with vcpkg
203-
run: |
204-
git clone --quiet --recursive https://github.com/microsoft/vcpkg.git
205-
cd vcpkg
206-
.\bootstrap-vcpkg.bat
207-
vcpkg install lapack
208-
209236
- name: Enable long paths
210237
run: |
211238
powershell.exe New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
@@ -224,7 +251,7 @@ jobs:
224251
-DENABLE_PYTHON=OFF `
225252
-DENABLE_GATE_DISPATCHER=OFF `
226253
-DCMAKE_PREFIX_PATH=D:\a\pennylane-lightning\pennylane-lightning\Kokkos `
227-
-DCMAKE_TOOLCHAIN_FILE=D:/a/pennylane-lightning/pennylane-lightning/vcpkg/scripts/buildsystems/vcpkg.cmake `
254+
-DCMAKE_TOOLCHAIN_FILE=D:\a\install_dir\vcpkg\scripts\buildsystems\vcpkg.cmake `
228255
-DENABLE_OPENMP=OFF `
229256
-DPL_BACKEND=${{ matrix.pl_backend }} `
230257
-DENABLE_LAPACK=ON `
@@ -238,7 +265,7 @@ jobs:
238265
$filename = $filename.Substring($filename.LastIndexOf("\")+1)
239266
$test_call = $file.ToString() + " --order lex --reporter junit --out .\Build\tests\results\report_" + $filename + ".xml"
240267
Invoke-Expression $test_call
241-
$cov_call = "OpenCppCoverage --sources pennylane_lightning\core\src --export_type cobertura:coverage.xml " + $file.ToString()
268+
$cov_call = "OpenCppCoverage --sources pennylane_lightning\core\src --excluded_modules D:\a\install_dir\* --excluded_modules C:\Windows\System32\* --export_type cobertura:coverage.xml " + $file.ToString()
242269
Invoke-Expression $cov_call
243270
}
244271
Move-Item -Path .\coverage.xml -Destination .\coverage-${{ github.job }}-${{ matrix.pl_backend }}.xml

0 commit comments

Comments
 (0)