Skip to content

Add .deb and .tar.gz releases to the release pipeline #161

Add .deb and .tar.gz releases to the release pipeline

Add .deb and .tar.gz releases to the release pipeline #161

name: ctest_pipeline
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
unit_tests:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-22.04
strategy:
matrix:
compiler: [clang, gcc]
dependency_loader: [fetch_content, vcpkg]
build_type: [debug, release]
steps:
- name: install deps
run: |
sudo apt-get update -y
sudo apt-get install -y software-properties-common
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get install -y gcc-11 g++-11 clang-14 libclang-cpp14-dev libclang-14-dev ninja-build
sudo apt-get install -y curl zip unzip tar pkg-config python3.10-venv flex bison
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Restore artifacts, or setup vcpkg (do not install any package)
uses: lukka/run-vcpkg@v10
with:
vcpkgDirectory: '${{ github.workspace }}/vendor/vcpkg'
- name: Run CMake consuming CMakePreset.json and vcpkg.json by mean of vcpkg.
uses: lukka/run-cmake@v10
with:
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
configurePreset: '${{ matrix.compiler }}-${{ matrix.dependency_loader }}-${{ matrix.build_type }}'
buildPreset: '${{ matrix.compiler }}-${{ matrix.dependency_loader }}-${{ matrix.build_type }}'
testPreset: '${{ matrix.compiler }}-${{ matrix.dependency_loader }}-${{ matrix.build_type }}'
formatting:
runs-on: ubuntu-22.04
steps:
- name: install deps
run: |
sudo apt-get update -y
sudo apt-get install -y clang-format-15
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Run clang-format
run: |
./scripts/format.sh --check
fetch_content_integration:
runs-on: ubuntu-22.04
steps:
- name: install deps
run: |
sudo apt-get update -y
sudo apt-get install -y software-properties-common
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get install -y gcc-11 g++-11 clang-14 libclang-cpp14-dev libclang-14-dev ninja-build
sudo apt-get install -y curl zip unzip tar pkg-config python3.10-venv flex bison git
- name: Set SHA to fetch
run: echo "SHA=${{github.event.pull_request.head.sha}}" >> $GITHUB_ENV
if: ${{ github.event_name == 'pull_request'}}
- name: Set SHA to fetch
run: echo "SHA=${{github.sha}}" >> $GITHUB_ENV
if: ${{ github.event_name == 'push'}}
- name: Create CMakeLists.txt
run: |
cat <<EOF > CMakeLists.txt
cmake_minimum_required(VERSION 3.23)
project(tsmp_application)
include(FetchContent)
FetchContent_Declare(
tsmp
GIT_REPOSITORY https://github.com/${{ github.repository }}.git
GIT_TAG ${SHA}
)
FetchContent_Declare(
catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.4.0
)
FetchContent_MakeAvailable(catch2 tsmp)
list(APPEND CMAKE_MODULE_PATH "${catch2_SOURCE_DIR}/extras")
include(CTest NO_POLICY_SCOPE)
include(Catch)
add_executable(main main.cpp)
target_link_libraries(main PRIVATE Catch2::Catch2WithMain tsmp::json)
enable_reflection(main)
catch_discover_tests(main)
EOF
- name: Cat CMakeLists.txt
run: cat CMakeLists.txt
- name: Create Test
run: |
cat <<EOF > main.cpp
#include <catch2/catch_all.hpp>
#include <tsmp/json.hpp>
struct foo_t {
std::string hello = "world";
};
TEST_CASE("FetchContent integration test", "[unit]") {
foo_t hello_world;
REQUIRE(tsmp::to_json(hello_world) == R"({"hello":"world"})");
}
EOF
- name: Configure
run: cmake -B binary_dir -DCMAKE_CXX_COMPILER=g++-11
- name: Build
run: cmake --build binary_dir
- name: Run Test
run: cmake --build binary_dir --target test