Skip to content

Commit 52f1f77

Browse files
Split coverage build into separate steps
1 parent 1fefc4e commit 52f1f77

File tree

3 files changed

+88
-33
lines changed

3 files changed

+88
-33
lines changed

.github/workflows/generate_coverage.yaml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,24 +117,39 @@ jobs:
117117
mamba info
118118
mamba list
119119
120-
- name: Build dpnp with coverage
121-
id: build_coverage
120+
- name: Build dpnp tensor with coverage (Step 1)
121+
id: build_tensor
122122
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
123123
with:
124124
shell: bash
125-
timeout_minutes: 120
125+
timeout_minutes: 60
126126
max_attempts: 5
127127
retry_on: error
128128
command: |
129129
. $CONDA/etc/profile.d/conda.sh
130130
conda activate coverage
131131
[ -f /opt/intel/oneapi/setvars.sh ] && source /opt/intel/oneapi/setvars.sh
132132
git clean -fxd
133-
python scripts/gen_coverage.py
133+
python scripts/gen_coverage.py --build-step tensor
134+
135+
- name: Build dpnp with coverage (skip tensor)
136+
id: build_skip_tensor
137+
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
138+
with:
139+
shell: bash
140+
timeout_minutes: 60
141+
max_attempts: 5
142+
retry_on: error
143+
command: |
144+
. $CONDA/etc/profile.d/conda.sh
145+
conda activate coverage
146+
[ -f /opt/intel/oneapi/setvars.sh ] && source /opt/intel/oneapi/setvars.sh
147+
python scripts/gen_coverage.py --build-step skip-tensor
134148
135149
- name: Total number of coverage attempts
136150
run: |
137-
echo "Total number of coverage attempts: ${{ steps.build_coverage.outputs.total_attempts }}"
151+
echo "Total tensor build attempts: ${{ steps.build_tensor.outputs.total_attempts }}"
152+
echo "Total skip-tensor build attempts: ${{ steps.build_skip_tensor.outputs.total_attempts }}"
138153
139154
- name: Upload coverage data to coveralls.io
140155
uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e # v2.3.7

dpnp/CMakeLists.txt

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -174,21 +174,31 @@ function(build_dpnp_cython_ext_with_backend _trgt _src _dest)
174174
target_link_libraries(${_trgt} PRIVATE dpnp_backend_library)
175175
endfunction()
176176

177-
# Skip tensor build for coverage to reduce memory usage on Public CI
178-
if(NOT DPNP_SKIP_TENSOR_BUILD)
177+
# Control which components to build (for memory-constrained CI builds)
178+
# DPNP_BUILD_COMPONENTS:
179+
# ALL (default),
180+
# TENSOR_ONLY,
181+
# SKIP_TENSOR,
182+
if(NOT DEFINED DPNP_BUILD_COMPONENTS)
183+
set(DPNP_BUILD_COMPONENTS "ALL")
184+
endif()
185+
186+
if(DPNP_BUILD_COMPONENTS STREQUAL "ALL" OR DPNP_BUILD_COMPONENTS STREQUAL "TENSOR_ONLY")
179187
add_subdirectory(tensor)
180188
endif()
181189

182-
add_subdirectory(backend)
183-
add_subdirectory(backend/extensions/blas)
184-
add_subdirectory(backend/extensions/fft)
185-
add_subdirectory(backend/extensions/indexing)
186-
add_subdirectory(backend/extensions/lapack)
187-
add_subdirectory(backend/extensions/statistics)
188-
add_subdirectory(backend/extensions/ufunc)
189-
add_subdirectory(backend/extensions/vm)
190-
add_subdirectory(backend/extensions/window)
191-
192-
add_subdirectory(dpnp_algo)
193-
add_subdirectory(dpnp_utils)
194-
add_subdirectory(random)
190+
if(DPNP_BUILD_COMPONENTS STREQUAL "ALL" OR DPNP_BUILD_COMPONENTS STREQUAL "SKIP_TENSOR")
191+
add_subdirectory(backend)
192+
add_subdirectory(backend/extensions/blas)
193+
add_subdirectory(backend/extensions/fft)
194+
add_subdirectory(backend/extensions/indexing)
195+
add_subdirectory(backend/extensions/lapack)
196+
add_subdirectory(backend/extensions/statistics)
197+
add_subdirectory(backend/extensions/ufunc)
198+
add_subdirectory(backend/extensions/vm)
199+
add_subdirectory(backend/extensions/window)
200+
201+
add_subdirectory(dpnp_algo)
202+
add_subdirectory(dpnp_utils)
203+
add_subdirectory(random)
204+
endif()

scripts/gen_coverage.py

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ def parse_args():
119119
action="store_true",
120120
help="Remove build dir before rebuild (default: False)",
121121
)
122+
p.add_argument(
123+
"--build-step",
124+
choices=["tensor", "skip-tensor", "both"],
125+
default="both",
126+
help="Which build step to run: tensor (only tensor to generate headers), "
127+
"skip-tensor (everything except tensor, assumes tensor headers exist), "
128+
"or both (default: both)",
129+
)
122130

123131
return p.parse_args()
124132

@@ -175,7 +183,6 @@ def main():
175183
verbose=args.verbose,
176184
)
177185
cmake_args.append("-DDPNP_GENERATE_COVERAGE=ON")
178-
cmake_args.append("-DDPNP_SKIP_TENSOR_BUILD=ON")
179186

180187
env = os.environ.copy()
181188

@@ -193,17 +200,37 @@ def main():
193200

194201
log_cmake_args(cmake_args, "gen_coverage")
195202

196-
build_extension(
197-
setup_dir,
198-
env,
199-
cmake_args,
200-
cmake_executable=args.cmake_executable,
201-
generator=args.generator,
202-
build_type="Coverage",
203-
)
204-
install_editable(setup_dir, env)
203+
if args.build_step in ["tensor", "both"]:
204+
# Build tensor only to generate Cython headers
205+
tensor_cmake_args = cmake_args.copy()
206+
tensor_cmake_args.append("-DDPNP_BUILD_COMPONENTS=TENSOR_ONLY")
207+
208+
build_extension(
209+
setup_dir,
210+
env,
211+
tensor_cmake_args,
212+
cmake_executable=args.cmake_executable,
213+
generator=args.generator,
214+
build_type="Coverage",
215+
)
205216

206-
if args.run_pytest:
217+
if args.build_step in ["skip-tensor", "both"]:
218+
# Build everything except tensor (assumes tensor headers already exist)
219+
skip_tensor_cmake_args = cmake_args.copy()
220+
skip_tensor_cmake_args.append("-DDPNP_BUILD_COMPONENTS=SKIP_TENSOR")
221+
222+
build_extension(
223+
setup_dir,
224+
env,
225+
skip_tensor_cmake_args,
226+
cmake_executable=args.cmake_executable,
227+
generator=args.generator,
228+
build_type="Coverage",
229+
)
230+
install_editable(setup_dir, env)
231+
232+
# Only run tests when we have a complete build (skip-tensor or both)
233+
if args.run_pytest and args.build_step in ["skip-tensor", "both"]:
207234
env["LLVM_PROFILE_FILE"] = "dpnp_pytest.profraw"
208235
pytest_cmd = [
209236
"pytest",
@@ -270,10 +297,13 @@ def find_objects():
270297
)
271298

272299
print("[gen_coverage] Coverage export is completed")
300+
elif args.build_step == "tensor":
301+
print(
302+
"[gen_coverage] Skipping pytest (tensor-only build, tests will run after skip-tensor build)"
303+
)
273304
else:
274305
print(
275-
"[gen_coverage] Skipping pytest and coverage collection "
276-
"(--skip-pytest)"
306+
"[gen_coverage] Skipping pytest and coverage collection (--skip-pytest)"
277307
)
278308

279309
print("[gen_coverage] Done")

0 commit comments

Comments
 (0)