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

New docker-image-based CI #316

Merged
merged 18 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 28 additions & 0 deletions .github/Dockerfile/base-catch2.Dockerfile
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions .github/Dockerfile/base-libboost.Dockerfile
Original file line number Diff line number Diff line change
@@ -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/*
25 changes: 25 additions & 0 deletions .github/Dockerfile/base-libfort.Dockerfile
Original file line number Diff line number Diff line change
@@ -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}"
24 changes: 24 additions & 0 deletions .github/actions/container-build_test_release/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
86 changes: 86 additions & 0 deletions .github/actions/container-build_test_release/action.yaml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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"]
Original file line number Diff line number Diff line change
@@ -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

Loading
Loading