From 3d72a8b80125c1bac3054f5297430e0ab948eaec Mon Sep 17 00:00:00 2001 From: Corentin Schreiber Date: Tue, 5 Sep 2023 17:17:29 +0100 Subject: [PATCH 1/2] Add conan-center test container --- docker/Dockerfile.conan-center | 74 ++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 docker/Dockerfile.conan-center diff --git a/docker/Dockerfile.conan-center b/docker/Dockerfile.conan-center new file mode 100644 index 00000000..d4c5eb62 --- /dev/null +++ b/docker/Dockerfile.conan-center @@ -0,0 +1,74 @@ +# NOTE: This Dockerfile is meant to test the integration of snitch in the Conan center. +# You can use it to get a hint on how to fetch snitch with Conan (v1 or v2). + +# ------------------------------------------- +# Base images +# ------------------------------------------- +# Base image with build tools +FROM ubuntu:latest AS snitch-dev-base +RUN apt update && apt install -y g++ python3 python3-pip python-is-python3 git wget rsync bash +RUN wget -q https://github.com/Kitware/CMake/releases/download/v3.15.7/cmake-3.15.7-Linux-x86_64.tar.gz && \ + tar -xvzf cmake-3.15.7-Linux-x86_64.tar.gz && \ + rm cmake-3.15.7-Linux-x86_64.tar.gz +ENV PATH=$PATH:/cmake-3.15.7-Linux-x86_64/bin + +# Image with cloned conan center repo +FROM snitch-dev-base AS snitch-conan-repo +ARG GIT_BRANCH +RUN git clone https://github.com/cschreib/conan-center-index.git && cd conan-center-index && git checkout ${GIT_BRANCH} + +# ------------------------------------------- +# Conan v1 +# ------------------------------------------- +FROM snitch-dev-base AS snitch-conan-v1-base +RUN pip install conan==1.59 +RUN conan config install https://github.com/conan-io/hooks.git -sf hooks -tf hooks && \ + conan config set hooks.conan-center +COPY --from=snitch-conan-repo /conan-center-index/recipes/snitch /conan-center-index/recipes/snitch + +# Static +FROM snitch-conan-v1-base AS snitch-conan-v1-static +ARG SNITCH_VERSION +RUN cd /conan-center-index/recipes/snitch && \ + conan create all/conanfile.py snitch/${SNITCH_VERSION}@ -pr:b=default -pr:h=default && \ + conan test all/test_v1_package/conanfile.py snitch/${SNITCH_VERSION}@ -pr:b=default -pr:h=default + +# Header-only +FROM snitch-conan-v1-base AS snitch-conan-v1-header-only +ARG SNITCH_VERSION +RUN cd /conan-center-index/recipes/snitch && \ + conan create all/conanfile.py snitch/${SNITCH_VERSION}@ -pr:b=default -pr:h=default -o snitch:header_only=True && \ + conan test all/test_v1_package/conanfile.py snitch/${SNITCH_VERSION}@ -pr:b=default -pr:h=default -o snitch:header_only=True + +# Shared +FROM snitch-conan-v1-base AS snitch-conan-v1-shared +ARG SNITCH_VERSION +RUN cd /conan-center-index/recipes/snitch && \ + conan create all/conanfile.py snitch/${SNITCH_VERSION}@ -pr:b=default -pr:h=default -o snitch:shared=True && \ + conan test all/test_v1_package/conanfile.py snitch/${SNITCH_VERSION}@ -pr:b=default -pr:h=default -o snitch:shared=True + +# ------------------------------------------- +# Conan v2 +# ------------------------------------------- +FROM snitch-dev-base AS snitch-conan-v2-base +RUN pip install conan==2.0 +RUN conan profile detect +COPY --from=snitch-conan-repo /conan-center-index/recipes/snitch /conan-center-index/recipes/snitch + +# Static +FROM snitch-conan-v2-base AS snitch-conan-v2-static +ARG SNITCH_VERSION +RUN cd /conan-center-index/recipes/snitch && \ + conan create all/conanfile.py --version ${SNITCH_VERSION} -s compiler.cppstd=20 + +# Header-only +FROM snitch-conan-v2-base AS snitch-conan-v2-header-only +ARG SNITCH_VERSION +RUN cd /conan-center-index/recipes/snitch && \ + conan create all/conanfile.py --version ${SNITCH_VERSION} -s compiler.cppstd=20 -o snitch/${SNITCH_VERSION}:header_only=True + +# Shared +FROM snitch-conan-v2-base AS snitch-conan-v2-shared +ARG SNITCH_VERSION +RUN cd /conan-center-index/recipes/snitch && \ + conan create all/conanfile.py --version ${SNITCH_VERSION} -s compiler.cppstd=20 -o snitch/${SNITCH_VERSION}:shared=True From bdb8a78c492c6fe89d04feaf0e0136686eacffc6 Mon Sep 17 00:00:00 2001 From: Corentin Schreiber Date: Tue, 5 Sep 2023 17:17:20 +0100 Subject: [PATCH 2/2] Add CMake 3.14 CI --- .github/workflows/cmake.yml | 73 +++++++++++++++++++++++++++++- .github/workflows/meson.yml | 2 +- .gitignore | 1 + tests/install_tests/CMakeLists.txt | 15 ++++++ tests/install_tests/standalone.cpp | 11 +++++ 5 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 tests/install_tests/CMakeLists.txt create mode 100644 tests/install_tests/standalone.cpp diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 5718b07b..8f62cd70 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -1,4 +1,4 @@ -name: CI +name: cmake on: workflow_dispatch: @@ -11,9 +11,80 @@ env: EM_VERSION: 3.1.35 EM_CACHE_FOLDER: 'emsdk-cache' CODECOV_TOKEN: 'f8197851-e753-4291-a835-2d76090f2c92' + CMAKE_INSTALL_VERSION: 3.14.7 jobs: + install: + strategy: + fail-fast: false + matrix: + platform: + - { name: Install Ubuntu GCC static, flags: "", test-flags: ""} + - { name: Install Ubuntu GCC header-only, flags: "-DSNITCH_HEADER_ONLY=1", test-flags: "-DHEADER_ONLY=yes"} + - { name: Install Ubuntu GCC shared, flags: "-DBUILD_SHARED_LIBS=1", test-flags: ""} + build-type: + - Release + + name: ${{matrix.platform.name}} ${{matrix.build-type}} + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + submodules: 'recursive' + + - name: Setup GCC + shell: bash + run: | + sudo apt install g++-11 + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11 + sudo update-alternatives --set gcc /usr/bin/gcc-11 + + - name: Setup CMake + shell: bash + run: | + wget -q https://github.com/Kitware/CMake/releases/download/v${CMAKE_INSTALL_VERSION}/cmake-${CMAKE_INSTALL_VERSION}-Linux-x86_64.tar.gz + tar -xvzf cmake-${CMAKE_INSTALL_VERSION}-Linux-x86_64.tar.gz -C "${{github.workspace}}" + echo "${{github.workspace}}/cmake-${CMAKE_INSTALL_VERSION}-Linux-x86_64/bin" >> ${GITHUB_PATH} + + - name: Create Build Environment + shell: bash + run: | + cmake --version + cmake -E make_directory ${{github.workspace}}/build + + - name: Configure CMake + shell: bash + working-directory: ${{github.workspace}}/build + run: cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install ${{matrix.platform.flags}} + + - name: Build + shell: bash + working-directory: ${{github.workspace}}/build + run: cmake --build . --parallel 2 + + - name: Install + shell: bash + working-directory: ${{github.workspace}}/build + run: make install + + - name: Build test + shell: bash + working-directory: ${{github.workspace}}/tests/install_tests + run: | + cmake -E make_directory build + cd build + cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=${{github.workspace}}/install ${{matrix.platform.test-flags}} + cmake --build . + + - name: Run test + shell: bash + working-directory: ${{github.workspace}}/tests/install_tests + run: ./build/standalone + build: + needs: install strategy: fail-fast: false matrix: diff --git a/.github/workflows/meson.yml b/.github/workflows/meson.yml index c004ae1b..6e8a013d 100644 --- a/.github/workflows/meson.yml +++ b/.github/workflows/meson.yml @@ -1,4 +1,4 @@ -name: CI_meson +name: meson on: workflow_dispatch: diff --git a/.gitignore b/.gitignore index 89ec2616..add3a21d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ doc/html/ snitch.sublime-workspace tests/approval_tests/data/actual tests/approval_tests/data/blanked +install/ diff --git a/tests/install_tests/CMakeLists.txt b/tests/install_tests/CMakeLists.txt new file mode 100644 index 00000000..16b003f0 --- /dev/null +++ b/tests/install_tests/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(snitch REQUIRED CONFIG) + +add_executable(standalone standalone.cpp) + +if (HEADER_ONLY) + target_compile_definitions(standalone PRIVATE HEADER_ONLY) + target_link_libraries(standalone PRIVATE snitch::snitch-header-only) +else() + target_link_libraries(standalone PRIVATE snitch::snitch) +endif() + +target_compile_features(standalone PRIVATE cxx_std_20) diff --git a/tests/install_tests/standalone.cpp b/tests/install_tests/standalone.cpp new file mode 100644 index 00000000..a338f8b0 --- /dev/null +++ b/tests/install_tests/standalone.cpp @@ -0,0 +1,11 @@ +#if defined(HEADER_ONLY) +# define SNITCH_IMPLEMENTATION +# include +#else +# include +# include +#endif + +TEST_CASE("compiles and runs") { + REQUIRE(true == !false); +}