Skip to content

Commit

Permalink
Merge pull request #127 from cschreib/cmake
Browse files Browse the repository at this point in the history
Add CMake 3.14 install CI checks
  • Loading branch information
cschreib authored Sep 5, 2023
2 parents 014787e + bdb8a78 commit 87260ed
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 2 deletions.
73 changes: 72 additions & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: cmake

on:
workflow_dispatch:
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/meson.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI_meson
name: meson

on:
workflow_dispatch:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ doc/html/
snitch.sublime-workspace
tests/approval_tests/data/actual
tests/approval_tests/data/blanked
install/
74 changes: 74 additions & 0 deletions docker/Dockerfile.conan-center
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions tests/install_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
11 changes: 11 additions & 0 deletions tests/install_tests/standalone.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#if defined(HEADER_ONLY)
# define SNITCH_IMPLEMENTATION
# include <snitch/snitch_all.hpp>
#else
# include <snitch/snitch_macros_check.hpp>
# include <snitch/snitch_macros_test_case.hpp>
#endif

TEST_CASE("compiles and runs") {
REQUIRE(true == !false);
}

0 comments on commit 87260ed

Please sign in to comment.