Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial template #1

Merged
merged 26 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
46c1223
Skeleton HOOMD-blue component.
joaander Nov 28, 2023
68f14be
Add pre-commit configuration.
joaander Nov 28, 2023
92d12e0
Add pre-commit github action and dependabot configuration.
joaander Nov 28, 2023
942cc05
Add clang-format configuration.
joaander Nov 28, 2023
22d9117
Add unit test configuration.
joaander Nov 28, 2023
cf88360
Install a specific HOOMD-blue version.
joaander Nov 28, 2023
d1af784
Install python files correctly.
joaander Nov 28, 2023
22800c4
Cache HOOMD-blue builds.
joaander Nov 28, 2023
c43a0df
Enable full test matrix.
joaander Nov 28, 2023
67f47d4
Fix GPU tests.
joaander Nov 28, 2023
ffcb259
Save HOOMD-blue cache after a successful build.
joaander Nov 29, 2023
3ffa0fc
Save cache only when there is no hit.
joaander Nov 29, 2023
aee9540
Add container image name to cache key.
joaander Nov 29, 2023
3e059f7
Make test fail.
joaander Nov 29, 2023
0cb263a
Complete all tests in the matrix.
joaander Nov 29, 2023
43fb4ae
Use more descriptive variable names for files.
joaander Nov 29, 2023
1e72f3f
Restore version test.
joaander Nov 29, 2023
e4d75ff
Add bumpversion configuration.
joaander Nov 29, 2023
3653d3e
Add README.
joaander Nov 29, 2023
f825df1
Add automatically generated releases on tags.
joaander Dec 8, 2023
64d2c4b
Add release instructions to README.
joaander Dec 8, 2023
b70c4d8
Test against HOOMD-blue 4.4.0.
joaander Dec 8, 2023
6645b04
Use consistent capitalization of github workflows.
joaander Dec 8, 2023
82449bc
Use v1 tag for gh-release.
joaander Dec 8, 2023
089ad2f
Edit for brevity.
joaander Dec 11, 2023
e256106
More revisions.
joaander Dec 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -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]
36 changes: 36 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -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

...
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions .github/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
changelog:
exclude:
authors:
- dependabot
categories:
- title: Added
labels:
- enhancement
- title: Fixed
labels:
- bug
- title: Changed
labels:
- "*"
23 changes: 23 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -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
60 changes: 60 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -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@v1
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 }}
119 changes: 119 additions & 0 deletions .github/workflows/unit-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
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/

#############################################################################################
# HOOMD-blue version to build.
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
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"
# 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:
fail-fast: false
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: Restore cached HOOMD-blue build
id: cache
uses: actions/cache/restore@v3
with:
path: install
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
with:
repository: glotzerlab/hoomd-blue
path: hoomd-blue
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 \
-DCMAKE_BUILD_TYPE=Release \
-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
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
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: install
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
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 ))
55 changes: 55 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
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
50 changes: 50 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -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"]
Loading