diff --git a/.github/Dockerfile/base-catch2.Dockerfile b/.github/Dockerfile/base-catch2.Dockerfile new file mode 100644 index 000000000..8a10b0479 --- /dev/null +++ b/.github/Dockerfile/base-catch2.Dockerfile @@ -0,0 +1,28 @@ +# Copyright 2023 NWChemEx-Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +ARG PARENT_IMAGE_NAME + +FROM ${PARENT_IMAGE_NAME}:latest + +ARG CATCH2_VERSION + +# Install catch2 ## +RUN cd /tmp \ + && git clone -b v${CATCH2_VERSION} https://github.com/catchorg/Catch2.git \ + && cd Catch2 \ + && cmake -Bbuild -H. -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX=/install \ + && cmake --build build \ + && cmake --build build --target install \ + && rm -rf /tmp/Catch2 diff --git a/.github/Dockerfile/base-libboost.Dockerfile b/.github/Dockerfile/base-libboost.Dockerfile new file mode 100644 index 000000000..7a4782a4b --- /dev/null +++ b/.github/Dockerfile/base-libboost.Dockerfile @@ -0,0 +1,11 @@ +ARG PARENT_IMAGE_NAME + +FROM ${PARENT_IMAGE_NAME}:latest + +ARG LIBBOOST_VERSION + +# Install libboost ## +RUN apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y libboost-all-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* diff --git a/.github/Dockerfile/base-libfort.Dockerfile b/.github/Dockerfile/base-libfort.Dockerfile new file mode 100644 index 000000000..af93edb7c --- /dev/null +++ b/.github/Dockerfile/base-libfort.Dockerfile @@ -0,0 +1,25 @@ +ARG PARENT_IMAGE_NAME + +FROM ${PARENT_IMAGE_NAME}:latest + +ARG LIBFORT_VERSION + +# Install curl to download libfort +RUN apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y curl \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# Install libfort# +ENV INSTALL_PATH=../install + +RUN curl -L -o libfort-${LIBFORT_VERSION}.tar.gz https://codeload.github.com/seleznevae/libfort/tar.gz/refs/tags/v${LIBFORT_VERSION} \ + && tar -zxf libfort-${LIBFORT_VERSION}.tar.gz \ + && cd libfort-${LIBFORT_VERSION} \ + && cmake -GNinja -H. -Bbuild -DCMAKE_INSTALL_PREFIX=${INSTALL_PATH} \ + && cmake --build build \ + && cmake --build build --target install \ + && cd .. \ + && rm -rf libfort-${LIBFORT_VERSION} libfort-${LIBFORT_VERSION}.tar.gz + +ENV PATH="`pwd`/install:${PATH}" diff --git a/.github/actions/container-build_test_release/Dockerfile b/.github/actions/container-build_test_release/Dockerfile new file mode 100644 index 000000000..eec40bc1c --- /dev/null +++ b/.github/actions/container-build_test_release/Dockerfile @@ -0,0 +1,24 @@ +# Copyright 2023 NWChemEx-Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM alpine:latest + +COPY docker-action /docker-action +COPY entrypoint.sh /entrypoint.sh + +RUN apk add --update --no-cache docker +RUN ["chmod", "+x", "/entrypoint.sh"] + +# Code file to execute when the docker container starts up (`entrypoint.sh`) +ENTRYPOINT ["/entrypoint.sh"] diff --git a/.github/actions/container-build_test_release/action.yaml b/.github/actions/container-build_test_release/action.yaml new file mode 100644 index 000000000..10703a3dd --- /dev/null +++ b/.github/actions/container-build_test_release/action.yaml @@ -0,0 +1,86 @@ +# Copyright 2023 NWChemEx-Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: container action to build ParallelZone + +description: container action from the base image to build ParallelZone + +inputs: + base_tag: + description: 'tag of the base image' + type: string + required: false + default: 'stable' + dep_repo_tag: + description: 'tag of the dependent repo images' + type: string + required: false + default: '' + token: + type: string + required: true + user: + type: string + required: true + cmake_version: + type: string + required: false + default: '' + gcc_version: + type: string + required: false + default: '' + clang_version: + type: string + required: false + default: '' + ninja_build: + type: boolean + required: true + use_clang: + type: boolean + required: true + CMAIZE_GITHUB_TOKEN: + type: string + required: true + INSTALL: + type: boolean + required: true + test: + type: boolean + required: true + integration_test: + type: boolean + required: true + branch_name: + type: string + required: true +runs: + using: 'docker' + image: 'Dockerfile' + args: + - ${{ inputs.token }} # 1 + - ${{ inputs.user }} # 2 + - ${{ inputs.base_tag }} # 3 + - ${{ inputs.cmake_version }} # 4 + - ${{ inputs.gcc_version }} # 5 + - ${{ inputs.clang_version }} # 6 + - ${{ inputs.ninja_build }} # 7 + - ${{ inputs.use_clang }} # 8 + - ${{ inputs.CMAIZE_GITHUB_TOKEN }} # 9 + - ${{ inputs.INSTALL }} # 10 + - ${{ inputs.test }} # 11 + - ${{ inputs.integration_test }} # 12 + - ${{ inputs.branch_name }} # 13 + - ${{ inputs.dep_repo_tag }} # 14 diff --git a/.github/actions/container-build_test_release/docker-action/Dockerfile b/.github/actions/container-build_test_release/docker-action/Dockerfile new file mode 100644 index 000000000..1dc1cd096 --- /dev/null +++ b/.github/actions/container-build_test_release/docker-action/Dockerfile @@ -0,0 +1,53 @@ +# Copyright 2023 NWChemEx-Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +ARG dep_repo_tag +ARG base_tag + +FROM ghcr.io/nwchemex-project/release_parallelzone:$dep_repo_tag +FROM ghcr.io/nwchemex-project/release_utilities:$dep_repo_tag + +FROM ghcr.io/nwchemex-project/base_pluginplay:$base_tag + +COPY --from=0 /install /install + +COPY --from=1 /install /install + +COPY build_test.sh /build_test.sh + +RUN ["chmod", "+x", "/build_test.sh"] + +ARG cmake_version +ARG gcc_version +ARG clang_version +ARG ninja_build +ARG use_clang +ARG cmaize_github_token +ARG install +ARG unit_test +ARG int_test +ARG branch_name + + +ENV env_cmake_version=$cmake_version +ENV env_gcc_version=$gcc_version +ENV env_clang_version=$clang_version +ENV env_ninja_build=$ninja_build +ENV env_use_clang=$use_clang +ENV env_cmaize_github_token=$cmaize_github_token +ENV env_install=$install +ENV env_unit_test=$unit_test +ENV env_int_test=$int_test +ENV env_branch_name=$branch_name + +ENTRYPOINT ["/build_test.sh"] diff --git a/.github/actions/container-build_test_release/docker-action/build_test.sh b/.github/actions/container-build_test_release/docker-action/build_test.sh new file mode 100644 index 000000000..d2f429ae2 --- /dev/null +++ b/.github/actions/container-build_test_release/docker-action/build_test.sh @@ -0,0 +1,133 @@ +#!/bin/sh +# Copyright 2023 NWChemEx-Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# Wraps the process for configuring, building, and testing an NWX repo +# +# Usage: +# build_test.sh +# +# Other variables: +# cmake_version: the version of cmake being used in the format x.y.z +# + +set -e # Exit with error if any command fails + +# checkout repo with the current branch (not master!) + +git clone -b ${env_branch_name} https://github.com/NWChemEx-Project/PluginPlay.git +cd PluginPlay + +cmake_command=cmake +ctest_command=ctest +toolchain_file=$(pwd)/toolchain.cmake + +#pybind11_path=$(python3 -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])') + +echo "set(BUILD_TESTING ON)" > "${toolchain_file}" +{ + echo "set(CMAKE_CXX_STANDARD 17)" + echo 'set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)' + echo "set(BUILD_SHARED_LIBS ON)" + echo "set(CATCH_ENABLE_COVERAGE ON)" + echo "set(CMAKE_PREFIX_PATH /install)" + #echo 'set(CMAKE_PREFIX_PATH "${pybind11_path};/install")' + echo 'set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -std=c++17")' + echo 'set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOMPI_SKIP_MPICXX")' + echo 'set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")' + echo 'set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs")' + echo 'set(CMAIZE_GITHUB_TOKEN '${env_cmaize_github_token}')' + echo 'set(CMAKE_BUILD_TYPE Release)' + echo 'set(ENABLE_SCALAPACK ON)' + echo 'set(LIBDIR "/usr/lib/x86_64-linux-gnu")' + echo 'set(BLAS_LIBRARIES "-L${LIBDIR} -lopenblas")' + echo 'set(LAPACK_LIBRARIES "-L${LIBDIR} -llapack ${BLAS_LIBRARIES}")' + echo 'set(ScaLAPACK_LIBRARIES "-L${LIBDIR} -lscalapack-openmpi ${LAPACK_LIBRARIES}")' + echo 'set(NWX_MODULE_DIRECTORY "./NWX_PyModules")' +} >> "${toolchain_file}" + +# if clang_build is true set clang and +# clang++ as default c and cxx compiler +# otherwise set gcc as default +# clang and gcc version controlled by defaults +# or inputs +if [ "${env_use_clang}" = true ] +then + { + echo "set(CMAKE_C_COMPILER /usr/bin/clang-${env_clang_version})" + echo "set(CMAKE_CXX_COMPILER /usr/bin/clang++-${env_clang_version})" + echo 'set(gpu_backend "none" CACHE STRING "" FORCE)' + } >> "${toolchain_file}" +else + { + echo "set(CMAKE_C_COMPILER /usr/bin/gcc-${env_gcc_version})" + echo "set(CMAKE_CXX_COMPILER /usr/bin/g++-${env_gcc_version})" + } >> "${toolchain_file}" +fi + +#Step 2: Configure +if [ "${env_install}" = true ]; then + export INSTALL_PATH=/install + if [ "${env_ninja_build}" = true ] ; then + ${cmake_command} -GNinja -H. -Bbuild -DCMAKE_TOOLCHAIN_FILE="${toolchain_file}" -DCMAKE_INSTALL_PREFIX=${INSTALL_PATH} + else + ${cmake_command} -H. -Bbuild -DCMAKE_TOOLCHAIN_FILE="${toolchain_file}" -DCMAKE_INSTALL_PREFIX=${INSTALL_PATH} + fi +else + if [ "${env_ninja_build}" = true ] ; then + ${cmake_command} -GNinja -H. -Bbuild -DCMAKE_TOOLCHAIN_FILE="${toolchain_file}" + else + ${cmake_command} -H. -Bbuild -DCMAKE_TOOLCHAIN_FILE="${toolchain_file}" + fi +fi + +#Step 3: Compile +${cmake_command} --build build + +# Step 4: test + +# set up the envs for running mpiexec in a container +# otherwise tests would fail +export OMPI_ALLOW_RUN_AS_ROOT=1 +export OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 + +cd build +# unit testing +if [ "${env_unit_test}" = true ]; then + echo "Running unit tests..." + ${ctest_command} -VV -R test_unit* +fi +# integration testing +if [ "${env_int_test}" = true ]; then + echo "Running integration tests..." + ${ctest_command} -VV -R test_integration* +fi +# test docs +echo "Running doc tests..." +${ctest_command} -VV -R *docs + +# python testing +#export PYTHONPATH=$PYTHONPATH:/install +#echo "PYTHONPATH = " $PYTHONPATH +#echo "Running python tests..." +#${ctest_command} -VV -R py +cd .. + +#Step 5: Install +if [ "${env_install}" = true ]; then + echo "Installing package..." + ${cmake_command} --build build --target install +fi + diff --git a/.github/actions/container-build_test_release/entrypoint.sh b/.github/actions/container-build_test_release/entrypoint.sh new file mode 100644 index 000000000..ae10a8a31 --- /dev/null +++ b/.github/actions/container-build_test_release/entrypoint.sh @@ -0,0 +1,53 @@ +#!/bin/sh -l +# Copyright 2023 NWChemEx-Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +CR_PAT=$1 +USER=$2 +BASE_TAG=$3 +CMAKE_VERSION=$4 +GCC_VRESION=$5 +CLANG_VERSION=$6 +NINJA_BUILD=$7 +USE_CLANG=$8 +CMAIZE_GITHUB_TOKEN=$9 +INSTALL=${10} +TEST=${11} +INTEGRATION_TEST=${12} +BRANCH_NAME=${13} +DEP_REPO_TAG=${14} + +cd /docker-action + +echo $CR_PAT | docker login ghcr.io -u $USER --password-stdin + +docker build -t docker-action --build-arg base_tag=$BASE_TAG --build-arg gcc_version=$GCC_VRESION --build-arg clang_version=$CLANG_VERSION --build-arg ninja_build=$NINJA_BUILD --build-arg use_clang=$USE_CLANG --build-arg cmaize_github_token=$CMAIZE_GITHUB_TOKEN --build-arg install=$INSTALL --build-arg unit_test=$TEST --build-arg int_test=$INTEGRATION_TEST --build-arg branch_name=$BRANCH_NAME --build-arg dep_repo_tag=${DEP_REPO_TAG} . && docker run docker-action + +container_id="$(docker ps -a | grep 'docker-action')" +container_id="${container_id%% *}" +docker cp ${container_id}:/install ./install + +cat <> release.Dockerfile +FROM scratch +ADD install /install +EOF + +if [ "${USE_CLANG}" = true ]; then + docker build -t ghcr.io/nwchemex-project/release_pluginplay:clang-latest -f release.Dockerfile . + docker push ghcr.io/nwchemex-project/release_pluginplay:clang-latest +else + docker build -t ghcr.io/nwchemex-project/release_pluginplay:gcc-latest -f release.Dockerfile . + docker push ghcr.io/nwchemex-project/release_pluginplay:gcc-latest +fi diff --git a/.github/workflows/build_base.yaml b/.github/workflows/build_base.yaml new file mode 100644 index 000000000..1b6c86829 --- /dev/null +++ b/.github/workflows/build_base.yaml @@ -0,0 +1,100 @@ +# manually input version no.s here +# will check in workflows to obtain +# this info from other files +# + +name: Build base image + +on: + workflow_call: + inputs: + cmake_version: + type: string + required: false + default: 3.17.0 + gcc_version: + type: string + required: false + default: 9 + clang_version: + type: string + required: false + default: 11 + ubuntu_version: + type: string + required: false + default: 20.04 + catch2_version: + type: string + required: false + default: 2.13.8 + libfort_version: + type: string + required: false + default: 0.4.2 + libboost_version: + type: string + required: false + default: 1.71.0 + +jobs: + build-image-gcc-clang-cmake: + uses: NWChemEx-Project/.github/.github/workflows/base_image_gcc-clang-cmake.yaml@master + with: + cmake_version: ${{ inputs.cmake_version }} + gcc_version: ${{ inputs.gcc_version }} + clang_version: ${{ inputs.clang_version }} + ubuntu_version: ${{ inputs.ubuntu_version }} + secrets: inherit + + build-base-image: + runs-on: ubuntu-latest + needs: build-image-gcc-clang-cmake + steps: + - uses: actions/checkout@v3 + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.CONTAINER_REPO_TOKEN }} + - name: Install libboost + uses: NWChemEx-Project/.github/actions/image-install_package@master + with: + libboost_version: ${{ inputs.libboost_version }} + package_name: libboost + parent_image_name: ghcr.io/nwchemex-project/base-cmake + path_to_dockerfile: .github/Dockerfile/base-libboost.Dockerfile + - name: Install libfort + uses: NWChemEx-Project/.github/actions/image-install_package@master + with: + libfort_version: ${{ inputs.libfort_version }} + package_name: libfort + parent_image_name: base-libboost + path_to_dockerfile: .github/Dockerfile/base-libfort.Dockerfile + - name: Install catch2 + uses: NWChemEx-Project/.github/actions/image-install_package@master + with: + catch2_version: ${{ inputs.catch2_version }} + package_name: catch2 + parent_image_name: base-libfort + path_to_dockerfile: .github/Dockerfile/base-catch2.Dockerfile + - name: Push the base image + uses: NWChemEx-Project/.github/actions/push_image@master + with: + tmp_image_name: base-catch2 + tmp_image_tag: latest + image_name: ghcr.io/nwchemex-project/base_pluginplay + image_tag: latest + - name: Check stable base image + id: image_exists + shell: /usr/bin/bash {0} + run: | + docker manifest inspect ghcr.io/nwchemex-project/base_pluginplay:stable > /dev/null + echo "conclusion=$?" >> "$GITHUB_OUTPUT" + - name: Push stable base image if not exist + if: ${{ steps.image_exists.outputs.conclusion != 0 }} + run: | + docker pull ghcr.io/nwchemex-project/base_pluginplay:latest + docker tag ghcr.io/nwchemex-project/base_pluginplay:latest ghcr.io/nwchemex-project/base_pluginplay:stable + docker push ghcr.io/nwchemex-project/base_pluginplay:stable diff --git a/.github/workflows/build_test_release-manual.yaml b/.github/workflows/build_test_release-manual.yaml new file mode 100644 index 000000000..6decaa9f1 --- /dev/null +++ b/.github/workflows/build_test_release-manual.yaml @@ -0,0 +1,112 @@ +# The building/testing/releasing process happens +# in a container created from the base image (container action). +# In the end two new release images +# ghcr.io/nwchemex-project/release_pluginplay:gcc(clang)-latest +# are generated. Whether these images are stable +# (do not break any downstream repos) or not is still +# to be tested. +# This workflow should run in the branch which opens a +# PR to dev (dev/master model to be developed). + +name: Build test release + +on: + workflow_dispatch: + +jobs: + # TODO: obtain package version info + # general packages for all repos: from NWXCmake + # specific packages for a repo: from dependency_versions.txt in + # the repo + # + # A job to retrieve all package versions and output + ### + update-base-image: + uses: NWChemEx-Project/PluginPlay/.github/workflows/build_base.yaml@master + secrets: inherit + + build_test_release-gcc: + runs-on: ubuntu-latest + needs: update-base-image + steps: + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.CONTAINER_REPO_TOKEN }} + - uses: actions/checkout@v3 + - name: Get current branch name + id: branch-name + uses: tj-actions/branch-names@v7 + - name: build test release in a container + uses: ./.github/actions/container-build_test_release + with: + ninja_build: true + test: true + integration_test: false + INSTALL: true + base_tag: latest + dep_repo_tag: gcc-stable + token: ${{ secrets.CONTAINER_REPO_TOKEN }} + user: ${{ github.actor }} + cmake_version: 3.17.0 + gcc_version: 9 + use_clang: false + CMAIZE_GITHUB_TOKEN: ${{ secrets.CMAIZE_GITHUB_TOKEN }} + branch_name: ${{ steps.branch-name.outputs.current_branch }} + - name: Check stable release image + id: image_exists + shell: /usr/bin/bash {0} + run: | + docker manifest inspect ghcr.io/nwchemex-project/release_pluginplay:gcc-stable > /dev/null + echo "conclusion=$?" >> "$GITHUB_OUTPUT" + - name: Push stable release image if not exist + if: ${{ steps.image_exists.outputs.conclusion != 0 }} + run: | + docker pull ghcr.io/nwchemex-project/release_pluginplay:gcc-latest + docker tag ghcr.io/nwchemex-project/release_pluginplay:gcc-latest ghcr.io/nwchemex-project/release_pluginplay:gcc-stable + docker push ghcr.io/nwchemex-project/release_pluginplay:gcc-stable + + build_test_release-clang: + runs-on: ubuntu-latest + needs: update-base-image + steps: + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.CONTAINER_REPO_TOKEN }} + - uses: actions/checkout@v3 + - name: Get current branch name + id: branch-name + uses: tj-actions/branch-names@v7 + - name: build test release in a container + uses: ./.github/actions/container-build_test_release + with: + ninja_build: true + test: true + integration_test: false + INSTALL: true + base_tag: latest + dep_repo_tag: clang-stable + token: ${{ secrets.CONTAINER_REPO_TOKEN }} + user: ${{ github.actor }} + cmake_version: 3.17.0 + clang_version: 11 + use_clang: true + CMAIZE_GITHUB_TOKEN: ${{ secrets.CMAIZE_GITHUB_TOKEN }} + branch_name: ${{ steps.branch-name.outputs.current_branch }} + - name: Check stable release image + id: image_exists + shell: /usr/bin/bash {0} + run: | + docker manifest inspect ghcr.io/nwchemex-project/release_pluginplay:clang-stable > /dev/null + echo "conclusion=$?" >> "$GITHUB_OUTPUT" + - name: Push stable release image if not exist + if: ${{ steps.image_exists.outputs.conclusion != 0 }} + run: | + docker pull ghcr.io/nwchemex-project/release_pluginplay:clang-latest + docker tag ghcr.io/nwchemex-project/release_pluginplay:clang-latest ghcr.io/nwchemex-project/release_pluginplay:clang-stable + docker push ghcr.io/nwchemex-project/release_pluginplay:clang-stable diff --git a/.github/workflows/build_test_release.yaml b/.github/workflows/build_test_release.yaml new file mode 100644 index 000000000..ae42ceada --- /dev/null +++ b/.github/workflows/build_test_release.yaml @@ -0,0 +1,147 @@ +# The building/testing/releasing process happens +# in a container created from the base image (container action). +# In the end two new release images +# ghcr.io/nwchemex-project/release_pluginplay:gcc(clang)-latest +# are generated. Whether these images are stable +# (do not break any downstream repos) or not is still +# to be tested. +# This workflow should run in the branch which opens a +# PR to dev (dev/master model to be developed). + +name: Build test release + +on: + pull_request: + branches: + - master + +jobs: + # TODO: obtain package version info + # general packages for all repos: from NWXCmake + # specific packages for a repo: from dependency_versions.txt in + # the repo + # + # A job to retrieve all package versions and output + ### + docker-file-changes: + runs-on: ubuntu-latest + outputs: + build_dockfile: ${{ steps.changes.outputs.bdfile }} + steps: + - uses: actions/checkout@v3 + - uses: dorny/paths-filter@v2 + id: changes + with: + filters: | + bdfile: + - '.github/Dockerfile/**' + + update-base-image: + needs: docker-file-changes + if: ${{ needs.docker-file-changes.outputs.build_dockfile == 'true' }} + uses: NWChemEx-Project/PluginPlay/.github/workflows/build_base.yaml@image-build_test_release + secrets: inherit + + build_update_check: + runs-on: ubuntu-latest + needs: docker-file-changes + outputs: + bi_check: ${{ steps.building-image-update.outputs.tag }} + steps: + - name: Check if the building image has been updated + id: building-image-update + run: | + if [ ${{ needs.docker-file-changes.outputs.build_dockfile == 'true' }} ]; then + tag="latest" + else + tag="stable" + fi + echo "tag=$tag" >> $GITHUB_OUTPUT + + build_test_release-gcc: + runs-on: ubuntu-latest + needs: [update-base-image, build_update_check] + if: always() && (needs.update-base-image.result == 'success' || needs.update-base-image.result == 'skipped') + steps: + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.CONTAINER_REPO_TOKEN }} + - uses: actions/checkout@v3 + - name: Get current branch name + id: branch-name + uses: tj-actions/branch-names@v7 + - name: build test release in a container + uses: ./.github/actions/container-build_test_release + with: + ninja_build: true + test: true + integration_test: false + INSTALL: true + base_tag: ${{needs.build_update_check.outputs.bi_check}} + dep_repo_tag: gcc-stable + token: ${{ secrets.CONTAINER_REPO_TOKEN }} + user: ${{ github.actor }} + cmake_version: 3.17.0 + gcc_version: 9 + use_clang: false + CMAIZE_GITHUB_TOKEN: ${{ secrets.CMAIZE_GITHUB_TOKEN }} + branch_name: ${{ steps.branch-name.outputs.current_branch }} + - name: Check stable release image + id: image_exists + shell: /usr/bin/bash {0} + run: | + docker manifest inspect ghcr.io/nwchemex-project/release_pluginplay:gcc-stable > /dev/null + echo "conclusion=$?" >> "$GITHUB_OUTPUT" + - name: Push stable release image if not exist + if: ${{ steps.image_exists.outputs.conclusion != 0 }} + run: | + docker pull ghcr.io/nwchemex-project/release_pluginplay:gcc-latest + docker tag ghcr.io/nwchemex-project/release_pluginplay:gcc-latest ghcr.io/nwchemex-project/release_pluginplay:gcc-stable + docker push ghcr.io/nwchemex-project/release_pluginplay:gcc-stable + + build_test_release-clang: + runs-on: ubuntu-latest + needs: [update-base-image, build_update_check] + if: always() && (needs.update-base-image.result == 'success' || needs.update-base-image.result == 'skipped') + steps: + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.CONTAINER_REPO_TOKEN }} + - uses: actions/checkout@v3 + - name: Get current branch name + id: branch-name + uses: tj-actions/branch-names@v7 + - name: build test release in a container + uses: ./.github/actions/container-build_test_release + with: + ninja_build: true + test: true + integration_test: false + INSTALL: true + base_tag: ${{needs.build_update_check.outputs.bi_check}} + dep_repo_tag: clang-stable + token: ${{ secrets.CONTAINER_REPO_TOKEN }} + user: ${{ github.actor }} + cmake_version: 3.17.0 + clang_version: 11 + use_clang: true + CMAIZE_GITHUB_TOKEN: ${{ secrets.CMAIZE_GITHUB_TOKEN }} + branch_name: ${{ steps.branch-name.outputs.current_branch }} + - name: Check stable release image + id: image_exists + shell: /usr/bin/bash {0} + run: | + docker manifest inspect ghcr.io/nwchemex-project/release_pluginplay:clang-stable > /dev/null + echo "conclusion=$?" >> "$GITHUB_OUTPUT" + - name: Push stable release image if not exist + if: ${{ steps.image_exists.outputs.conclusion != 0 }} + run: | + docker pull ghcr.io/nwchemex-project/release_pluginplay:clang-latest + docker tag ghcr.io/nwchemex-project/release_pluginplay:clang-latest ghcr.io/nwchemex-project/release_pluginplay:clang-stable + docker push ghcr.io/nwchemex-project/release_pluginplay:clang-stable diff --git a/.github/workflows/c-cpp.yaml b/.github/workflows/c-cpp.yaml deleted file mode 100644 index 0834d3143..000000000 --- a/.github/workflows/c-cpp.yaml +++ /dev/null @@ -1,25 +0,0 @@ -name: C_C++_CI - -on: - pull_request: - branches: - - master - -jobs: - build-with-gcc: - uses: NWChemEx-Project/.github/.github/workflows/c-cpp_tmpl.yaml@master - with: - dependencies: 'ninja gcc gcovr cmake openmpi boost libfort' - clang-build: false - gcc-build: true - ninja_build: true - secrets: - CMAIZE_GITHUB_TOKEN: ${{ secrets.CMAIZE_GITHUB_TOKEN }} - # build-with-clang: - # uses: NWChemEx-Project/.github/.github/workflows/c-cpp_tmpl.yaml@master - # with: - # dependencies: 'clang gcovr cmake openmpi boost' - # clang-build: true - # gcc-build: false - # secrets: - # CMAIZE_GITHUB_TOKEN: ${{ secrets.CMAIZE_GITHUB_TOKEN }} diff --git a/CMakeLists.txt b/CMakeLists.txt index d136cb170..9c75994e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -161,12 +161,17 @@ if("${BUILD_TESTING}") DEPPACKAGES pluginplay ) cmaize_add_tests( - test_${PROJECT_NAME} + test_unit_${PROJECT_NAME} SOURCE_DIR ${tests_src_dir} INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/${PROJECT_NAME}" DEPENDS Catch2::Catch2 ${PROJECT_NAME} ${PROJECT_NAME}_examples ) - + cmaize_add_tests( + test_integration_${PROJECT_NAME} + SOURCE_DIR "${cxx_test_dir}/integration_tests" + INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/${PROJECT_NAME}" + DEPENDS Catch2::Catch2 ${PROJECT_NAME} ${PROJECT_NAME}_examples + ) cmaize_add_tests( test_${PROJECT_NAME}_docs SOURCE_DIR "${cxx_test_dir}/doc_snippets" diff --git a/tests/cxx/integration_tests/blank_test.cpp b/tests/cxx/integration_tests/blank_test.cpp new file mode 100644 index 000000000..f0e48aacb --- /dev/null +++ b/tests/cxx/integration_tests/blank_test.cpp @@ -0,0 +1,27 @@ +/* + * Copyright 2023 NWChemEx-Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define CATCH_CONFIG_MAIN +#include +#include + +int print_and_return(int ii) { + std::cout << "This is only a blank model for an integration test." + << std::endl; + return 0; +} + +TEST_CASE("Blank test", "[classic]") { REQUIRE(print_and_return(0) == 0); }