Skip to content

Commit

Permalink
documentation and fix CI?
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmrichard committed Nov 11, 2024
1 parent 98d63e9 commit b6d25f6
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 43 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/build_plugin_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ on:
project_slug:
required: false
type: string
default: "new_project"
default: "new_plugin"
nwx_cmake:
required: false
type: bool
default: true
secrets:
CONTAINER_REPO_TOKEN:
required: true
Expand Down Expand Up @@ -49,10 +53,13 @@ jobs:
run: |
echo "default_context:" > configure.yaml
echo " project_name: ${PROJECT_NAME}" >> configure.yaml
echo " project_slug: ${PROJECT_SLUG}" >> configure.yaml
echo " nwx_cmake: ${NWX_CMAKE}" >> configure.yaml
shell: bash
env:
PROJECT_NAME: ${{ inputs.project_name }}
PROJECT_SLUG: ${{ inputs.project_slug }}
NWX_CMAKE: ${{ inputs.nwx_cmake }}

- name: Test current state
run: |
Expand Down
27 changes: 11 additions & 16 deletions {{ cookiecutter.project_slug }}/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,13 @@ cmake_minimum_required(VERSION 3.14)
include(cmake/get_cmake_modules.cmake)

## Set Project and Version

{%- if cookiecutter.nwx_cmake -%}

{% if cookiecutter.nwx_cmake %}
# TODO: Uncomment when you have a git tag
#include(get_version_from_git)
#get_version_from_git(VERSION "${CMAKE_CURRENT_LIST_DIR}")
set(VERSION "0.0.1") # Delete this line if you uncomment line above

{%- else -%}

set(VERSION "0.0.1")

{% else %}
set(VERSION "0.0.1") # Change this to your plugin's actual version
{% endif %}
project({{ cookiecutter.project_slug }} VERSION "${VERSION}" LANGUAGES CXX)

Expand All @@ -24,8 +19,7 @@ set(${PROJECT_NAME}_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
set(${PROJECT_NAME}_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
set(${PROJECT_NAME}_TESTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tests")

{%- if cookiecutter.nwx_cmake -%}

{% if cookiecutter.nwx_cmake %}
include(nwx_versions)
{% endif %}
include(get_cmaize)
Expand Down Expand Up @@ -54,8 +48,7 @@ cmaize_add_library(
DEPENDS simde
)

{%- if cookiecutter.nwx_cmake -%}

{% if cookiecutter.nwx_cmake %}
include(nwx_pybind11)
nwx_add_pybind11_module(
${PROJECT_NAME}
Expand All @@ -76,16 +69,16 @@ if("${BUILD_TESTING}")
VERSION v2.x
)

set(UNIT_TEST_DIR "${${PROJECT_NAME}_TESTS_DIR}/unit_tests")
## Add Tests ##
cmaize_add_tests(
test_${PROJECT_NAME}
SOURCE_DIR "${${PROJECT_NAME}_TESTS_DIR}/unit_tests/${PROJECT_NAME}"
SOURCE_DIR "${UNIT_TEST_DIR}/${PROJECT_NAME}"
INCLUDE_DIRS "${${PROJECT_NAME}_INCLUDE_DIR}/${PROJECT_NAME}"
DEPENDS Catch2 ${PROJECT_NAME}
)

{%- if cookiecutter.nwx_cmake -%}

{% if cookiecutter.nwx_cmake %}
if("${INTEGRATION_TESTING}")
cmaize_find_or_build_dependency(
nwchemex
Expand All @@ -95,9 +88,11 @@ if("${BUILD_TESTING}")
CMAKE_ARGS BUILD_TESTING=OFF
)


set(INTEGRATION_DIR "${${PROJECT_NAME}_TESTS_DIR}/integration_tests")
nwx_pybind11_tests(
py_${PROJECT_NAME}
"${${PROJECT_NAME}_TESTS_DIR}/integration_tests/test_${PROJECT_NAME}.py"
"${INTEGRATION_DIR}/${PROJECT_NAME}/test_${PROJECT_NAME}.py"
DEPENDS nwchemex
SUBMODULES simde chemist pluginplay parallelzone friendzone
chemcache nwchemex
Expand Down
5 changes: 2 additions & 3 deletions {{ cookiecutter.project_slug }}/cmake/get_cmake_modules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include_guard()
macro(get_cmake_modules)
include(FetchContent)

{%- if cookiecutter.nwx_cmake -%}
{% if cookiecutter.nwx_cmake %}
FetchContent_Declare(
nwx_cmake
GIT_REPOSITORY https://github.com/NWChemEx/NWXCMake
Expand All @@ -14,8 +14,7 @@ macro(get_cmake_modules)
CACHE STRING ""
FORCE
)
{%- else -%}

{% else %}
if("${CMAIZE_VERSION}" STREQUAL "")
set(CMAIZE_VERSION v1.1.0 )
endif()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#pragma once

#include "{{ cookiecutter.project_slug }}_mm.hpp"
#include <{{ cookiecutter.project_slug }}/{{ cookiecutter.project_slug }}_mm.hpp>
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#include "{{ cookiecutter.project_slug }}/{{ cookiecutter.project_slug }}_mm.hpp"
#include <{{ cookiecutter.project_slug }}/{{ cookiecutter.project_slug }}_mm.hpp>

namespace {{ cookiecutter.project_slug }} {

inline void set_defaults(pluginplay::ModuleManager& mm) {
// Default submodules between collections can be set here
inline void set_defaults(pluginplay::ModuleManager & mm) {
// Set your modules' default submodules here
}

DECLARE_PLUGIN({{ cookiecutter.project_slug }}) {
// Add subcollection load calls here
// Add your modules to mm here

// Assign default submodules
set_defaults(mm);
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
""" Example of how to use the full NWX ecosystem in a test.
In the setUp method for this test we load ALL of the released NWX plugins. We
then load this plugin, i.e., the plugin we are testing.
"""

import nwchemex as nwx
import simde
import pluginplay
import unittest

import {{ cookiecutter.project_slug }}

class AnExampleIntegrationTest(unittest.TestCase):

Expand All @@ -24,4 +30,7 @@ def testMoleculeFromString(self):

def setUp(self):
self.mm = pluginplay.ModuleManager()

nwx.load_modules(self.mm)
{{ cookiecutter.project_slug}}.load_modules(self.mm)

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Driver for integration tests.
This file drives your integration tests. To run the integration tests (assuming
your Python path is setup correctly) simply type:
.. code-block:: terminal
python test_{{ cookiecutter.project_slug }}.py
The driver assumes that your integration tests live in importable Python
modules next to this file.
"""

import os
import parallelzone as pz
import sys
import unittest

if __name__ == '__main__':

# Ensure a RuntimeView object persists through all tests
rv = pz.runtime.RuntimeView()

# Works out the path to the directory containing the driver
my_dir = os.path.dirname(os.path.realpath(__file__))

#Find and run the tests, then return the result
loader = unittest.TestLoader()
tests = loader.discover(my_dir)
testrunner = unittest.runner.TextTestRunner()
ret = not testrunner.run(tests).wasSuccessful()
sys.exit(ret)

0 comments on commit b6d25f6

Please sign in to comment.