-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1798 from glotzerlab/refactor-ci
Refactor CI workflows
- Loading branch information
Showing
29 changed files
with
573 additions
and
1,338 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,242 @@ | ||
name: Build and test | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
config: | ||
type: string | ||
required: true | ||
image: | ||
type: string | ||
required: true | ||
build_runner: | ||
type: string | ||
required: true | ||
default: ubuntu-latest | ||
test_runner: | ||
type: string | ||
required: true | ||
default: ubuntu-latest | ||
test_docker_options: | ||
type: string | ||
required: false | ||
validate: | ||
type: string | ||
required: false | ||
|
||
env: | ||
# prevent deadlocked MPI tests from causing the job to cancel | ||
MPIEXEC_TIMEOUT: 3000 | ||
# allow mpirun to execute as root in the tests | ||
OMPI_ALLOW_RUN_AS_ROOT: 1 | ||
OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1 | ||
# allow openmpi to oversubscribe cores | ||
OMPI_MCA_rmaps_base_oversubscribe: 1 | ||
# prevent errors from mis-configured openib systems | ||
OMPI_MCA_btl: "vader,self" | ||
# skip running the CPU tests in GPU builds | ||
_HOOMD_SKIP_CPU_TESTS_WHEN_GPUS_PRESENT_: 1 | ||
# Require GPU tests in GPU builds. | ||
_HOOMD_REQUIRE_GPU_TESTS_IN_GPU_BUILDS_: 1 | ||
# import HOOMD out of the build directory | ||
PYTHONPATH: ${{ github.workspace }}/install | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ fromJson(inputs.build_runner) }} | ||
container: | ||
image: ${{ inputs.image == '' && null || inputs.image }} | ||
|
||
steps: | ||
- name: Set Werror on recent compilers | ||
run: | | ||
echo "CXXFLAGS=-Werror" >> $GITHUB_ENV | ||
- name: Clean workspace | ||
run: ( shopt -s dotglob nullglob; rm -rf ./* ) | ||
shell: bash | ||
- name: Checkout | ||
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 | ||
with: | ||
path: code | ||
submodules: true | ||
|
||
- name: Configure | ||
run: | | ||
if [[ ${BUILD_DEBUG} == "true" ]]; then BUILD_TYPE="Debug"; else BUILD_TYPE="Release"; fi | ||
echo "BUILD_TYPE=${BUILD_TYPE}" | ||
cmake -S code -B build -GNinja \ | ||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ | ||
-DENABLE_GPU=${ENABLE_GPU:-"OFF"} \ | ||
-DENABLE_MPI=${ENABLE_MPI:-"OFF"} \ | ||
-DENABLE_TBB=${ENABLE_TBB:-"OFF"} \ | ||
-DENABLE_LLVM=${ENABLE_LLVM:-"OFF"} \ | ||
-DBUILD_MD=${BUILD_MD:-"ON"} \ | ||
-DBUILD_MPCD=${BUILD_MD:-"ON"} \ | ||
-DBUILD_METAL=${BUILD_MD:-"ON"} \ | ||
-DBUILD_HPMC=${BUILD_HPMC:-"ON"} \ | ||
-DCUDA_ARCH_LIST="60;70" \ | ||
-DENABLE_DEBUG_JIT=ON \ | ||
-DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/install \ | ||
-DPLUGINS="" | ||
env: | ||
ENABLE_GPU: ${{ contains(inputs.config, 'cuda') }} | ||
ENABLE_MPI: ${{ contains(inputs.config, 'mpi') }} | ||
ENABLE_TBB: ${{ contains(inputs.config, 'tbb') }} | ||
ENABLE_LLVM: ${{ contains(inputs.config, 'llvm') }} | ||
BUILD_MD: ${{ !contains(inputs.config, 'nomd') }} | ||
BUILD_HPMC: ${{ !contains(inputs.config, 'nohpmc') }} | ||
BUILD_DEBUG: ${{ contains(inputs.config, 'debug') }} | ||
shell: bash | ||
|
||
- name: Build | ||
run: ninja install -j $(($(getconf _NPROCESSORS_ONLN) + 2)) -k 0 | ||
working-directory: build | ||
|
||
- name: Configure plugins | ||
run : | | ||
if [[ ${BUILD_DEBUG} == "true" ]]; then BUILD_TYPE="Debug"; else BUILD_TYPE="Release"; fi | ||
echo "BUILD_TYPE=${BUILD_TYPE}" | ||
CMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/install cmake -S code/example_plugins -B build-example-plugins -GNinja -DCMAKE_BUILD_TYPE=${BUILD_TYPE} | ||
env: | ||
BUILD_DEBUG: ${{ contains(inputs.config, 'debug') }} | ||
shell: bash | ||
|
||
- name: Build plugins | ||
run: ninja install -j $(($(getconf _NPROCESSORS_ONLN) + 2)) -k 0 | ||
working-directory: build-example-plugins | ||
|
||
- name: Remove object files | ||
run: find build -type f -name '*.o' -delete | ||
|
||
- name: 'Tar build' | ||
run: tar --use-compress-program='zstd -10 -T0' -cvf build.tar build | ||
|
||
- name: 'Tar install' | ||
run: tar --use-compress-program='zstd -10 -T0' -cvf install.tar install | ||
|
||
- name: 'Upload build' | ||
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 | ||
with: | ||
name: build-${{ inputs.config }}-${{ github.sha }} | ||
path: build.tar | ||
retention-days: 7 | ||
- name: 'Upload install' | ||
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 | ||
with: | ||
name: install-${{ inputs.config }}-${{ github.sha }} | ||
path: install.tar | ||
retention-days: 7 | ||
|
||
- name: Clean workspace | ||
run: ( shopt -s dotglob nullglob; rm -rf ./* ) | ||
shell: bash | ||
- name: Clean HOME | ||
run: ( shopt -s dotglob nullglob; rm -rf $HOME/* ) | ||
shell: bash | ||
|
||
|
||
pytest: | ||
needs: build | ||
runs-on: ${{ fromJson(inputs.test_runner) }} | ||
container: | ||
image: ${{ inputs.image == '' && null || inputs.image }} | ||
options: ${{ inputs.test_docker_options }} -e CUDA_VISIBLE_DEVICES | ||
|
||
steps: | ||
- name: Clean workspace | ||
run: ( shopt -s dotglob nullglob; rm -rf ./* ) | ||
shell: bash | ||
- name: Checkout | ||
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 | ||
with: | ||
path: code | ||
submodules: true | ||
|
||
- name: Download install | ||
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 | ||
with: | ||
name: install-${{ inputs.config }}-${{ github.sha }} | ||
- name: Untar install | ||
run: tar --use-compress-program='zstd -10 -T0' -xvf install.tar | ||
|
||
### Unit tests | ||
- name: Run pytest (serial) | ||
run: python3 -m pytest --pyargs hoomd -x -v -ra --durations=0 --durations-min=0.1 | ||
|
||
- name: Run pytest (mpi) | ||
if: ${{ contains(inputs.config, 'mpi') }} | ||
run: mpirun -n 2 ${GITHUB_WORKSPACE}/install/hoomd/pytest/pytest-openmpi.sh --pyargs hoomd -x -v -ra --durations=0 --durations-min=0.1 || (( cat pytest.out.1 && exit 1 )) | ||
|
||
- name: Run pytest (serial without cupy) | ||
if: ${{ contains(inputs.config, 'cuda') }} | ||
run: python3 -m pytest --pyargs hoomd -x -v -ra --durations=0 --durations-min=0.1 -m cupy_optional | ||
env: | ||
_HOOMD_DISALLOW_CUPY_: 1 | ||
|
||
- name: Run pytest (mpi without cupy) | ||
if: ${{ contains(inputs.config, 'cuda') && contains(inputs.config, 'mpi') }} | ||
run: mpirun -n 2 ${GITHUB_WORKSPACE}/install/hoomd/pytest/pytest-openmpi.sh --pyargs hoomd -x -v -ra --durations=0 --durations-min=0.1 -m cupy_optional || (( cat pytest.out.1 && exit 1 )) | ||
env: | ||
_HOOMD_DISALLOW_CUPY_: 1 | ||
|
||
### Validation tests | ||
- name: Run pytest -m validate (serial) | ||
if: ${{ !contains(inputs.config, 'mpi') && contains(github.event.pull_request.labels.*.name, 'validate') && inputs.validate == 'true' }} | ||
run: python3 -m pytest --pyargs hoomd -x -v -ra --durations=0 --durations-min=0.1 -p hoomd.pytest_plugin_validate -m validate --validate | ||
|
||
- name: Run pytest -m validate (mpi) | ||
if: ${{ contains(inputs.config, 'mpi') && contains(github.event.pull_request.labels.*.name, 'validate') && inputs.validate == 'true' }} | ||
run: mpirun -n 2 ${GITHUB_WORKSPACE}/install/hoomd/pytest/pytest-openmpi.sh --pyargs hoomd -x -v -ra --durations=0 --durations-min=0.1 -p hoomd.pytest_plugin_validate -m validate --validate || (( cat pytest.out.1 && exit 1 )) | ||
|
||
- name: Run howto guides (serial) | ||
if: ${{ contains(inputs.config, 'llvm') && contains(github.event.pull_request.labels.*.name, 'validate') && inputs.validate == 'true' }} # some examples require LLVM | ||
run: 'for i in *.py; do echo "Running howto: $i" && python3 $i || exit 1; done' | ||
working-directory: code/sphinx-doc/howto | ||
|
||
- name: Clean workspace | ||
run: ( shopt -s dotglob nullglob; rm -rf ./* ) | ||
shell: bash | ||
- name: Clean HOME | ||
run: ( shopt -s dotglob nullglob; rm -rf $HOME/* ) | ||
shell: bash | ||
|
||
|
||
ctest: | ||
needs: build | ||
runs-on: ${{ fromJson(inputs.test_runner) }} | ||
container: | ||
image: ${{ inputs.image == '' && null || inputs.image }} | ||
options: ${{ inputs.test_docker_options }} -e CUDA_VISIBLE_DEVICES | ||
|
||
steps: | ||
- name: Clean workspace | ||
run: ( shopt -s dotglob nullglob; rm -rf ./* ) | ||
shell: bash | ||
- name: Checkout | ||
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 | ||
with: | ||
path: code | ||
submodules: true | ||
|
||
- name: Download build | ||
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 | ||
with: | ||
name: build-${{ inputs.config }}-${{ github.sha }} | ||
- name: Untar build | ||
run: tar --use-compress-program='zstd -10 -T0' -xvf build.tar | ||
|
||
- name: Run tests | ||
run: >- | ||
ctest | ||
-T test | ||
--output-on-failure | ||
--test-output-size-failed 1048576 | ||
--test-output-size-passed 1048576 | ||
working-directory: build | ||
|
||
- name: Clean workspace | ||
run: ( shopt -s dotglob nullglob; rm -rf ./* ) | ||
shell: bash | ||
- name: Clean HOME | ||
run: ( shopt -s dotglob nullglob; rm -rf $HOME/* ) | ||
shell: bash |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.