From 3730f9b7db1a747b73458f763e9e466e5a8726f9 Mon Sep 17 00:00:00 2001 From: Hans Johnson Date: Fri, 3 Apr 2026 17:05:13 -0500 Subject: [PATCH] ENH: Add platform-specific package install inputs and OS selection Add optional inputs to the CXX build workflow: - apt-packages: Install system packages on Linux (apt-get) - brew-packages: Install system packages on macOS (brew) - choco-packages: Install system packages on Windows (choco) - os-list: JSON array of runner OS labels to build on, allowing modules to disable platforms that cannot work Update README with: - Simplified example using secrets: inherit instead of explicit secrets block (avoids YAML errors from empty secrets:) - Example for modules with external system dependencies - Updated workflow ref from @main to @v5.4.6 Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/build-test-cxx.yml | 35 +++++++++++++++++++++++++++- README.md | 34 +++++++++++++++++++++++---- 2 files changed, 63 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-test-cxx.yml b/.github/workflows/build-test-cxx.yml index 360d729..89f2061 100644 --- a/.github/workflows/build-test-cxx.yml +++ b/.github/workflows/build-test-cxx.yml @@ -30,6 +30,23 @@ on: # example: MeshToPolyData@3ad8f08:BSplineGradient@0.3.0 required: false type: string + apt-packages: + description: 'Space-separated list of apt packages to install on Linux runners before building (e.g. libopenslide-dev libfftw3-dev)' + required: false + type: string + brew-packages: + description: 'Space-separated list of Homebrew packages to install on macOS runners before building (e.g. openslide libomp)' + required: false + type: string + choco-packages: + description: 'Space-separated list of Chocolatey packages to install on Windows runners before building' + required: false + type: string + os-list: + description: 'JSON-formatted array of runner OS labels to build on (default: all platforms)' + required: false + type: string + default: '["ubuntu-22.04", "windows-2022", "macos-15-intel", "macos-15"]' jobs: build-test-cxx: @@ -37,7 +54,7 @@ jobs: strategy: max-parallel: 3 matrix: - os: [ubuntu-22.04, windows-2022, macos-15-intel, macos-15] + os: ${{ fromJSON(inputs.os-list) }} include: - os: ubuntu-22.04 c-compiler: "gcc" @@ -65,6 +82,22 @@ jobs: with: large-packages: false + - name: Install system packages (Linux) + if: inputs.apt-packages != '' && runner.os == 'Linux' + run: | + sudo apt-get update -qq + sudo apt-get install -y -qq ${{ inputs.apt-packages }} + + - name: Install system packages (macOS) + if: inputs.brew-packages != '' && runner.os == 'macOS' + run: | + brew install ${{ inputs.brew-packages }} + + - name: Install system packages (Windows) + if: inputs.choco-packages != '' && runner.os == 'Windows' + run: | + choco install -y ${{ inputs.choco-packages }} + - name: Set up Python 3.11 uses: actions/setup-python@v5 with: diff --git a/README.md b/README.md index 6d5834a..20936a0 100644 --- a/README.md +++ b/README.md @@ -87,14 +87,38 @@ on: [push,pull_request] jobs: cxx-build-workflow: - uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-cxx.yml@main + uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-cxx.yml@v5.4.6 + + python-build-workflow: + uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-package-python.yml@v5.4.6 + secrets: inherit +``` + +> **Note:** `secrets: inherit` passes all repository secrets (including `pypi_password`) +> to the reusable workflow. This is simpler than explicitly listing each secret and avoids +> YAML errors from empty `secrets:` blocks. Alternatively, you can pass secrets explicitly: +> ```yaml +> secrets: +> pypi_password: ${{ secrets.pypi_password }} +> ``` + +#### Modules with external system dependencies + +Modules that require system libraries not available on standard runners can use +the `apt-packages`, `brew-packages`, `choco-packages`, and `os-list` inputs: + +```yaml +jobs: + cxx-build-workflow: + uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-cxx.yml@v5.4.6 with: - itk-cmake-options: '-DITK_BUILD_DEFAULT_MODULES:BOOL=OFF -DITKGroup_Core:BOOL=ON' + apt-packages: 'libopenslide-dev' + brew-packages: 'openslide' + os-list: '["ubuntu-22.04", "macos-15-intel", "macos-15"]' python-build-workflow: - uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-package-python.yml@main - secrets: - pypi_password: ${{ secrets.pypi_password }} + uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-package-python.yml@v5.4.6 + secrets: inherit ``` The example above can be broken down line by line: