12 CP2K CI
Zilong HE edited this page 2026-11-16 21:59:01 +08:00

The CP2K Continuous Integration (CI) system performs tests on every Pull Requests to the main cp2k repository, so as to verify that the revisions to code do not break important functionalities and workflows. The machinery is maintained at the separate repository cp2k/cp2k-ci, while the definitions and procedures are under the tools/docker directory in the main cp2k repository.

Mandatory checks

The CI always run the following five checks:

Git history

We want to keep the git history linear. If the git history of the PR contains one or more merge commits, this check will fail.

So, as instructed on Git Tips & Tricks, please always use git rebase instead of git pull when updating the branches of the local repository. For some background info see:

Precommit

Some of the formatting and style conventions of the project are analyzed and implemented during the precommit check. Fortran codes, C codes, Python scripts, Shell scripts, CMake scripts, MarkDown documents, etc are handled by various tools; refer to ./tools/precommit/README.md for details.

Always run ./make_pretty.sh to fix the potential issues automatically and locally prior to making the PR. This is a wrapper script for ./tools/precommit/precommit.py which connects to the online precommit server to inspect the files and stores cache entries in the ./obj/precommit directory. It runs through the entire repository by default, regardless of whether a file has been modified or not, only skipping the cached entries as well as certain directories of large files, build artifacts, logs and backups. The dashboard report plots the number of checked files by type.

Tip

To save time and touch only the files that have been revised, say ./src/particle_methods.F, append the filenames as arguments like ./make_pretty.sh ./src/particle_methods.F. The list of filenames can be generated from git diff (for changed but not yet staged files) or git show (for committed files) commands. This allows for convenient one-liners like:

./make_pretty.sh $(git diff --name-only --diff-filter=d | tr "\n" " ")
./make_pretty.sh $(git show --pretty=format: --name-only --diff-filter=d | tr "\n" " ")

Conventions

To ensure that all Fortran codes adhere to the coding conventions, this check builds CP2K with a CMake preset of special compiler flags and analyzes the resulting abstract syntax tree. The procedure is defined in the directory ./tools/conventions, and the --check_conventions flag of make_cp2k.sh performs a convention check after a local build with Spack.

This has recently been extended to analyze also C/C++ codes using clang-tidy, with the rules stated in ./tools/conventions/clang-tidy.yaml.

Ideally new violations should not be introduced in a PR, including but not limited to hardcoded write unit in WRITE (*, *) statements, type without initializer, bugprone unsafe functions, etc. A justified or unavoidable violation may be tolerated, in which case the suppression should be registered in ./tools/conventions/conventions.supp. The dashboard report tracks the number of suppressed convention violations.

Misc

A few peripheral tests of Python scripts.

Regtest pdbg

Compile the CP2K program on the cloud and run through all unit test binaries and the whole regression test suite (regtest) in parallel. Standalone unit test codes are defined in various *__unittest.F files in the src/ directory and are compiled along with the main CP2K binary; input files and reference results for the regression test are put in several categories under the tests/ directory. The procedure is based on ./tests/do_regtest.py which is elaborated on the manual; the --test flag of make_cp2k.sh also launches such a test after a local build with Spack.

This is the most time-consuming and resource-extensive check of the five. Therefore, when adding new input file(s) and/or unit test(s) for testing new features, it is recommended to use lightweight ones that complete within seconds, require little disk space, and are numerically stable.

Optional checks

Apart from the five above, many other checks have been designed to cover a variety of compiler flavors and versions, hardware specs, environment configurations and interfaced workflows. Compiling the program and performing these checks for every PR would impose significant server load, so they are made optional before a PR is eligible for merging, but still tracked regularly in the CP2K Dashboard on a daily or weekly basis.

When appropriate, they are triggered manually on demand by any member of the cp2k-developers with a comment to the PR. For instance, saying /cp2kci gcc16 intel-ifx-psmp in the comments triggers the gcc16 and intel-ifx-psmp tests as defined in tools/docker/cp2k-ci.conf, as signalled by cp2k-ci[bot] reacting with eyes emoji.

Some checks monitors every revision to files in a particular trigger_path. For instance, the "Manual generation" check that generates a set of the manual as html pages, including the documentation pages and the whole input reference, will be triggered by a PR touching the docs/ directory. Note that the manual also includes the input reference defined in the src/ directory; if significant revision takes place there, in particular one with many math entities and layout arrangements, then triggering the check by making a comment /cp2kci manual may still be necessary.