diff --git a/.github/workflows/build_plugin_template.yaml b/.github/workflows/build_plugin_template.yaml new file mode 100644 index 0000000..3e36e70 --- /dev/null +++ b/.github/workflows/build_plugin_template.yaml @@ -0,0 +1,72 @@ +name: 'Configure and build PluginTemplate' + +on: + workflow_call: + inputs: + project_name: + required: true + type: string + project_slug: + required: false + type: string + default: "new_project" + secrets: + CONTAINER_REPO_TOKEN: + required: true + +Test-Cookiecutter: + runs-on: ubuntu-latest + container: + image: ghcr.io/nwchemex/nwx_buildenv:latest + credentials: + username: ${{ github.actor }} + password: ${{ secrets.CONTAINER_REPO_TOKEN }} + steps: + - uses: actions/checkout@v2 + + - name: Install cookecutter + run: | + pip install cookiecutter + shell: bash + + - name: Install Zip + run: | + apt-get update && apt-get install -y zip + shell: bash + + - name: Zip current state + run: | + # From the Cookiecutter docs + (SOURCE_DIR=$(basename $PWD) ZIP=cookiecutter.zip && + pushd .. && + zip -r $ZIP $SOURCE_DIR --exclude $SOURCE_DIR/$ZIP --quiet && + mv $ZIP $SOURCE_DIR/$ZIP && + popd && + echo "Cookiecutter full path: $PWD/$ZIP") + shell: bash + + - name: Write configure.yaml + run: | + echo "default_context:" > configure.yaml + echo " project_name: ${PROJECT_NAME}" >> configure.yaml + shell: bash + env: + PROJECT_NAME: ${{ inputs.project_name }} + PROJECT_SLUG: ${{ inputs.project_slug }} + + - name: Test current state + run: | + # Generate the template + cookiecutter ./cookiecutter.zip --no-input --config-file configure.yaml + cd ${PROJECT_SLUG} + + # Configure, build, and test + cmake -Bbuild -H. \ + -DCMAKE_TOOLCHAIN_FILE=./default_toolchain.cmake \ + -DCMAKE_INSTALL_PREFIX=./install + cmake --build build --parallel + cd build + ctest -VV + shell: bash + env: + PROJECT_SLUG: ${{ inputs.project_slug }} \ No newline at end of file diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 628e301..58d65a2 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -21,44 +21,9 @@ on: - master jobs: - Test-Cookiecutter: - runs-on: ubuntu-latest - container: - image: ghcr.io/nwchemex/nwx_buildenv:latest - credentials: - username: ${{ github.actor }} - password: ${{ secrets.CONTAINER_REPO_TOKEN }} - steps: - - uses: actions/checkout@v2 - - name: Install cookecutter - run: | - pip install cookiecutter - shell: bash - - name: Install Zip - run: | - apt-get update && apt-get install -y zip - shell: bash - - name: Zip current state - run: | - # From the Cookiecutter docs - (SOURCE_DIR=$(basename $PWD) ZIP=cookiecutter.zip && - pushd .. && - zip -r $ZIP $SOURCE_DIR --exclude $SOURCE_DIR/$ZIP --quiet && - mv $ZIP $SOURCE_DIR/$ZIP && - popd && - echo "Cookiecutter full path: $PWD/$ZIP") - shell: bash - - name: Test current state - run: | - # Generate the template - cookiecutter ./cookiecutter.zip --no-input - cd new_plugin - - # Configure, build, and test - cmake -Bbuild -H. \ - -DCMAKE_TOOLCHAIN_FILE=./default_toolchain.cmake \ - -DCMAKE_INSTALL_PREFIX=./install - cmake --build build --parallel - cd build - ctest -VV - shell: bash + default_run: + uses: ./workflows/build_plugin_template.yaml + with: + project_name: "New Plugin" + secrets: + CONTAINER_REPO_TOKEN: ${{ secrets.CONTAINER_REPO_TOKEN }}