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

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

Merged
merged 3 commits into from
Aug 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 34 additions & 28 deletions .github/workflows/ci-conan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,41 @@ name: libcosim CI Conan
# This workflow is triggered on pushes to the repository.
on: [push, workflow_dispatch]

env:
CONAN_LOGIN_USERNAME_OSP: ${{ secrets.osp_artifactory_usr }}
CONAN_PASSWORD_OSP: ${{ secrets.osp_artifactory_pwd }}
CONAN_REVISIONS_ENABLED: 1
CONAN_NON_INTERACTIVE: True
CONAN_USE_ALWAYS_SHORT_PATHS: True

jobs:
conan-on-linux:
name: Conan
runs-on: ${{ matrix.os }}
env:
CC: gcc-${{ matrix.compiler_version }}
CXX: g++-${{ matrix.compiler_version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu-18.04]
build_type: [Debug, Release]
compiler_version: [7, 8, 9]
compiler_libcxx: [libstdc++11]
option_fmuproxy: ['fmuproxy=True', 'fmuproxy=False']

steps:
- uses: actions/checkout@v2
- name: Install prerequisites
- name: Generate Dockerfile
run: |
sudo apt-get install -y --no-install-recommends \
g++-8
sudo pip3 install --upgrade setuptools pip
sudo pip3 install conan
- name: Configure Conan
run: conan remote add osp https://osp.jfrog.io/artifactory/api/conan/conan-local --force
- name: Conan create
mkdir /tmp/osp-builder-docker
cat <<'EOF' >/tmp/osp-builder-docker/Dockerfile
FROM conanio/gcc${{ matrix.compiler_version }}
ENV CONAN_LOGIN_USERNAME_OSP=${{ secrets.osp_artifactory_usr }}
ENV CONAN_PASSWORD_OSP=${{ secrets.osp_artifactory_pwd }}
ENV CONAN_REVISIONS_ENABLED=1
ENV CONAN_NON_INTERACTIVE=True
ENV CONAN_USE_ALWAYS_SHORT_PATHS=True
ENV LIBCOSIM_RUN_TESTS_ON_CONAN_BUILD=True
COPY entrypoint.sh /
ENTRYPOINT /entrypoint.sh
EOF
- name: Generate entrypoint.sh
run: |
cat <<'EOF' >/tmp/osp-builder-docker/entrypoint.sh
#!/bin/bash -v
set -eu
cd /mnt/source
conan remote add osp https://osp.jfrog.io/artifactory/api/conan/conan-local --force
REFNAME="${GITHUB_REF#refs/*/}"
VERSION="v$(<version.txt)"
if [[ $GITHUB_REF == refs/tags/* ]] && [[ $REFNAME == $VERSION ]]; then CHANNEL="stable"
Expand All @@ -47,16 +47,27 @@ jobs:
CHANNEL="testing-${SHORT_REFNAME//\//_}"
fi
conan create -s build_type=${{ matrix.build_type }} -s compiler.version=${{ matrix.compiler_version }} -s compiler.libcxx=${{ matrix.compiler_libcxx }} -o ${{ matrix.option_fmuproxy }} -b missing . osp/${CHANNEL}
- name: Conan upload
run: |
conan upload --all -c -r osp '*'
EOF
chmod 0755 /tmp/osp-builder-docker/entrypoint.sh
- name: Build Docker image
run: |
docker build -t osp-builder /tmp/osp-builder-docker/
- name: Build cosim
run: |
docker run --rm --env GITHUB_REF="$GITHUB_REF" -v $(pwd):/mnt/source:ro osp-builder

conan-on-windows:
name: Conan
runs-on: ${{ matrix.os }}
env:
CONAN_USER_HOME_SHORT: C:\c
CONAN_LOGIN_USERNAME_OSP: ${{ secrets.osp_artifactory_usr }}
CONAN_PASSWORD_OSP: ${{ secrets.osp_artifactory_pwd }}
CONAN_REVISIONS_ENABLED: 1
CONAN_NON_INTERACTIVE: 1
CONAN_USE_ALWAYS_SHORT_PATHS: 1
CONAN_USER_HOME_SHORT: C:\c
LIBCOSIM_RUN_TESTS_ON_CONAN_BUILD: 1
strategy:
fail-fast: false
matrix:
Expand All @@ -65,11 +76,6 @@ jobs:
compiler_version: [15]
option_fmuproxy: ['fmuproxy=True', 'fmuproxy=False']

exclude:
- os: windows-2016
build_type: Debug
option_fmuproxy: 'fmuproxy=True'

steps:
- uses: actions/checkout@v2
- name: Install prerequisites
Expand Down
13 changes: 11 additions & 2 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

from conans import ConanFile, CMake, tools
from conans import ConanFile, CMake, RunEnvironment, tools
from os import path


Expand Down Expand Up @@ -37,6 +37,9 @@ class LibcosimConan(ConanFile):
"xerces-c:shared=True"
)

def is_tests_enabled(self):
return os.getenv("LIBCOSIM_RUN_TESTS_ON_CONAN_BUILD", "False").lower() in ("true", "1")

def set_version(self):
self.version = tools.load(path.join(self.recipe_folder, "version.txt")).strip()

Expand All @@ -53,15 +56,21 @@ def configure_cmake(self):
cmake = CMake(self)
cmake.definitions["LIBCOSIM_USING_CONAN"] = "ON"
cmake.definitions["LIBCOSIM_BUILD_APIDOC"] = "OFF"
cmake.definitions["LIBCOSIM_BUILD_TESTS"] = "OFF"
cmake.definitions["LIBCOSIM_BUILD_TESTS"] = self.is_tests_enabled()
if self.options.fmuproxy:
cmake.definitions["LIBCOSIM_WITH_FMUPROXY"] = "ON"
cmake.definitions["LIBCOSIM_TEST_FMUPROXY"] = "OFF" # Temporary, to be removed again in PR #633
cmake.configure()
return cmake

def build(self):
cmake = self.configure_cmake()
cmake.build()
if self.is_tests_enabled():
env_run = RunEnvironment(self)
with tools.environment_append(env_run.vars):
cmake.test(output_on_failure=True)


def package(self):
cmake = self.configure_cmake()
Expand Down