Skip to content

Commit

Permalink
Docker: Move CMake test into test_cmake.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
oschuett committed May 3, 2023
1 parent c772426 commit e0ef5d2
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 35 deletions.
21 changes: 6 additions & 15 deletions tools/docker/Dockerfile.test_cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,28 +60,19 @@ COPY ./tools/toolchain/scripts/arch_base.tmpl \
RUN ./scripts/generate_arch_files.sh && rm -rf ./build


COPY ./tools/build_utils/fypp /bin/fypp

# Install CP2K using CMake.

WORKDIR /opt/cp2k
COPY ./src ./src
COPY ./exts ./exts
COPY ./tools/build_utils ./tools/build_utils
COPY ./cmake ./cmake
COPY ./CMakeLists.txt .
WORKDIR ./build
RUN /bin/bash -c " \
echo 'Compiling cp2k...' && \
source /opt/cp2k-toolchain/install/setup && \
cmake -Werror=dev -DCP2K_USE_VORI=ON -DCP2K_USE_COSMA=NO -DCP2K_BLAS_VENDOR=OpenBLAS -DCP2K_USE_SPGLIB=ON -DCP2K_USE_LIBINT2=ON -DCP2K_USE_LIBXC=ON -DCP2K_USE_LIBTORCH=OFF -DCP2K_ENABLE_CONSISTENCY_CHECKS=ON -DCP2K_BUILD_DBCSR=ON -DCP2K_ENABLE_REGTESTS=ON .. |& tee ./cmake.log && \
! grep -A5 'CMake Warning' ./cmake.log && \
make -j"
WORKDIR /opt/cp2k
COPY ./data ./data
COPY ./tests ./tests
COPY ./tools/regtesting ./tools/regtesting

RUN echo "\nSummary: Compilation works fine.\nStatus: OK\n"
COPY ./tools/docker/scripts/test_cmake.sh .
RUN ./test_cmake.sh 2>&1 | tee report.log

# Output the report if the image is old and was therefore pulled from the build cache.
CMD cat $(find ./report.log -mmin +10) | sed '/^Summary:/ s/$/ (cached)/'
ENTRYPOINT []

#EOF
26 changes: 6 additions & 20 deletions tools/docker/generate_dockerfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,36 +404,22 @@ def install_cp2k(

# ======================================================================================
def install_cp2k_cmake() -> str:
# TODO: This is a draft and does not yet actually work.

return rf"""
COPY ./tools/build_utils/fypp /bin/fypp
return (
rf"""
# Install CP2K using CMake.
WORKDIR /opt/cp2k
COPY ./src ./src
COPY ./exts ./exts
COPY ./tools/build_utils ./tools/build_utils
COPY ./cmake ./cmake
COPY ./CMakeLists.txt .
WORKDIR ./build
RUN /bin/bash -c " \
echo 'Compiling cp2k...' && \
source /opt/cp2k-toolchain/install/setup && \
cmake -Werror=dev -DCP2K_USE_VORI=ON -DCP2K_USE_COSMA=NO -DCP2K_BLAS_VENDOR=OpenBLAS -DCP2K_USE_SPGLIB=ON -DCP2K_USE_LIBINT2=ON -DCP2K_USE_LIBXC=ON -DCP2K_USE_LIBTORCH=OFF -DCP2K_ENABLE_CONSISTENCY_CHECKS=ON -DCP2K_BUILD_DBCSR=ON -DCP2K_ENABLE_REGTESTS=ON .. |& tee ./cmake.log && \
! grep -A5 'CMake Warning' ./cmake.log && \
make -j"
WORKDIR /opt/cp2k
COPY ./data ./data
COPY ./tests ./tests
COPY ./tools/regtesting ./tools/regtesting
RUN echo "\nSummary: Compilation works fine.\nStatus: OK\n"
#EOF
COPY ./tools/docker/scripts/test_cmake.sh .
RUN ./test_cmake.sh 2>&1 | tee report.log
"""
+ print_cached_report()
)


# ======================================================================================
Expand Down
41 changes: 41 additions & 0 deletions tools/docker/scripts/test_cmake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash -e

# shellcheck disable=SC1091
source /opt/cp2k-toolchain/install/setup

ln -s /opt/cp2k/tools/build_utils/fypp /bin/fypp

mkdir build
cd build

if ! cmake \
-Werror=dev \
-DCP2K_USE_VORI=ON \
-DCP2K_USE_COSMA=NO \
-DCP2K_BLAS_VENDOR=OpenBLAS \
-DCP2K_USE_SPGLIB=ON \
-DCP2K_USE_LIBINT2=ON \
-DCP2K_USE_LIBXC=ON \
-DCP2K_USE_LIBTORCH=OFF \
-DCP2K_BUILD_DBCSR=ON \
-DCP2K_ENABLE_REGTESTS=ON \
.. |& tee ./cmake.log; then
echo -e "\nSummary: CMake failed."
echo -e "Status: FAILED\n"
fi

if grep -A5 'CMake Warning' ./cmake.log; then
echo -e "\nSummary: Found CMake warnings."
echo -e "Status: FAILED\n"
fi

echo -e '\n\nCompiling cp2k...'
if make -j; then
echo -e "\nSummary: Compilation works fine."
echo -e "Status: OK\n"
else
echo -e "\nSummary: Compilation failed."
echo -e "Status: FAILED\n"
fi

#EOF

0 comments on commit e0ef5d2

Please sign in to comment.