@@ -245,85 +245,24 @@ def check(name: str, command: str, paths: t.Set[str]) -> None:
245
245
key: v1-precheck-pip-cache
246
246
paths:
247
247
- .cache
248
- """
248
+ """
249
249
)
250
250
251
251
252
- def gen_build_base_venvs () -> None :
253
- """Generate the list of base jobs for building virtual environments."""
252
+ def gen_cached_testrunner () -> None :
253
+ """Generate the cached testrunner job."""
254
+ with TESTS_GEN .open ("a" ) as f :
255
+ f .write (template ("cached-testrunner" , current_month = datetime .datetime .now ().month ))
254
256
255
- current_month = datetime .datetime .now ().month
256
257
258
+ def gen_build_base_venvs () -> None :
259
+ """Generate the list of base jobs for building virtual environments.
260
+
261
+ We need to generate this dynamically from a template because it depends
262
+ on the cached testrunner job, which is also generated dynamically.
263
+ """
257
264
with TESTS_GEN .open ("a" ) as f :
258
- f .write (
259
- f"""
260
- build_base_venvs:
261
- extends: .testrunner
262
- stage: setup
263
- needs: []
264
- parallel:
265
- matrix:
266
- - PYTHON_VERSION: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
267
- variables:
268
- CMAKE_BUILD_PARALLEL_LEVEL: '12'
269
- PIP_VERBOSE: '0'
270
- DD_PROFILING_NATIVE_TESTS: '1'
271
- DD_USE_SCCACHE: '1'
272
- PIP_CACHE_DIR: '${{CI_PROJECT_DIR}}/.cache/pip'
273
- SCCACHE_DIR: '${{CI_PROJECT_DIR}}/.cache/sccache'
274
- DD_FAST_BUILD: '1'
275
- DD_CMAKE_INCREMENTAL_BUILD: '1'
276
- DD_SETUP_CACHE_DOWNLOADS: '1'
277
- EXT_CACHE_VENV: '${{CI_PROJECT_DIR}}/.cache/ext_cache_venv'
278
- rules:
279
- - if: '$CI_COMMIT_REF_NAME == "main"'
280
- variables:
281
- DD_FAST_BUILD: '0'
282
- - when: always
283
- script: |
284
- set -e -o pipefail
285
- apt update && apt install -y sccache
286
- pip install riot==0.20.1
287
- if [ ! -d $EXT_CACHE_VENV ]; then
288
- python$PYTHON_VERSION -m venv $EXT_CACHE_VENV
289
- source $EXT_CACHE_VENV/bin/activate
290
- pip install cmake setuptools_rust Cython
291
- else
292
- source $EXT_CACHE_VENV/bin/activate
293
- fi
294
- python scripts/gen_ext_cache_scripts.py
295
- deactivate
296
- $SHELL scripts/restore-ext-cache.sh
297
- riot -P -v generate --python=$PYTHON_VERSION
298
- echo "Running smoke tests"
299
- riot -v run -s --python=$PYTHON_VERSION smoke_test
300
- source $EXT_CACHE_VENV/bin/activate
301
- python scripts/gen_ext_cache_scripts.py
302
- deactivate
303
- $SHELL scripts/save-ext-cache.sh
304
- cache:
305
- # Share pip/sccache between jobs of the same Python version
306
- - key: v1-build_base_venvs-${{PYTHON_VERSION}}-cache-{ current_month }
307
- paths:
308
- - .cache
309
- - key: v1-build_base_venvs-${{PYTHON_VERSION}}-ext-{ current_month }
310
- paths:
311
- - .ext_cache
312
- - key: v1-build_base_venvs-${{PYTHON_VERSION}}-download-cache-{ current_month }
313
- paths:
314
- - .download_cache
315
- artifacts:
316
- name: venv_$PYTHON_VERSION
317
- paths:
318
- - scripts/restore-ext-cache.sh
319
- - scripts/save-ext-cache.sh
320
- - .riot/venv_*
321
- - ddtrace/_version.py
322
- - ddtrace/**/*.so*
323
- - ddtrace/internal/datadog/profiling/crashtracker/crashtracker_exe*
324
- - ddtrace/internal/datadog/profiling/test/test_*
325
- """
326
- )
265
+ f .write (template ("build-base-venvs" ))
327
266
328
267
329
268
# -----------------------------------------------------------------------------
@@ -358,6 +297,14 @@ def gen_build_base_venvs() -> None:
358
297
sys .path .append (str (ROOT / "scripts" ))
359
298
sys .path .append (str (ROOT / "tests" ))
360
299
300
+
301
+ def template (name : str , ** params ):
302
+ """Render a template file with the given parameters."""
303
+ if not (template_path := (GITLAB / "templates" / name ).with_suffix (".yml" )).exists ():
304
+ raise FileNotFoundError (f"Template file { template_path } does not exist" )
305
+ return "\n " + template_path .read_text ().format (** params ).strip () + "\n "
306
+
307
+
361
308
has_error = False
362
309
363
310
LOGGER .info ("Configuration generation steps:" )
0 commit comments