open-simulation-platform / libcosim

OSP C++ co-simulation library
https://open-simulation-platform.github.io/libcosim
Mozilla Public License 2.0
61 stars 10 forks source link

Clean up Conan CI build environment using Docker and run tests in Conan CI builds #644

Closed kyllingstad closed 3 years ago

kyllingstad commented 3 years ago

This change was motivated by some test failures in PR #633 which are almost surely unrelated to the PR itself. The probable diagnosis is simply that the build environment provided by GitHub's workflow runners is so messy that some unwanted library inadvertently gets picked up from outside the Conan package ecosystem. (We add to the mess by installing an additional GCC version, which happens to be the version for which the tests fail...)

Long story short, here I've set up a cleaner build environment using Docker. The building still takes place on GitHub's runners, but is now isolated from the messy host environment inside a Docker container. The base environments for the different compilers are the ones used for Conan Center.

The process, described in the Linux part of .github/workflows/ci-conan.yml, now goes like this:

  1. Generate /tmp/osp-builder-docker/Dockerfile, which defines the build environment as a Docker image.
  2. Generate /tmp/osp-builder-docker/entrypoint.sh, which gets copied into the Docker image as /entrypoint.sh and contains the actual libcosim build steps.
  3. Build a Docker image named osp-builder based on the above files.
  4. Run a Docker container based off osp-builder, i.e., run /entrypoint.sh inside the build environment. The source folder which is checked out on the host runner gets mounted read-only at /mnt/source inside the container.

I've included a change which was originally in #633, namely the addition of the environment variable LIBCOSIM_RUN_TESTS_ON_CONAN_BUILD, added so we can run tests in Conan-based CI builds too.

kyllingstad commented 3 years ago

@markaren, two notes for PR #633:

markaren commented 3 years ago

Wupsie, seems tests are not enabled for windows (ENV not set)

kyllingstad commented 3 years ago

Good catch! And enabling it revealed another problem: When environment variables are set to True in a workflow YAML file, it gets interpreted as a boolean rather than a string and converted to lowercase true during the parsing process. Conan only understands the literal values True and 1 for its environment variables, and true gets interpreted as false. :-|

This is probably an issue with the CMake CI setup too, so I'll investigate and open a separate PR for that if necessary.