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

Use official Clang/GCC containers #3703

Merged
merged 44 commits into from
Aug 27, 2022
Merged

Use official Clang/GCC containers #3703

merged 44 commits into from
Aug 27, 2022

Conversation

nlohmann
Copy link
Owner

@nlohmann nlohmann commented Aug 14, 2022

This PR tries to use the containers from https://hub.docker.com/r/silkeh/clang and https://hub.docker.com/_/gcc where possible instead of using the "big" json-ci container.

So far, I could use the official images for all Clang versions and GCC versions >= 7.

For GCC 4.8 to GCC 6, some fetch_content tests fail which I have not yet looked into in detail.

The runtime is much faster now, because the images only take ~1 minute to come up which goes down to few seconds when cached.

Todos:

  • investigate GCC 4.8 to GCC 6
  • update versions in README
  • remove migrated versions from json-ci container. (see Remove unused tools json-ci#16)
  • check if official versions can be used for the "clang" and "gcc" targets with maximal warnings
  • check if lukka/get-cmake@latest can help to move some jobs to GitHub images

@github-actions github-actions bot added L and removed M labels Aug 14, 2022
@github-actions github-actions bot added M and removed L labels Aug 14, 2022
@coveralls
Copy link

coveralls commented Aug 14, 2022

Coverage Status

Coverage remained the same at 100.0% when pulling f4504f1 on docker_images into 8fcdbf2 on develop.

@github-actions github-actions bot added the tests label Aug 20, 2022
@github-actions github-actions bot removed the tests label Aug 20, 2022
@github-actions github-actions bot added L and removed M labels Aug 21, 2022
@github-actions github-actions bot added the tests label Aug 21, 2022
@nlohmann nlohmann marked this pull request as ready for review August 27, 2022 12:11
@@ -30,7 +30,7 @@ execute_process(COMMAND ${CPPCHECK_TOOL} --version OUTPUT_VARIABLE CPPCHECK_TOOL
string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" CPPCHECK_TOOL_VERSION "${CPPCHECK_TOOL_VERSION}")
message(STATUS "🔖 Cppcheck ${CPPCHECK_TOOL_VERSION} (${CPPCHECK_TOOL})")

find_program(GCC_TOOL NAMES g++-latest g++-HEAD g++-11 g++-10)
find_program(GCC_TOOL NAMES g++-latest g++-HEAD g++-12 g++-11 g++-10)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GCC compiler detection needs some love. This doesn't work on Gentoo and I always have to remember to specify GCC_TOOL manually.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. I would be able to remove this altogether once we clean up the CI image. I could not use gcc:latest btw. due to incompatible compiler flags.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compiler flags are also a challenge for the CMake preset file. I was really hoping for a convenient way to use the CI warning flags in local builds. But that might resolve your issue, as I have to sort all flags by compiler version.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, the CI targets are meant to work in the context of this project's CI. If they are useful on a different machine, then this is fine, but only a coincidence.

Copy link
Contributor

@falbrechtskirchinger falbrechtskirchinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment about future improvements, otherwise looks good to me.

@@ -667,8 +667,11 @@ add_custom_target(ci_cppcheck
###############################################################################

add_custom_target(ci_cpplint
COMMAND ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/cpplint/cpplint.py --filter=-whitespace,-legal,-runtime/references,-runtime/explicit,-runtime/indentation_namespace,-readability/casting,-readability/nolint --quiet --recursive ${SRC_FILES}
COMMAND ${Python3_EXECUTABLE} -mvenv venv_cpplint
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not super happy about more venvs being hard-coded.

In general, I'd like to be able to specify a) don't use a venv at all, or b) create/use a venv at a specific location. (I'm experimenting with this approach here: https://github.com/falbrechtskirchinger/json-ci/blob/split3/Makefile) One more thing for the ever-growing to-do list, I guess. ;-)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what's bad about this venv. Like this, the target is independent and just needs a Python interpreter - and allows to execute this target independently of any Docker image.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just like the option to use or not use a venv, and if I choose to use a venv, specify its location. There's no reason to have a separate venv for every working tree and in the case of cpplint, there's no reason to use any venv on my system at all.

venvs are a (small) reason why my json directory (with currently 31 working trees) is over 20GB in size.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could set up the venv in the GitHub Actions job and assume in this target that cpplint can be called.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most importantly, things should work consistently across Makefiles and CMake.

I like the idea of having two environment variables per venv:
JSON_<NAME>_USE_VENV to enable or disable using a venv (default true)
JSON_<NAME>_VENV that specifies the path of the venv (with a default, if not set)

This works in the Makefile linked above and I'd want to repeat it for mkdocs, reuse, etc,
I haven't thought about how to apply that concept to GitHub workflows and CMake code yet but am aware of the Python3_FIND_VIRTUALENV option of FindPython3, for example.

Eventually, I envision adding the following to my .bashrc or .profile and avoid unnecessary duplication:

JSON_MKDOCS_USE_VENV=true
JSON_MKDOCS_VENV="$HOME/projects/json/.share/venvs/mkdocs"
JSON_REUSE_USE_VENV=true
JSON_REUSE_VENV="$HOME/projects/json/.share/venvs/reuse"
JSON_CPPLINT_USE_VENV=false

JSON_TEST_DATA_DIRECTORY="$HOME/projects/json/.share/json_test_data"

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just hard-code .share/venv to the Makefiles/CMakeLists.txt? Then the CI can install the required things there, and everybody else can bring their own venv.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

projects/json is not the git checkout. projects/json/develop is and then I create additional working directories using git worktree add ../my-feature which creates the branch my-feature and the working tree projects/json/my-feature. See https://github.com/nlohmann/json/tree/develop/tools/serve_header#serving-jsonhpp-from-multiple-project-directory-instances-or-working-trees.

The whole point is for the venv to be able to sit outside of the git checkout and to be shared by multiple working trees.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry - I mistook the directory.

@nlohmann nlohmann added this to the Release 3.11.3 milestone Aug 27, 2022
@nlohmann nlohmann merged commit f7973f4 into develop Aug 27, 2022
@nlohmann nlohmann deleted the docker_images branch August 27, 2022 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants