From 46c122300892ccfce64747c148cc3f49dcb9b91a Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Tue, 28 Nov 2023 08:57:01 -0500 Subject: [PATCH 01/26] Skeleton HOOMD-blue component. --- .ruff.toml | 50 ++++++++++++++++++++++++++++++++++ CMakeLists.txt | 21 +++++++++++++++ README.md | 0 src/CMakeLists.txt | 55 ++++++++++++++++++++++++++++++++++++++ src/__init__.py | 8 ++++++ src/module.cc | 25 +++++++++++++++++ src/pytest/CMakeLists.txt | 12 +++++++++ src/pytest/__init__.py | 4 +++ src/pytest/test_version.py | 8 ++++++ src/version.py | 3 +++ 10 files changed, 186 insertions(+) create mode 100644 .ruff.toml create mode 100644 CMakeLists.txt create mode 100644 README.md create mode 100644 src/CMakeLists.txt create mode 100644 src/__init__.py create mode 100644 src/module.cc create mode 100644 src/pytest/CMakeLists.txt create mode 100644 src/pytest/__init__.py create mode 100644 src/pytest/test_version.py create mode 100644 src/version.py diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 0000000..72cf54a --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,50 @@ +target-version = "py38" + +extend-select = [ + "A", + "B", + "D", + "E501", + "EM", + "I", + "ICN", + "ISC", + "N", + "NPY", + "PL", + "PT", + "RET", + "RUF", + "UP", + "W", +] + +ignore = [ + "N806", "N803", # Allow occasional use of uppercase variable and argument names (e.g. N). + "D107", # Do not document __init__ separately from the class. + "PLR09", # Allow "too many" statements/arguments/etc... + "N816", # Allow mixed case names like kT. +] + +[lint.per-file-ignores] + +"__init__.py" = ["F401", # __init__.py import submodules for use by the package importer. +] + +[pydocstyle] +convention = "google" + +[format] +quote-style = "single" + +[lint.flake8-import-conventions] +# Prefer no import aliases +aliases = {} +# Always import hoomd without 'from' +banned-from = ["hoomd"] + +# Ban standard import conventions and force common packages to be imported by their actual name. +[lint.flake8-import-conventions.banned-aliases] +"numpy" = ["np"] +"pandas" = ["pd"] +"matplotlib" = ["mpl"] diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..ad254d8 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,21 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 3.9 FATAL_ERROR) + +# Name the plugin project. +# TODO: Set the project title to the name of your Python package. +project(hoomd_component_template LANGUAGES C CXX) + +# Find the installed HOOMD. +find_package(HOOMD 4.0.0 REQUIRED) + +message(STATUS "Found HOOMD ${HOOMD_VERSION}: ${HOOMD_INSTALL_PREFIX}/${PYTHON_SITE_INSTALL_DIR}") + +# Force installation to the HOOMD installation location. +set(CMAKE_INSTALL_PREFIX ${HOOMD_INSTALL_PREFIX} CACHE PATH "Installation prefix" FORCE) + +# Enable compiler warnings on gcc and clang. +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wconversion -Wno-sign-conversion -Wno-unknown-pragmas -Wno-deprecated-declarations -Wno-unused-result") +endif() + +# Add the component's source directory. +add_subdirectory(src) diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..baeff43 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,55 @@ +# TODO: Set COMPONENT_NAME to the name of your Python package. +set(COMPONENT_NAME template) + +# TODO: List all host C++ source code files in _${COMPONENT_NAME}_sources. +set(_${COMPONENT_NAME}_sources + module.cc + ) + +# TODO: List all GPU C++ source code files in _${COMPONENT_NAME}_cu_sources. +set(_${COMPONENT_NAME}_cu_sources + PotentialPairExampleGPUKernel.cu + ) + +# TODO: List all Python modules in files. +set(files + __init__.py + version.py + ) + +if (ENABLE_HIP) +set(_cuda_sources ${_${COMPONENT_NAME}_cu_sources}) +endif (ENABLE_HIP) + +pybind11_add_module(_${COMPONENT_NAME} SHARED ${_${COMPONENT_NAME}_sources} ${_cuda_sources} NO_EXTRAS) +# Alias into the HOOMD namespace so that external and symlinked components both work. +add_library(HOOMD::_${COMPONENT_NAME} ALIAS _${COMPONENT_NAME}) + +if (APPLE) +set_target_properties(_${COMPONENT_NAME} PROPERTIES INSTALL_RPATH "@loader_path/..;@loader_path") +else() +set_target_properties(_${COMPONENT_NAME} PROPERTIES INSTALL_RPATH "\$ORIGIN/..;\$ORIGIN") +endif() + +# Link the library to its dependencies. Add or remove HOOMD extension modules (and/or external C++ +# libraries) as needed. +target_link_libraries(_${COMPONENT_NAME} + PUBLIC HOOMD::_hoomd + PUBLIC HOOMD::_md + ) + +# Install the library. +install(TARGETS _${COMPONENT_NAME} + LIBRARY DESTINATION ${PYTHON_SITE_INSTALL_DIR}/${COMPONENT_NAME} + ) + +# Install the Python package. +install(FILES ${python_files} + DESTINATION ${PYTHON_SITE_INSTALL_DIR}/${COMPONENT_NAME} + ) + +# Copy the Python package to the build directory. +copy_files_to_build("${files}" "hoomd-component-${COMPONENT_NAME}" "*.py") + +# Python tests. +add_subdirectory(pytest) diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..30fd9dc --- /dev/null +++ b/src/__init__.py @@ -0,0 +1,8 @@ +# Copyright (c) 2009-2023 The Regents of the University of Michigan. +# Part of HOOMD-blue, released under the BSD 3-Clause License. + +"""Template HOOMD-blue component.""" +# TODO: Document your component. + +# TODO: Import all Python modules in your component. +from . import version diff --git a/src/module.cc b/src/module.cc new file mode 100644 index 0000000..f8a67ab --- /dev/null +++ b/src/module.cc @@ -0,0 +1,25 @@ +// Copyright (c) 2009-2023 The Regents of the University of Michigan. +// Part of HOOMD-blue, released under the BSD 3-Clause License. + +// TODO: Include the header files of classes that will be exported to Python. + +#include + +namespace hoomd + { +namespace md + { + +// TODO: Set the name of the python module to match ${COMPONENT_NAME} (set in CMakeLists.txt), +// prefixed with an underscore. +PYBIND11_MODULE(_template, m) + { + // TODO: Call export_Class(m) for each C++ class to be exported to Python. + +#ifdef ENABLE_HIP + // TODO: Call export_ClassGPU(m) for each GPU enabled C++ class to be exported to Python. +#endif + } + + } // end namespace md + } // end namespace hoomd diff --git a/src/pytest/CMakeLists.txt b/src/pytest/CMakeLists.txt new file mode 100644 index 0000000..919b52a --- /dev/null +++ b/src/pytest/CMakeLists.txt @@ -0,0 +1,12 @@ +# TODO: List all pytest files in files. +set(files __init__.py + test_version.py + ) + +# Copy tests to the install directory. +install(FILES ${files} + DESTINATION ${PYTHON_SITE_INSTALL_DIR}/${COMPONENT_NAME}/pytest + ) + +# Copy tests to the build directory for testing prior to installation. +copy_files_to_build("${files}" "hoomd-component-${COMPONENT_NAME}-pytest" "*.py") diff --git a/src/pytest/__init__.py b/src/pytest/__init__.py new file mode 100644 index 0000000..c6121fc --- /dev/null +++ b/src/pytest/__init__.py @@ -0,0 +1,4 @@ +# Copyright (c) 2009-2023 The Regents of the University of Michigan. +# Part of HOOMD-blue, released under the BSD 3-Clause License. + +"""Unit tests.""" diff --git a/src/pytest/test_version.py b/src/pytest/test_version.py new file mode 100644 index 0000000..404190b --- /dev/null +++ b/src/pytest/test_version.py @@ -0,0 +1,8 @@ +"""Test the version module.""" + +import hoomd.template + + +def test_version(): + """Test the version attribute.""" + assert hoomd.template.version.version == '0.0.0' diff --git a/src/version.py b/src/version.py new file mode 100644 index 0000000..2ab05ab --- /dev/null +++ b/src/version.py @@ -0,0 +1,3 @@ +"""Version information.""" + +version = '0.0.0' From 68f14becf6849b61cb1d3da0a341209e8f1ab571 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Tue, 28 Nov 2023 09:06:59 -0500 Subject: [PATCH 02/26] Add pre-commit configuration. --- .pre-commit-config.yaml | 56 ++++++++++++++++++++++++++++++++++++++ src/module.cc | 24 ++++++++-------- src/pytest/test_version.py | 3 ++ src/version.py | 3 ++ 4 files changed, 73 insertions(+), 13 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..dff86f1 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,56 @@ +ci: + autoupdate_schedule: quarterly + autoupdate_branch: 'trunk' + autofix_prs: false + +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: 'v4.4.0' + hooks: + - id: end-of-file-fixer + exclude_types: [svg] + - id: trailing-whitespace + exclude_types: [svg] + - id: check-json + - id: check-yaml + - id: check-case-conflict + - id: fix-encoding-pragma + args: + - --remove + - id: mixed-line-ending +- repo: https://github.com/glotzerlab/fix-license-header + rev: v0.2.0 + hooks: + - id: fix-license-header + name: Fix license headers (Python) + types_or: [python] + args: + - --license-file=LICENSE + - --add=Part of HOOMD-blue, released under the BSD 3-Clause License. + - --keep-before=#! + - id: fix-license-header + name: Fix license headers (C) + types_or: [c, c++, cuda, inc] + args: + - --license-file=LICENSE + - --add=Part of HOOMD-blue, released under the BSD 3-Clause License. + - --comment-prefix=// + - id: fix-license-header + name: Fix license headers (reStructuredText) + types_or: [rst] + args: + - --license-file=LICENSE + - --add=Part of HOOMD-blue, released under the BSD 3-Clause License. + - --keep-after=.. include + - --comment-prefix=.. +- repo: https://github.com/pre-commit/mirrors-clang-format + rev: v16.0.6 + hooks: + - id: clang-format + types_or: [c, c++, cuda, inc] +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.4 + hooks: + - id: ruff-format + - id: ruff + diff --git a/src/module.cc b/src/module.cc index f8a67ab..8ee8b91 100644 --- a/src/module.cc +++ b/src/module.cc @@ -5,21 +5,19 @@ #include -namespace hoomd - { -namespace md - { +namespace hoomd { +namespace md { -// TODO: Set the name of the python module to match ${COMPONENT_NAME} (set in CMakeLists.txt), -// prefixed with an underscore. -PYBIND11_MODULE(_template, m) - { - // TODO: Call export_Class(m) for each C++ class to be exported to Python. +// TODO: Set the name of the python module to match ${COMPONENT_NAME} (set in +// CMakeLists.txt), prefixed with an underscore. +PYBIND11_MODULE(_template, m) { + // TODO: Call export_Class(m) for each C++ class to be exported to Python. #ifdef ENABLE_HIP - // TODO: Call export_ClassGPU(m) for each GPU enabled C++ class to be exported to Python. + // TODO: Call export_ClassGPU(m) for each GPU enabled C++ class to be exported + // to Python. #endif - } +} - } // end namespace md - } // end namespace hoomd +} // end namespace md +} // end namespace hoomd diff --git a/src/pytest/test_version.py b/src/pytest/test_version.py index 404190b..fea608c 100644 --- a/src/pytest/test_version.py +++ b/src/pytest/test_version.py @@ -1,3 +1,6 @@ +# Copyright (c) 2009-2023 The Regents of the University of Michigan. +# Part of HOOMD-blue, released under the BSD 3-Clause License. + """Test the version module.""" import hoomd.template diff --git a/src/version.py b/src/version.py index 2ab05ab..5969534 100644 --- a/src/version.py +++ b/src/version.py @@ -1,3 +1,6 @@ +# Copyright (c) 2009-2023 The Regents of the University of Michigan. +# Part of HOOMD-blue, released under the BSD 3-Clause License. + """Version information.""" version = '0.0.0' From 92d12e0b1f4bdb45c28a15b2409806ef8df0f161 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Tue, 28 Nov 2023 09:20:25 -0500 Subject: [PATCH 03/26] Add pre-commit github action and dependabot configuration. --- .github/dependabot.yml | 12 ++++++++++++ .github/workflows/pre-commit.yaml | 23 +++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/pre-commit.yaml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..bba0703 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + target-branch: trunk + schedule: + interval: "weekly" + time: "07:00" + timezone: "EST5EDT" + pull-request-branch-name: + separator: "-" + open-pull-requests-limit: 2 diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml new file mode 100644 index 0000000..6c8d1c5 --- /dev/null +++ b/.github/workflows/pre-commit.yaml @@ -0,0 +1,23 @@ +name: pre-commit + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + pull_request: + push: + branches: [trunk] + + workflow_dispatch: + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: '3.12' + - run: pip install pre-commit + - run: pre-commit run --all-files From 942cc05624a094f1f1b3cd65d62825e9cd64d702 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Tue, 28 Nov 2023 10:41:49 -0500 Subject: [PATCH 04/26] Add clang-format configuration. --- .clang-format | 36 ++++++++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 1 - src/module.cc | 21 ++++++++++++--------- 3 files changed, 48 insertions(+), 10 deletions(-) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..684ae7a --- /dev/null +++ b/.clang-format @@ -0,0 +1,36 @@ +--- +BasedOnStyle: WebKit +AccessModifierOffset: 0 +AlignAfterOpenBracket: Align +AlignEscapedNewlines: 'Left' +AlignOperands: 'true' +AlignTrailingComments: 'true' +AllowAllArgumentsOnNextLine: 'false' +AllowAllParametersOfDeclarationOnNextLine: 'false' +AllowShortFunctionsOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: 'false' +AllowShortLoopsOnASingleLine: 'false' +BinPackArguments: 'false' +BinPackParameters: 'false' +BreakBeforeBraces: Whitesmiths +BreakConstructorInitializers: BeforeColon +ColumnLimit: '100' +CompactNamespaces: 'true' +Cpp11BracedListStyle: 'true' +FixNamespaceComments: 'true' +IndentWidth: '4' +KeepEmptyLinesAtTheStartOfBlocks: false +Language: Cpp +NamespaceIndentation: None +PointerAlignment: Left +SortIncludes: 'true' +SpaceAfterCStyleCast: 'false' +SpaceAfterTemplateKeyword: 'false' +SpaceBeforeParens: ControlStatements +SpacesInAngles: 'false' +SpaceInEmptyParentheses: false +Standard: Cpp11 +TabWidth: '4' +UseTab: Never + +... diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dff86f1..147dc1c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -53,4 +53,3 @@ repos: hooks: - id: ruff-format - id: ruff - diff --git a/src/module.cc b/src/module.cc index 8ee8b91..2763883 100644 --- a/src/module.cc +++ b/src/module.cc @@ -5,19 +5,22 @@ #include -namespace hoomd { -namespace md { +namespace hoomd + { +namespace md + { // TODO: Set the name of the python module to match ${COMPONENT_NAME} (set in // CMakeLists.txt), prefixed with an underscore. -PYBIND11_MODULE(_template, m) { - // TODO: Call export_Class(m) for each C++ class to be exported to Python. +PYBIND11_MODULE(_template, m) + { + // TODO: Call export_Class(m) for each C++ class to be exported to Python. #ifdef ENABLE_HIP - // TODO: Call export_ClassGPU(m) for each GPU enabled C++ class to be exported - // to Python. + // TODO: Call export_ClassGPU(m) for each GPU enabled C++ class to be exported + // to Python. #endif -} + } -} // end namespace md -} // end namespace hoomd + } // end namespace md + } // end namespace hoomd From 22d9117c562d60d928ad0e23245f2eface95c7bb Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Tue, 28 Nov 2023 11:46:44 -0500 Subject: [PATCH 05/26] Add unit test configuration. --- .github/workflows/unit-test.yaml | 96 ++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 .github/workflows/unit-test.yaml diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml new file mode 100644 index 0000000..fda55e5 --- /dev/null +++ b/.github/workflows/unit-test.yaml @@ -0,0 +1,96 @@ +name: Unit test + +env: + # TODO: Set COMPONENT_NAME to the name of your Python package. + COMPONENT_NAME: template + + # Most components should not modify the rest of this file. When needed, merge in updates from + # https://github.com/glotzerlab/hoomd-component-template/ + + ############################################################################################# + # 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 + # import HOOMD out of the build directory + PYTHONPATH: ${{ github.workspace }}/install + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + pull_request: + push: + branches: [trunk] + + workflow_dispatch: + +defaults: + run: + shell: bash + +jobs: + build_test: + name: Build and test [${{ matrix.name }}] + runs-on: ubuntu-latest + container: + image: glotzerlab/ci:2023.11.27-cuda120_gcc11_py310 + strategy: + matrix: + include: + - name: 'CPU' + enable_gpu: 'OFF' + enable_mpi: 'OFF' +# - name: 'CPU, MPI' +# enable_gpu: 'OFF' +# enable_mpi: 'ON' +# - name: 'GPU' +# enable_gpu: 'ON' +# enable_mpi: 'OFF' +# - name: 'GPU, MPI' +# enable_gpu: 'ON' +# enable_mpi: 'ON' + + steps: + - name: Checkout HOOMD-blue + uses: actions/checkout@v4 + with: + repository: glotzerlab/hoomd-blue + path: hoomd-blue + submodules: true + - name: Configure HOOMD-blue + run: | + cmake -B build-hoomd-blue -S hoomd-blue \ + -GNinja \ + -DCMAKE_BUILD_TYPE=Release \ + -DENABLE_GPU=${ENABLE_GPU} \ + -DENABLE_MPI=${ENABLE_MPI} \ + -DCUDA_ARCH_LIST="70" \ + -DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/install + - name: Build HOOMD-blue + run: ninja install -j $(($(getconf _NPROCESSORS_ONLN) + 2)) + working-directory: build-hoomd-blue + + - name: Checkout component + uses: actions/checkout@v4 + with: + path: component + - name: Configure component + run: CMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/install cmake -S component -B build-component -GNinja -DCMAKE_BUILD_TYPE=Release + - name: Build component + run: ninja install -j $(($(getconf _NPROCESSORS_ONLN) + 2)) + working-directory: build-component + + - name: Run pytest (serial) + run: python3 -m pytest --pyargs hoomd.${COMPONENT_NAME} -x -v -ra --durations=0 --durations-min=0.1 + - name: Run pytest (MPI) + if: ${{ matrix.enable_mpi == 'ON' }} + run: mpirun -n 2 ${GITHUB_WORKSPACE}/install/hoomd/pytest/pytest-openmpi.sh --pyargs hoomd.${COMPONENT_NAME} -x -v -ra --durations=0 --durations-min=0.1 || (( cat pytest.out.1 && exit 1 )) From cf88360811338fbeec77cbdba26f7406b365af59 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Tue, 28 Nov 2023 12:19:13 -0500 Subject: [PATCH 06/26] Install a specific HOOMD-blue version. --- .github/workflows/unit-test.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index fda55e5..4283c5b 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -8,6 +8,8 @@ env: # https://github.com/glotzerlab/hoomd-component-template/ ############################################################################################# + # HOOMD-blue version to build. + HOOMD_BLUE_VERSION: 4.3.0 # prevent deadlocked MPI tests from causing the job to cancel MPIEXEC_TIMEOUT: 3000 # allow mpirun to execute as root in the tests @@ -22,6 +24,7 @@ env: # import HOOMD out of the build directory PYTHONPATH: ${{ github.workspace }}/install + concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -66,6 +69,7 @@ jobs: repository: glotzerlab/hoomd-blue path: hoomd-blue submodules: true + ref: v${{ env.HOOMD_BLUE_VERSION }} - name: Configure HOOMD-blue run: | cmake -B build-hoomd-blue -S hoomd-blue \ @@ -74,7 +78,12 @@ jobs: -DENABLE_GPU=${ENABLE_GPU} \ -DENABLE_MPI=${ENABLE_MPI} \ -DCUDA_ARCH_LIST="70" \ + -DBUILD_TESTING=OFF \ + -DPLUGINS="" \ -DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/install + env: + ENABLE_GPU: ${{ matrix.enable_gpu }} + ENABLE_MPI: ${{ matrix.enable_mpi }} - name: Build HOOMD-blue run: ninja install -j $(($(getconf _NPROCESSORS_ONLN) + 2)) working-directory: build-hoomd-blue From d1af784d5344ffa166933d3408dd0a8f0a86cbe9 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Tue, 28 Nov 2023 12:19:54 -0500 Subject: [PATCH 07/26] Install python files correctly. --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index baeff43..fae7ca7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -44,7 +44,7 @@ install(TARGETS _${COMPONENT_NAME} ) # Install the Python package. -install(FILES ${python_files} +install(FILES ${files} DESTINATION ${PYTHON_SITE_INSTALL_DIR}/${COMPONENT_NAME} ) From 22800c4c73261240b6358bfe1def633fb7eae872 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Tue, 28 Nov 2023 12:52:06 -0500 Subject: [PATCH 08/26] Cache HOOMD-blue builds. --- .github/workflows/unit-test.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index 4283c5b..43a9256 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -63,7 +63,14 @@ jobs: # enable_mpi: 'ON' steps: + - name: Cache HOOMD-blue build + id: cache + uses: actions/cache@v3 + with: + path: install + key: hoomd-blue-${{ env.HOOMD_BLUE_VERSION }}-${{ runner.os }}-mpi-${{ matrix.enable_mpi }}-gpu-${{ matrix.enable_gpu }} - name: Checkout HOOMD-blue + if: steps.cache.outputs.cache-hit != 'true' uses: actions/checkout@v4 with: repository: glotzerlab/hoomd-blue @@ -71,6 +78,7 @@ jobs: submodules: true ref: v${{ env.HOOMD_BLUE_VERSION }} - name: Configure HOOMD-blue + if: steps.cache.outputs.cache-hit != 'true' run: | cmake -B build-hoomd-blue -S hoomd-blue \ -GNinja \ @@ -85,6 +93,7 @@ jobs: ENABLE_GPU: ${{ matrix.enable_gpu }} ENABLE_MPI: ${{ matrix.enable_mpi }} - name: Build HOOMD-blue + if: steps.cache.outputs.cache-hit != 'true' run: ninja install -j $(($(getconf _NPROCESSORS_ONLN) + 2)) working-directory: build-hoomd-blue From c43a0df23f3cffff3b5ce6d513dee7c261a428ae Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Tue, 28 Nov 2023 14:30:13 -0500 Subject: [PATCH 09/26] Enable full test matrix. --- .github/workflows/unit-test.yaml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index 43a9256..3fac68b 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -52,15 +52,15 @@ jobs: - name: 'CPU' enable_gpu: 'OFF' enable_mpi: 'OFF' -# - name: 'CPU, MPI' -# enable_gpu: 'OFF' -# enable_mpi: 'ON' -# - name: 'GPU' -# enable_gpu: 'ON' -# enable_mpi: 'OFF' -# - name: 'GPU, MPI' -# enable_gpu: 'ON' -# enable_mpi: 'ON' + - name: 'CPU, MPI' + enable_gpu: 'OFF' + enable_mpi: 'ON' + - name: 'GPU' + enable_gpu: 'ON' + enable_mpi: 'OFF' + - name: 'GPU, MPI' + enable_gpu: 'ON' + enable_mpi: 'ON' steps: - name: Cache HOOMD-blue build From 67f47d479fecd2ae1567bfdc5c22f0505dd822fa Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Tue, 28 Nov 2023 15:51:06 -0500 Subject: [PATCH 10/26] Fix GPU tests. --- .github/workflows/unit-test.yaml | 2 -- src/CMakeLists.txt | 1 - 2 files changed, 3 deletions(-) diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index 3fac68b..a2b43bb 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -19,8 +19,6 @@ env: 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 # import HOOMD out of the build directory PYTHONPATH: ${{ github.workspace }}/install diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fae7ca7..c6cbd69 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,7 +8,6 @@ set(_${COMPONENT_NAME}_sources # TODO: List all GPU C++ source code files in _${COMPONENT_NAME}_cu_sources. set(_${COMPONENT_NAME}_cu_sources - PotentialPairExampleGPUKernel.cu ) # TODO: List all Python modules in files. From ffcb259879d162656e5e68ac038a86e36a6b5710 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Wed, 29 Nov 2023 08:58:17 -0500 Subject: [PATCH 11/26] Save HOOMD-blue cache after a successful build. Enable reuse of the HOOMD-blue cache when the component tests fail. --- .github/workflows/unit-test.yaml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index a2b43bb..d383df1 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -61,9 +61,9 @@ jobs: enable_mpi: 'ON' steps: - - name: Cache HOOMD-blue build + - name: Restore cached HOOMD-blue build id: cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: install key: hoomd-blue-${{ env.HOOMD_BLUE_VERSION }}-${{ runner.os }}-mpi-${{ matrix.enable_mpi }}-gpu-${{ matrix.enable_gpu }} @@ -94,6 +94,11 @@ jobs: if: steps.cache.outputs.cache-hit != 'true' run: ninja install -j $(($(getconf _NPROCESSORS_ONLN) + 2)) working-directory: build-hoomd-blue + - name: Cache HOOMD-blue build + uses: actions/cache/save@v3 + with: + path: install + key: hoomd-blue-${{ env.HOOMD_BLUE_VERSION }}-${{ runner.os }}-mpi-${{ matrix.enable_mpi }}-gpu-${{ matrix.enable_gpu }} - name: Checkout component uses: actions/checkout@v4 From 3ffa0fca23e51dba1cceaa107cef881f8ad1f646 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Wed, 29 Nov 2023 09:21:23 -0500 Subject: [PATCH 12/26] Save cache only when there is no hit. --- .github/workflows/unit-test.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index d383df1..a31408e 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -95,6 +95,7 @@ jobs: run: ninja install -j $(($(getconf _NPROCESSORS_ONLN) + 2)) working-directory: build-hoomd-blue - name: Cache HOOMD-blue build + if: steps.cache.outputs.cache-hit != 'true' uses: actions/cache/save@v3 with: path: install From aee954077c7b2f38713074a039992a63e3cb5b8c Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Wed, 29 Nov 2023 09:48:04 -0500 Subject: [PATCH 13/26] Add container image name to cache key. --- .github/workflows/unit-test.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index a31408e..f3a6adc 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -66,7 +66,7 @@ jobs: uses: actions/cache/restore@v3 with: path: install - key: hoomd-blue-${{ env.HOOMD_BLUE_VERSION }}-${{ runner.os }}-mpi-${{ matrix.enable_mpi }}-gpu-${{ matrix.enable_gpu }} + key: hoomd-blue-${{ env.HOOMD_BLUE_VERSION }}-2023.11.27-cuda120_gcc11_py310-mpi-${{ matrix.enable_mpi }}-gpu-${{ matrix.enable_gpu }} - name: Checkout HOOMD-blue if: steps.cache.outputs.cache-hit != 'true' uses: actions/checkout@v4 @@ -99,7 +99,7 @@ jobs: uses: actions/cache/save@v3 with: path: install - key: hoomd-blue-${{ env.HOOMD_BLUE_VERSION }}-${{ runner.os }}-mpi-${{ matrix.enable_mpi }}-gpu-${{ matrix.enable_gpu }} + key: hoomd-blue-${{ env.HOOMD_BLUE_VERSION }}-2023.11.27-cuda120_gcc11_py310-mpi-${{ matrix.enable_mpi }}-gpu-${{ matrix.enable_gpu }} - name: Checkout component uses: actions/checkout@v4 From 3e059f7bc7e3a26dae6d0f8f2d18ce227381c2a6 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Wed, 29 Nov 2023 09:48:24 -0500 Subject: [PATCH 14/26] Make test fail. Ensure that the cache uploads. --- src/pytest/test_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pytest/test_version.py b/src/pytest/test_version.py index fea608c..82583f6 100644 --- a/src/pytest/test_version.py +++ b/src/pytest/test_version.py @@ -8,4 +8,4 @@ def test_version(): """Test the version attribute.""" - assert hoomd.template.version.version == '0.0.0' + assert hoomd.template.version.version == '0.0.1' From 0cb263a5bb27af80bea50028d90b901e3d0e6a24 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Wed, 29 Nov 2023 10:22:21 -0500 Subject: [PATCH 15/26] Complete all tests in the matrix. --- .github/workflows/unit-test.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index f3a6adc..722f6df 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -45,6 +45,7 @@ jobs: container: image: glotzerlab/ci:2023.11.27-cuda120_gcc11_py310 strategy: + fail-fast: false matrix: include: - name: 'CPU' From 43fb4ae997c048988bfb28874336158fe25f79ed Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Wed, 29 Nov 2023 11:08:38 -0500 Subject: [PATCH 16/26] Use more descriptive variable names for files. --- src/CMakeLists.txt | 8 ++++---- src/pytest/CMakeLists.txt | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c6cbd69..d1f2bc3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,8 +10,8 @@ set(_${COMPONENT_NAME}_sources set(_${COMPONENT_NAME}_cu_sources ) -# TODO: List all Python modules in files. -set(files +# TODO: List all Python modules in python_files. +set(python_files __init__.py version.py ) @@ -43,12 +43,12 @@ install(TARGETS _${COMPONENT_NAME} ) # Install the Python package. -install(FILES ${files} +install(FILES ${python_files} DESTINATION ${PYTHON_SITE_INSTALL_DIR}/${COMPONENT_NAME} ) # Copy the Python package to the build directory. -copy_files_to_build("${files}" "hoomd-component-${COMPONENT_NAME}" "*.py") +copy_files_to_build("${python_files}" "hoomd-component-${COMPONENT_NAME}" "*.py") # Python tests. add_subdirectory(pytest) diff --git a/src/pytest/CMakeLists.txt b/src/pytest/CMakeLists.txt index 919b52a..8f2d47e 100644 --- a/src/pytest/CMakeLists.txt +++ b/src/pytest/CMakeLists.txt @@ -1,12 +1,12 @@ -# TODO: List all pytest files in files. -set(files __init__.py +# TODO: List all pytest files in test_files. +set(test_files __init__.py test_version.py ) # Copy tests to the install directory. -install(FILES ${files} +install(FILES ${test_files} DESTINATION ${PYTHON_SITE_INSTALL_DIR}/${COMPONENT_NAME}/pytest ) # Copy tests to the build directory for testing prior to installation. -copy_files_to_build("${files}" "hoomd-component-${COMPONENT_NAME}-pytest" "*.py") +copy_files_to_build("${test_files}" "hoomd-component-${COMPONENT_NAME}-pytest" "*.py") From 1e72f3fb1f8bc19abad047cb1486382ecd7b9066 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Wed, 29 Nov 2023 11:09:06 -0500 Subject: [PATCH 17/26] Restore version test. --- src/pytest/test_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pytest/test_version.py b/src/pytest/test_version.py index 82583f6..fea608c 100644 --- a/src/pytest/test_version.py +++ b/src/pytest/test_version.py @@ -8,4 +8,4 @@ def test_version(): """Test the version attribute.""" - assert hoomd.template.version.version == '0.0.1' + assert hoomd.template.version.version == '0.0.0' From e4d75ff907e82137a261ea3e58d5690cd49b2ad8 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Wed, 29 Nov 2023 11:10:33 -0500 Subject: [PATCH 18/26] Add bumpversion configuration. --- .bumpversion.cfg | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .bumpversion.cfg diff --git a/.bumpversion.cfg b/.bumpversion.cfg new file mode 100644 index 0000000..3cdc3d8 --- /dev/null +++ b/.bumpversion.cfg @@ -0,0 +1,8 @@ +[bumpversion] +current_version = 0.0.0 +commit = False +tag = False + +[bumpversion:file:src/version.py] + +[bumpversion:file:src/pytest/test_version.py] From 3653d3ec448f17a760527e566248528a8a1494e6 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Wed, 29 Nov 2023 16:57:15 -0500 Subject: [PATCH 19/26] Add README. --- README.md | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/README.md b/README.md index e69de29..65fba50 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,89 @@ +# HOOMD-blue component template + +`hoomd-component-template` provides a framework to develop a component that extends +[HOOMD-blue](https://glotzerlab.engin.umich.edu/hoomd-blue/). + +It includes: + +* CMake scripts to build the component. +* Template C++ and Python modules. +* An example unit test. +* Pre-commit configuration. +* GitHub Actions configuration. + +## Building the component + +To build this component: + +1. Build and install HOOMD-blue from source. +2. Obtain the component's source. + ``` + $ git clone https://github.com/glotzerlab/hoomd-component-template + ``` +3. Configure. + ``` + $ cmake -B build/hoomd-component-template -S hoomd-component-template + ``` +4. Build the component. + ``` + $ cmake --build build/hoomd-component-template + ``` +5. Install the component. + ``` + $ cmake --install build/hoomd-component-template + ``` + +Once installed, the template is available for import via: +``` +import hoomd.template +``` + +## Creating a new component + +To create a new component: + +1. Fork the [hoomd-component-template](https://github.com/glotzerlab/hoomd-component-template/) + repository. +2. Add C++ and Python files to `src/`. +3. Address all TODO comments. These explain how to set your package name, add C++ files, add unit + tests, and other tasks. Use [ripgrep](https://github.com/BurntSushi/ripgrep) to find all TODO + messages: + ``` + $ rg TODO . .github + ``` +4. Add unit tests in `src/pytest` using [pytest](https://docs.pytest.org). +5. Format and check code style with [pre-commit](https://pre-commit.com/). + ``` + $ pre-commit run --all-files + ``` +6. Push your changes to GitHub and the provided [GitHub Actions](https://docs.github.com/en/actions) + workflow will run and test your that your code compiles on the CPU (with and without MPI), and + on the GPU (with and without MPI). The workflow also runs the unit tests on the CPU. You should + run GPU unit tests locally, GitHub does not provide free GPU runners for GitHub Actions. + +## Maintaining your component + +The HOOMD-blue developers will periodically update +[hoomd-component-template](https://github.com/glotzerlab/hoomd-component-template/), including +updates to the GitHub Actions workflow, pre-commit configuration, and CMake scripts. Merge these +changes into your fork to to test with the latest version of HOOMD-blue. + +For example, run: +``` +$ git remote add upstream https://github.com/glotzerlab/hoomd-component-template +$ git fetch upstream +$ git merge upstream/trunk +``` +and resolve merge conflicts as appropriate. + +## Documenting and releasing your component + +TODO: Document your component in `README.md` (this file). + +When appropriate: + +* Add [Sphinx](https://www.sphinx-doc.org) documentation and publish it on +[readthedocs](https://www.readthedocs.org). +* Add a [conda-forge](https://conda-forge.org/) package. +* Announce your component on the [hoomd-users](https://groups.google.com/g/hoomd-users) mailing + list. From f825df1f8be2fefefcc6e54cb2a3291198ef8e3e Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Fri, 8 Dec 2023 09:52:24 -0500 Subject: [PATCH 20/26] Add automatically generated releases on tags. --- .github/release.yaml | 14 ++++++++ .github/workflows/release.yaml | 60 ++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 .github/release.yaml create mode 100644 .github/workflows/release.yaml diff --git a/.github/release.yaml b/.github/release.yaml new file mode 100644 index 0000000..1dc7dd0 --- /dev/null +++ b/.github/release.yaml @@ -0,0 +1,14 @@ +changelog: + exclude: + authors: + - dependabot + categories: + - title: Added + labels: + - enhancement + - title: Fixed + labels: + - bug + - title: Changed + labels: + - "*" diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..d6b6bd3 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,60 @@ +name: GitHub Release + +on: + pull_request: + + push: + branches: + - "trunk" + tags: + - "v*" + + workflow_dispatch: + +permissions: + contents: write + +defaults: + run: + shell: bash + +jobs: + release: + name: Publish [GitHub] + runs-on: ubuntu-latest + + steps: + - name: Determine version number + id: version + run: | + TAG=${{ github.ref_name }} + # Remove v from start of tag name + VERSION=${TAG#v} + # Replace / with - in merge names + VERSION=${VERSION//\//-} + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" + echo "name=${{ github.event.repository.name }}-${VERSION}" >> "$GITHUB_OUTPUT" + + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: true + path: ${{ steps.version.outputs.name }} + + - name: Remove .git + run: | + rm -rf ${{ steps.version.outputs.name }}/.git + ls -laR ${{ steps.version.outputs.name }} + + - name: Tar source + run: tar --zstd -cvf ${{ steps.version.outputs.name }}.tar.zst ${{ steps.version.outputs.name }} + + - name: Create release + uses: softprops/action-gh-release@v0.1.15 + if: startsWith(github.ref, 'refs/tags/v') + with: + files: "*.tar.zst" + name: ${{ steps.version.outputs.version }} + generate_release_notes: True + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 64d2c4bcc6ffb90e68a77b659766a32a6233f22b Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Fri, 8 Dec 2023 10:14:20 -0500 Subject: [PATCH 21/26] Add release instructions to README. --- README.md | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 65fba50..f727a18 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ It includes: * An example unit test. * Pre-commit configuration. * GitHub Actions configuration. + * Unit tests. + * Automatic release creation on tags starting with `v`, (e.g. `v1.0.0`). ## Building the component @@ -44,13 +46,13 @@ To create a new component: 1. Fork the [hoomd-component-template](https://github.com/glotzerlab/hoomd-component-template/) repository. -2. Add C++ and Python files to `src/`. -3. Address all TODO comments. These explain how to set your package name, add C++ files, add unit - tests, and other tasks. Use [ripgrep](https://github.com/BurntSushi/ripgrep) to find all TODO - messages: +2. Address all TODO comments. These explain how to set your package name, add C++ files, add unit + tests, and other tasks. You can se [ripgrep](https://github.com/BurntSushi/ripgrep) to find all + TODO messages: ``` $ rg TODO . .github ``` +3. Add C++ and Python files to `src/`. 4. Add unit tests in `src/pytest` using [pytest](https://docs.pytest.org). 5. Format and check code style with [pre-commit](https://pre-commit.com/). ``` @@ -60,6 +62,20 @@ To create a new component: workflow will run and test your that your code compiles on the CPU (with and without MPI), and on the GPU (with and without MPI). The workflow also runs the unit tests on the CPU. You should run GPU unit tests locally, GitHub does not provide free GPU runners for GitHub Actions. +7. When you are ready to release, bump the version number with [bump2version](https://github.com/c4urself/bump2version). + ``` + bump2version minor + ``` + Commit and push the changes to a branch, and make a pull request. After merging the working + pull request, tag the commit and push the tags. For example: + ``` + git switch trunk + git pull origin trunk + git tag -a v0.1.0 + git push origin --tags + ``` + The GitHub Actions workflow `release.yaml` will automatically create a GitHub release with + a change log for each tag. ## Maintaining your component @@ -85,5 +101,4 @@ When appropriate: * Add [Sphinx](https://www.sphinx-doc.org) documentation and publish it on [readthedocs](https://www.readthedocs.org). * Add a [conda-forge](https://conda-forge.org/) package. -* Announce your component on the [hoomd-users](https://groups.google.com/g/hoomd-users) mailing - list. +* Announce your component on the [HOOMD-blue discussion board](https://github.com/glotzerlab/hoomd-blue/discussions). From b70c4d826f8a59d180d2766be9c113d170951e6f Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Fri, 8 Dec 2023 10:15:18 -0500 Subject: [PATCH 22/26] Test against HOOMD-blue 4.4.0. --- .github/workflows/unit-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index 722f6df..f5fb0ee 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -9,7 +9,7 @@ env: ############################################################################################# # HOOMD-blue version to build. - HOOMD_BLUE_VERSION: 4.3.0 + HOOMD_BLUE_VERSION: 4.4.0 # prevent deadlocked MPI tests from causing the job to cancel MPIEXEC_TIMEOUT: 3000 # allow mpirun to execute as root in the tests From 6645b047f9784eab4c025dc1985afe0fa653191d Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Fri, 8 Dec 2023 10:17:11 -0500 Subject: [PATCH 23/26] Use consistent capitalization of github workflows. --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d6b6bd3..8036b6c 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,4 +1,4 @@ -name: GitHub Release +name: GitHub release on: pull_request: From 82449bc854fe322394772365143b228dbfbfeb57 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Fri, 8 Dec 2023 10:22:59 -0500 Subject: [PATCH 24/26] Use v1 tag for gh-release. --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8036b6c..f1ffbbc 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -50,7 +50,7 @@ jobs: run: tar --zstd -cvf ${{ steps.version.outputs.name }}.tar.zst ${{ steps.version.outputs.name }} - name: Create release - uses: softprops/action-gh-release@v0.1.15 + uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/v') with: files: "*.tar.zst" From 089ad2f926554db967ae74ee87fefc72d0df0f2e Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Mon, 11 Dec 2023 10:40:58 -0500 Subject: [PATCH 25/26] Edit for brevity. --- README.md | 65 ++++++++++++++----------------------------------------- 1 file changed, 16 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index f727a18..0662f8c 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,9 @@ # HOOMD-blue component template `hoomd-component-template` provides a framework to develop a component that extends -[HOOMD-blue](https://glotzerlab.engin.umich.edu/hoomd-blue/). - -It includes: - -* CMake scripts to build the component. -* Template C++ and Python modules. -* An example unit test. -* Pre-commit configuration. -* GitHub Actions configuration. - * Unit tests. - * Automatic release creation on tags starting with `v`, (e.g. `v1.0.0`). +[HOOMD-blue](https://glotzerlab.engin.umich.edu/hoomd-blue/). It includes template C++ and Python +modules, an example unit test, CMake scripts to build the component, and GitHub Actions +configurations. ## Building the component @@ -44,38 +36,21 @@ import hoomd.template To create a new component: -1. Fork the [hoomd-component-template](https://github.com/glotzerlab/hoomd-component-template/) - repository. -2. Address all TODO comments. These explain how to set your package name, add C++ files, add unit - tests, and other tasks. You can se [ripgrep](https://github.com/BurntSushi/ripgrep) to find all - TODO messages: - ``` - $ rg TODO . .github - ``` +1. Fork [hoomd-component-template](https://github.com/glotzerlab/hoomd-component-template/). +2. Address all **TODO** comments (including those in `.github/*`) 3. Add C++ and Python files to `src/`. -4. Add unit tests in `src/pytest` using [pytest](https://docs.pytest.org). +4. Add unit tests in `src/pytest`. 5. Format and check code style with [pre-commit](https://pre-commit.com/). - ``` - $ pre-commit run --all-files - ``` -6. Push your changes to GitHub and the provided [GitHub Actions](https://docs.github.com/en/actions) - workflow will run and test your that your code compiles on the CPU (with and without MPI), and - on the GPU (with and without MPI). The workflow also runs the unit tests on the CPU. You should - run GPU unit tests locally, GitHub does not provide free GPU runners for GitHub Actions. -7. When you are ready to release, bump the version number with [bump2version](https://github.com/c4urself/bump2version). - ``` - bump2version minor - ``` - Commit and push the changes to a branch, and make a pull request. After merging the working - pull request, tag the commit and push the tags. For example: - ``` - git switch trunk - git pull origin trunk - git tag -a v0.1.0 - git push origin --tags - ``` - The GitHub Actions workflow `release.yaml` will automatically create a GitHub release with - a change log for each tag. + +## Using the provided GitHub Actions configuration + +When you push your changes to GitHub and, the [unit test workflow](.github/workflows/unit-test.yaml) +will run and test your that your code compiles on the CPU (with and without MPI), and +on the GPU (with and without MPI). The workflow also runs the unit tests on the CPU. You should +run GPU unit tests locally, GitHub does not provide free GPU runners for GitHub Actions. + +When you push a new tag, the [release workflow](.github/workflows/release.yaml) will create a +new GitHub release with automatically generated release notes. ## Maintaining your component @@ -84,14 +59,6 @@ The HOOMD-blue developers will periodically update updates to the GitHub Actions workflow, pre-commit configuration, and CMake scripts. Merge these changes into your fork to to test with the latest version of HOOMD-blue. -For example, run: -``` -$ git remote add upstream https://github.com/glotzerlab/hoomd-component-template -$ git fetch upstream -$ git merge upstream/trunk -``` -and resolve merge conflicts as appropriate. - ## Documenting and releasing your component TODO: Document your component in `README.md` (this file). From e256106c2b20cb7547821df80ea26fc4bb57884e Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Mon, 11 Dec 2023 10:48:48 -0500 Subject: [PATCH 26/26] More revisions. --- README.md | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 0662f8c..161655d 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,15 @@ # HOOMD-blue component template -`hoomd-component-template` provides a framework to develop a component that extends -[HOOMD-blue](https://glotzerlab.engin.umich.edu/hoomd-blue/). It includes template C++ and Python -modules, an example unit test, CMake scripts to build the component, and GitHub Actions -configurations. +`hoomd-component-template` provides a framework to develop components that extend +[**HOOMD-blue**](https://glotzerlab.engin.umich.edu/hoomd-blue/). It includes template C++ and +Python modules, an example unit test, CMake scripts to build the component, and GitHub Actions +workflows. ## Building the component To build this component: -1. Build and install HOOMD-blue from source. +1. Build and install **HOOMD-blue** from source. 2. Obtain the component's source. ``` $ git clone https://github.com/glotzerlab/hoomd-component-template @@ -37,17 +37,17 @@ import hoomd.template To create a new component: 1. Fork [hoomd-component-template](https://github.com/glotzerlab/hoomd-component-template/). -2. Address all **TODO** comments (including those in `.github/*`) +2. Address all **TODO** comments (including those in `.github/`) 3. Add C++ and Python files to `src/`. 4. Add unit tests in `src/pytest`. 5. Format and check code style with [pre-commit](https://pre-commit.com/). ## Using the provided GitHub Actions configuration -When you push your changes to GitHub and, the [unit test workflow](.github/workflows/unit-test.yaml) -will run and test your that your code compiles on the CPU (with and without MPI), and -on the GPU (with and without MPI). The workflow also runs the unit tests on the CPU. You should -run GPU unit tests locally, GitHub does not provide free GPU runners for GitHub Actions. +When you push your changes to GitHub, the [unit test workflow](.github/workflows/unit-test.yaml) +compile your code on the CPU (with and without MPI) and on the GPU (with and without MPI). The +workflow also executes the unit tests on the CPU. You should run GPU unit tests locally, as GitHub +does not provide free GPU runners for GitHub Actions. When you push a new tag, the [release workflow](.github/workflows/release.yaml) will create a new GitHub release with automatically generated release notes. @@ -57,11 +57,12 @@ new GitHub release with automatically generated release notes. The HOOMD-blue developers will periodically update [hoomd-component-template](https://github.com/glotzerlab/hoomd-component-template/), including updates to the GitHub Actions workflow, pre-commit configuration, and CMake scripts. Merge these -changes into your fork to to test with the latest version of HOOMD-blue. +changes into your fork to support the latest version of HOOMD-blue. ## Documenting and releasing your component -TODO: Document your component in `README.md` (this file). +TODO: Document your component in `README.md` (this file) and remove documentation relevant to the +template. When appropriate: