Docker: Migrate manual test to CMake

This commit is contained in:
Ole Schütt 2025-07-23 17:47:30 +02:00 committed by Ole Schütt
parent a99a1edcfd
commit aaa8291090
5 changed files with 20 additions and 32 deletions

View file

@ -356,9 +356,11 @@ if(NOT Python_EXECUTABLE)
endif()
# get the git hash Get the latest abbreviated commit hash of the working branch
# As a fall back, e.g. in a container, try reading a file named "REVISION".
execute_process(
COMMAND git log -1 --format=%h
COMMAND bash -c "git log -1 --format=%h || cat REVISION"
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
ERROR_QUIET
OUTPUT_VARIABLE CP2K_GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE)

View file

@ -1632,7 +1632,7 @@ add_fypp_sources(CP2K_SRCS ${CP2K_SRCS_F})
# set the __SHORT_FILE__ per file for CP2K sources
foreach(cp2k_src ${CP2K_SRCS})
# add_fypp_sources returns a path in the current binary dir
get_filename_component(short_file "${cp2k_src}" NAME)
file(RELATIVE_PATH short_file "${CMAKE_BINARY_DIR}/src" "${cp2k_src}")
set_source_files_properties(
${cp2k_src} PROPERTIES COMPILE_DEFINITIONS __SHORT_FILE__="${short_file}")
endforeach()

View file

@ -23,7 +23,7 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--mpi-mode=mpich \
--with-dbcsr=no \
--with-dbcsr \
--with-gcc=system \
--dry-run
@ -64,20 +64,21 @@ COPY ./tools/toolchain/scripts/arch_base.tmpl \
./scripts/
RUN ./scripts/generate_arch_files.sh && rm -rf ./build
# Install CP2K using local.psmp.
WORKDIR /opt/cp2k
ARG GIT_COMMIT_SHA
COPY ./Makefile .
ENV GIT_COMMIT_SHA=${GIT_COMMIT_SHA}
# Install CP2K sources.
WORKDIR /opt/cp2k
COPY ./src ./src
COPY ./exts ./exts
COPY ./tools/build_utils ./tools/build_utils
RUN /bin/bash -c " \
if [ -n "${GIT_COMMIT_SHA}" ] ; then echo "git:\${GIT_COMMIT_SHA::7}" > REVISION; fi && \
mkdir -p arch && \
ln -vs /opt/cp2k-toolchain/install/arch/local.psmp ./arch/"
COPY ./data ./data
COPY ./tests ./tests
COPY ./tools/regtesting ./tools/regtesting
COPY ./tools/build_utils ./tools/build_utils
COPY ./cmake ./cmake
COPY ./CMakeLists.txt .
# Compile CP2K.
COPY ./tools/docker/scripts/build_cp2k_cmake.sh .
RUN ./build_cp2k_cmake.sh toolchain_all psmp
# Generate manual.
COPY ./docs ./docs

View file

@ -112,7 +112,7 @@ def main() -> None:
f.write(conventions())
with OutputFile(f"Dockerfile.test_manual", args.check) as f:
f.write(install_deps_toolchain())
f.write(install_deps_toolchain(with_dbcsr=""))
f.write(manual())
with OutputFile(f"Dockerfile.test_precommit", args.check) as f:
@ -255,7 +255,7 @@ RUN /bin/bash -ec " \
# ======================================================================================
def manual() -> str:
return (
install_cp2k(version="psmp", arch="local", revision=True)
install_cp2k_cmake(profile="toolchain_all", version="psmp", revision=True)
+ rf"""
# Generate manual.
COPY ./docs ./docs

View file

@ -5,21 +5,6 @@
# shellcheck disable=SC1091
source /opt/cp2k-toolchain/install/setup
echo -e "\n========== Compiling CP2K =========="
cd /opt/cp2k
echo -n "Compiling cp2k... "
if make -j VERSION=psmp &> make.out; then
echo "done."
else
echo -e "failed.\n\n"
tail -n 100 make.out
mkdir -p /workspace/artifacts/
cp make.out /workspace/artifacts/
echo -e "\nSummary: Compilation failed."
echo -e "Status: FAILED\n"
exit 0
fi
echo -e "\n========== Installing Dependencies =========="
apt-get update -qq
apt-get install -qq --no-install-recommends \
@ -42,8 +27,8 @@ echo -e "\n========== Generating Manual =========="
mkdir -p /workspace/artifacts/manual
cd /workspace/artifacts/manual
/opt/cp2k/exe/local/cp2k.psmp --version
/opt/cp2k/exe/local/cp2k.psmp --xml
/opt/cp2k/build/bin/cp2k.psmp --version
/opt/cp2k/build/bin/cp2k.psmp --xml
set +e # disable error trapping for remainder of script
(