|
SpECTRE
2021.08.02
|
SpECTRE uses TravisCI for testing the code. Multiple build jobs (described below) are launched each time a pull request is submitted or updated. In addition, a daily cron job is run. Travis will also launch these build jobs each time you push to a branch on your fork of SpECTRE if you enable it. (Go to Travis, click on your name in the upper right corner, and then towards the bottom, enable testing on your fork of SpECTRE.)
For pull requests, you can view the Travis CI build by clicking on Details next to the Travis build failed or Travis build succeeded in the section for All checks have failed or All checks have passed towards the bottom of the pull request. You can login to Travis using your GitHub credentials in order to cancel your builds, and you should do so if you update your pull request while it is building.
The Travis report lists the build jobs which will each have either a green check mark if it passes, a red X if it has failed, or a yellow binary if the build is in progress. Clicking on a build job will display the log of the build.
The following build jobs are launched:
tools/CheckCommits.sh and fails the build if any casing of the words in the list below is the first word of the commit message. This allows developers to flag their commits with these keywords to indicate that a pull request should not be merged in its current state.tools/CheckFiles.sh (which also runs the script tools/FileTestDefs.sh), and tools/CheckPythonFormatting.sh. The checks fail if any of the following are true:tools/FileTestDefs.sh for the full list of exceptions.)c++ header file (i.e., *.hpp or *.tpp) is missing #pragma oncec++ file (i.e., *.hpp, *.tpp, or *.cpp) file,<iostream> (useless when running in parallel)<lrtslock.h> (use <converse.h> instead)"Utilities/TmplDebugging.hpp" (used only for debugging)*.cpp filenamespace ending in _details (use _detail)struct TD or class TD (used only for debugging)std::enable_if (use Requires instead)Ls (use List instead)/*! (does not render correctly in Doxygen)return Py_None; (bug prone, use Py_RETURN_NONE instead)c++ test,TEST_CASE (use SPECTRE_TEST_CASE instead)Approx (use approx instead)CMakeLists.txt file in src, but not in an Executables or Python-binding directory,C++ file that is present in the directoryC++ file that is not present in the directoryc++ or python file contains a TODO (case-insensitive) commenttests/Unit/RunSingleTest/CMakeLists.txt wasn't modified.style.yapf file in the root of the repository..travis/RunClangTidy.sh which runs clang-tidy on all files which were modified. This is done for both Release and Debug builds.tools/CheckFiles.sh --test which tests the checks performed in the CHECK_FILES build.Release and Debug builds, for the gcc and clang compilers using a Linux OS, and the AppleClang compiler for OS X.gcc Debug build will fail if there are doxygen warnings.Before pushing to GitHub and waiting for Travis to perform the checks it is useful to perform at least the following tests locally:
make test-executables and then execute ctest to run all unit tests. As for make you can append a -jN flag to ctest to run in parallel on N cores. To run only a subset of the tests you can use one of the other keywords that the tests are labeled with, such as ctest -L datastructures. To run only particular tests you can also execute ctest -R TEST_NAME instead, where TEST_NAME is a regular expression matching the test identifiers such as Unit.DataStructures.Mesh. Pass the flag --output-on-failure to get output from failed tests. Consult ctest -h for further options.make clang-tidy FILE=SOURCE_FILE where SOURCE_FILE is a relative or absolute path to a .cpp file. To perform this check for all source files that changed in your pull request, make clang-tidy-hash HASH=UPSTREAM_HEAD where UPSTREAM_HEAD is the hash of the commit that your pull request is based on, usually the HEAD of the upstream/develop branch.make doc (or make doc-check to highlight warnings) can be used, placing its result in the docs directory in the build tree. Once code has been made into a pull request to GitHub, the documentation can be rendered locally using the tools/pr-docs script. To view the documentation, simply open the index.html file in the html subdirectory in a browser. Some functionality requires a web server (e.g. citation popovers), so just run a python3 -m http.server in the html directory to enable this.make iwyu-hash HASH=UPSTREAM_HEAD. Since IWYU requires USE_PCH=OFF you can create a separate build directory and append -D USE_PCH=OFF to the usual cmake call. Note that it is very easy to incorrectly install IWYU (if not using the Docker container) and generate nonsense errors. Note that we have left IWYU pragmas in the code, but no longer require they be added so that IWYU gives no errors when run. As IWYU is still under development, we plan to investigate using it again in the future.gcc Debug build runs code coverage for each Travis build.Restart build button to the right of the pull request description.More options button in the top right, choose Caches and delete the cache for your pull request.Getting ccache to work with precompiled headers on TravisCI is a little challenging. The header to be precompiled is ${SPECTRE_SOURCE_DIR}/tools/SpectrePch.hpp and is symbolically linked to ${SPECTRE_BUILD_DIR}/SpectrePch.hpp. The configuration that seems to work is specifying the environment variables:
On macOS builds we haven't yet had success with using ccache with a precompiled header. We disable the precompiled header and build in debug mode only to have reasonable build times.
In order to avoid timeouts we build SpECTRE in various stages, carrying over the ccache from one stage to the next. This allows us to avoid recompiling the code in the next stage (there is some small overhead from running ccache instead of not doing anything at all). The first stage builds all the SpECTRE libraries but none of the executables or testing libraries. The second stage builds builds the test executables, runs the tests, and also runs ClangTidy, include-what-you-use, and various other checks. Another stage could be added that builds some of the test libraries if necessary.
On macOS builds we cache all of our dependencies, like LIBXSMM and Charm++. These are cached in $HOME/mac_cache. Ultimately this saves about 10-12 minutes even when compared to using ccache to cache the object files from building the dependencies. We also cache $HOME/Library/Caches/Homebrew, which is where Homebrew keeps the downloaded formulas. By caching the Homebrew bottles we are able to avoid brew formulas building from source because a tarball of the package was not available at the time.