InsightSoftwareConsortium / ITKRemoteModuleBuildTestPackageAction

A composite GitHub Action to build, test, and package, ITK remote modules
Apache License 2.0
3 stars 6 forks source link

ITKRemoteModuleBuildTestPackageAction

This project provides reusable GitHub Actions workflows to build, test, and package ITK external modules.

The Insight Toolkit (ITK) is an open-source, cross-platform system that provides developers with an extensive suite of software tools for image analysis. More information is available on the ITK website or at the ITK GitHub homepage.

Table of Contents

Motivation

The ITK ecosystem is driven by community contributions in the form of external modules that provide expanded functionality. Chapter 9 of the ITK Software Guide, "How To Create A Module", details the process to extend ITK.

Continuous Integration (CI) is a best software practice wherein proposed code changes are automatically built and tested for quality assurance. The goal of ITKRemoteModuleBuildTestPackageAction is to minimize the CI development burden for community members by providing workflows for common building, testing, and packaging procedures.

In most cases community members can leverage ITKRemoteModuleBuildTestPackageAction in their external module projects for several advantages:

Provided Workflows

Reusable workflow scripts are provided in the .github/workflows directory. Workflows are organized by target distribution:

Usage

ITKRemoteModuleBuildTestPackageAction may be used by ITK external modules that are hosted on GitHub to make use of GHA CI runners. The provided workflows assume that any build dependencies other than ITK will be fetched during the CMake build process.

Reusable workflows may be referenced inside an external module's .github/workflows/build-test-package.yml file to run when changes to the module are proposed. Input parameters may also be passed to the reusable workflow to guide the build/test procedure. See the inputs: field in any ITKRemoteModuleBuildTestPackageAction file for a list of parameters available for use.

More information on GitHub Actions reusable workflows is available in GitHub documentation.

Example Usage

An example GHA .yml file using ITKRemoteModuleBuildTestPackageAction workflows:

name: Build, test, package

on: [push,pull_request]

jobs:
  cxx-build-workflow:
    uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-cxx.yml@d4a5ce4f219b66b78269a15392e15c95f90e7e00
    with:
      itk-cmake-options: '-DITK_BUILD_DEFAULT_MODULES:BOOL=OFF -DITKGroup_Core:BOOL=ON'

  python-build-workflow:
    uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-package-python.yml@d4a5ce4f219b66b78269a15392e15c95f90e7e00
    secrets:
      pypi_password: ${{ secrets.pypi_password }}

The example above can be broken down line by line:

name: Build, test, package

The workflow name that will be used to group workflow runs under the "Action" tab on the external module's GitHub page.

on: [push, pull_request]

Run workflows every time a new commit is pushed or a pull request is entered on the module repository.

jobs:

The top-level jobs used to organize the run. Reusable workflows may provide multiple jobs.

  cxx-build-workflow:
    uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-cxx.yml@d4a5ce4f219b66b78269a15392e15c95f90e7e00

Tells GHA to fetch and run the build-test-cxx.yml workflow. A commit hash or tagged version may be provided.

    with:
      itk-cmake-options: '-DITK_BUILD_DEFAULT_MODULES:BOOL=OFF -DITKGroup_Core:BOOL=ON'

Passes input arguments to the reusable workflow. In this case the parameters provided in itk-cmake-options will be passed to the ITK configuration command so that only certain modules are built before the external module itself is subsequently built against ITK.

  python-build-workflow:
    uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-package-python.yml@d4a5ce4f219b66b78269a15392e15c95f90e7e00

Tells GHA to fetch and run the build-test-package-python.yml workflow. A commit hash or tagged version may be provided.

  secrets:
    pypi_password: ${{ secrets.pypi_password }}

Passes a secret from the external module repository to the workflow. In this case the pypi_password secret is required for automatically uploading Python wheel to the Python Package Index (PyPI) for distribution.

ITKSplitComponents is one example of an external module leveraging reusable workflows for continuous integration. Refer to ITKSplitComponent's GHA workflow

build-test-cxx Overview

The workflow defined in build-test-cxx.yml builds and tests the external module against a recent version of the Insight Toolkit. For efficiency, wrappings are not typically built as part of this workflow.

Several optional parameters are exposed to allow the external module to direct workflow execution.

  with:
    itk-git-tag: 'v5.3.0'
  with:
    itk-cmake-options: '-DITK_BUILD_DEFAULT_MODULES:BOOL=OFF'
  with:
    itk-module-deps: 'MeshToPolyData@3ad8f08:BSplineGradient@0.3.0'
  with:
    cmake-options: '-DBUILD_EXAMPLES:BOOL=ON'
  with:
    warnings-to-ignore: '\"libcleaver.a.*has no symbols\" \"libitkcleaver.*has no symbols\"'
  with:
    ctest-options: '-E \"elastix_run_example_COMPARE_IM|elastix_run_3DCT_lung.MI.bspline.ASGD.001_COMPARE_TP\"'

build-test-package-python Overview

The workflow defined in build-test-package-python.yml builds and packages Python wrappings for the external module against a fixed version of the Insight Toolkit.

Several optional parameters are exposed to allow the external module to direct workflow execution.

  with:
    cmake-options: '-DELASTIX_USE_OPENMP:BOOL=OFF'
  with:
    itk-wheel-tag: 'v5.3.0'
  with:
    itk-python-package-tag: 'v5.3.0'
  with:
    itk-python-package-org: 'InsightSoftwareConsortium'
  with:
    itk-module-deps: 'InsightSoftwareConsortium/ITKMeshToPolyData@3ad8f08:InsightSoftwareConsortium/ITKBSplineGradient@0.3.0'
  with:
    python3-minor-versions: '["7","8","9","10","11"]` # Builds for Python 3.7 through 3.11
  with:
    manylinux-platforms: '["_2_28-x64","2014-x64","_2_28-aarch64"]'
  with:
    test-notebooks: true

Contributing

Community contributions to ITKRemoteModuleBuildTestPackageAction are welcome!

Please read CONTRIBUTING.md for testing instructions and best practices before opening a pull request to contribute your changes. Also see ITK's contributing documentation for general best practices regarding ITK and external modules.

Workflow issues may be submitted to the ITKRemoteModuleBuildTestPackageAction issue tracker on GitHub.

Frequently Asked Questions

What target platforms and architectures are supported?

The build-test-cxx workflow supports building and running C++ tests on GitHub Actions runner images for Windows, Linux, and macOS. Image details are available here.

The build-test-package-python.yml workflow supports Python package generation for the following platforms and architectures:

What should I do if my target platform/architecture does not appear on the list above?

itk-wasm is another experimental path for reproducible execution across architectures, with planned support for ITK external module Python distributions. Read more at https://wasm.itk.org/.

If the answers above do not meet your platform needs, please open an issue in the project issue tracker for discussion, and consider contributing either time or funding to support development. The ITK open source ecosystem is driven through contributions from its community members.

Additional Notes

ITKRemoteModuleBuildTestPackageAction aims to provide boilerplate to simplify CI processes for the majority of ITK C++ external modules. However, it may not be feasible to adapt reusable workflows to fit every project's needs, particularly in the case where build setup requires fetching project-specific third party dependencies before building.

If your project requires build steps not currently addressed by ITKRemoteModuleBuildTestPackageAction then consider doing one of the following:

  1. Implement build setup steps in your project's CMake procedures in CMakeLists.txt such that building with CMake in a reusable workflow handles extraneous dependency retrieval steps.
  2. Fork the workflows in ITKRemoteModuleBuildTestPackageAction for your project and manually replicate subsequent updates in your workflow.
  3. Open a pull request to propose changes if the changes will generally benefit other external modules in the ITK ecosystem.
  4. Open an issue on ITKRemoteModuleBuildTestPackageAction.

Community Discussion

Please direct general questions and discussions to the ITK Discourse forum.

License

ITKRemoteModuleBuildTestPackageAction is distributed under the Apache License 2.0 (see LICENSE)