Skip to content

Commit c717f6b

Browse files
authored
Do not download Python and CGAL on every self-hosted CI run (#782)
`actions/setup-python` downloads a Python build from GitHub on every run of our ephemeral self-hosted runners. A GitHub 504 during that download failed the CGAL job in the merge group of #780 today. The changed-line lint, CGAL and verification-report jobs now make a venv from the runner's system Python, which is 3.12 on Ubuntu 24.04, the version they requested. The CGAL job also installs `python3-dev` for the Python interface it builds. The GitHub-hosted fallback in `test` keeps `setup-python`, where the toolcache is local. The first merge-group run of this PR then failed one step later: SIMPLE fetches CGAL 6.0.1 from GitHub releases on every configure, also in the CGAL job, which already installs Ubuntu's `libcgal-dev` (5.6), and that download returned 504 as well. CMake now uses an installed CGAL of version 5.6 or later, header-only as before; SIMPLE includes only the AABB-tree, surface-mesh and STL-reader headers, which 5.6 provides. Without one it fetches 6.0.1 as before, now pinned by SHA-256. Both configure paths were checked locally, and the wall library builds against the fetched 6.0.1; the CGAL job compiles and runs the wall tests against 5.6. This PR's own merge-group run exercises the changed jobs. ## Risk tier - [x] T4: parallelism, GPU, dependency, CI, or security-sensitive build logic Chris&AI
1 parent 5bbb160 commit c717f6b

2 files changed

Lines changed: 46 additions & 26 deletions

File tree

‎.github/workflows/main.yml‎

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,14 @@ jobs:
6969
fetch-depth: 0
7070
ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha || github.sha }}
7171

72+
# The runner's Python 3.12 (Ubuntu 24.04); setup-python would download one
73+
# from GitHub on every run of this ephemeral runner.
7274
- name: Set up Python
73-
uses: actions/setup-python@v6
74-
with:
75-
python-version: "3.12"
75+
run: |
76+
sudo apt-get update
77+
sudo apt-get install -y --no-install-recommends python3-venv
78+
python3 -m venv "$RUNNER_TEMP/venv"
79+
echo "$RUNNER_TEMP/venv/bin" >> "$GITHUB_PATH"
7680
7781
- name: Install lint tools
7882
run: python -m pip install fprettify==0.3.7 ruff==0.14.1
@@ -457,11 +461,6 @@ jobs:
457461
with:
458462
fetch-depth: 0
459463

460-
- name: Set up Python
461-
uses: actions/setup-python@v6
462-
with:
463-
python-version: "3.12"
464-
465464
- name: Install system dependencies (CGAL)
466465
run: |
467466
sudo apt-get update
@@ -482,7 +481,12 @@ jobs:
482481
libopenblas-dev \
483482
liblapack-dev \
484483
libopenmpi-dev \
485-
openmpi-bin
484+
openmpi-bin \
485+
python3-dev \
486+
python3-venv
487+
# The runner's Python 3.12; setup-python would download one from GitHub.
488+
python3 -m venv "$RUNNER_TEMP/venv"
489+
echo "$RUNNER_TEMP/venv/bin" >> "$GITHUB_PATH"
486490
487491
- name: Install wall-test Python dependencies
488492
run: |
@@ -595,10 +599,13 @@ jobs:
595599
with:
596600
fetch-depth: 0
597601

602+
# The runner's Python 3.12; setup-python would download one from GitHub.
598603
- name: Set up Python
599-
uses: actions/setup-python@v6
600-
with:
601-
python-version: "3.12"
604+
run: |
605+
sudo apt-get update
606+
sudo apt-get install -y --no-install-recommends python3-venv
607+
python3 -m venv "$RUNNER_TEMP/venv"
608+
echo "$RUNNER_TEMP/venv/bin" >> "$GITHUB_PATH"
602609
603610
- name: Install build dependencies
604611
run: |

‎CMakeLists.txt‎

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -407,26 +407,39 @@ else()
407407
link_libraries(${NETCDF_FLIBS_LIST})
408408
endif()
409409

410-
# CGAL (optional, for STL wall intersections)
411-
# CGAL 5.x is header-only, fetch headers via FetchContent (don't run CGAL's CMake)
410+
# CGAL (optional, for STL wall intersections). Header-only: an installed CGAL
411+
# >= 5.6 is used as is; otherwise 6.0.1 is fetched, pinned by hash, so a
412+
# download failure cannot hit hosts that have CGAL.
412413
if(SIMPLE_ENABLE_CGAL)
413414
# CGAL requires Boost headers
414415
find_package(Boost REQUIRED)
415416
message(STATUS "Boost found: ${Boost_VERSION}")
416417

417-
include(FetchContent)
418-
FetchContent_Declare(
419-
cgal
420-
URL https://github.com/CGAL/cgal/releases/download/v6.0.1/CGAL-6.0.1.tar.xz
421-
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
422-
)
423-
FetchContent_GetProperties(cgal)
424-
if(NOT cgal_POPULATED)
425-
FetchContent_Populate(cgal)
418+
find_path(CGAL_INCLUDE_DIR CGAL/version.h)
419+
set(_cgal_version "")
420+
if(CGAL_INCLUDE_DIR)
421+
file(STRINGS "${CGAL_INCLUDE_DIR}/CGAL/version.h" _cgal_version_line
422+
REGEX "^#define CGAL_VERSION ")
423+
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" _cgal_version
424+
"${_cgal_version_line}")
425+
endif()
426+
if(_cgal_version AND _cgal_version VERSION_GREATER_EQUAL 5.6)
427+
message(STATUS "CGAL enabled from ${CGAL_INCLUDE_DIR}: ${_cgal_version} (header-only)")
428+
else()
429+
include(FetchContent)
430+
FetchContent_Declare(
431+
cgal
432+
URL https://github.com/CGAL/cgal/releases/download/v6.0.1/CGAL-6.0.1.tar.xz
433+
URL_HASH SHA256=0acdfbf317c556630dd526f3253780f29b6ec9713ee92903e81b5c93c0f59b7f
434+
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
435+
)
436+
FetchContent_GetProperties(cgal)
437+
if(NOT cgal_POPULATED)
438+
FetchContent_Populate(cgal)
439+
endif()
440+
set(CGAL_INCLUDE_DIR "${cgal_SOURCE_DIR}/include" CACHE PATH "CGAL headers" FORCE)
441+
message(STATUS "CGAL enabled via FetchContent: 6.0.1 (header-only)")
426442
endif()
427-
# CGAL 6.x is header-only, just add include path
428-
set(CGAL_INCLUDE_DIR "${cgal_SOURCE_DIR}/include")
429-
message(STATUS "CGAL enabled via FetchContent: 6.0.1 (header-only)")
430443
message(STATUS "CGAL include dir: ${CGAL_INCLUDE_DIR}")
431444
add_compile_definitions(SIMPLE_ENABLE_CGAL)
432445
else()

0 commit comments

Comments
 (0)