Adds cmake build support.
This commit is contained in:
164
.github/workflows/ci.yml
vendored
Normal file
164
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
name: TinyTest CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
build-bazel:
|
||||
name: Build with Bazel
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Bazel
|
||||
uses: bazelbuild/setup-bazelisk@v2
|
||||
|
||||
- name: Build
|
||||
run: bazel build --enable_workspace=true //...
|
||||
|
||||
- name: Test
|
||||
run: bazel test --enable_workspace=true //...
|
||||
|
||||
build-cmake:
|
||||
name: Build with CMake
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
build_type: [Debug, Release]
|
||||
library_type: [Static, Shared]
|
||||
compiler: [default]
|
||||
include:
|
||||
# Define mappings for library types
|
||||
- library_type: Static
|
||||
shared_libs: OFF
|
||||
- library_type: Shared
|
||||
shared_libs: ON
|
||||
|
||||
# Add GCC 10 configuration on Linux
|
||||
- os: ubuntu-latest
|
||||
build_type: Release
|
||||
library_type: Static
|
||||
compiler: gcc-10
|
||||
cc: gcc-10
|
||||
cxx: g++-10
|
||||
|
||||
# Add GCC 11 configuration on Linux
|
||||
- os: ubuntu-latest
|
||||
build_type: Release
|
||||
library_type: Static
|
||||
compiler: gcc-11
|
||||
cc: gcc-11
|
||||
cxx: g++-11
|
||||
|
||||
# Add Clang configuration on Linux
|
||||
- os: ubuntu-latest
|
||||
build_type: Release
|
||||
library_type: Static
|
||||
compiler: clang
|
||||
cc: clang
|
||||
cxx: clang++
|
||||
|
||||
# Add MinGW configuration on Windows
|
||||
- os: windows-latest
|
||||
build_type: Release
|
||||
library_type: Static
|
||||
compiler: mingw
|
||||
use_mingw: true
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
# Set up GCC if specified
|
||||
- name: Set up GCC
|
||||
if: matrix.compiler == 'gcc-10' || matrix.compiler == 'gcc-11'
|
||||
uses: egor-tensin/setup-gcc@v1
|
||||
with:
|
||||
version: ${{ matrix.compiler }}
|
||||
|
||||
# Set up Clang if specified
|
||||
- name: Set up Clang
|
||||
if: matrix.compiler == 'clang'
|
||||
uses: egor-tensin/setup-clang@v1
|
||||
with:
|
||||
version: latest
|
||||
|
||||
# Set up MinGW if specified
|
||||
- name: Set up MinGW
|
||||
if: matrix.use_mingw
|
||||
uses: egor-tensin/setup-mingw@v2
|
||||
with:
|
||||
platform: x64
|
||||
|
||||
# Setup environment variables for specific compilers
|
||||
- name: Set Compiler Environment Variables
|
||||
if: matrix.cc && matrix.cxx
|
||||
shell: bash
|
||||
run: |
|
||||
echo "CC=${{ matrix.cc }}" >> $GITHUB_ENV
|
||||
echo "CXX=${{ matrix.cxx }}" >> $GITHUB_ENV
|
||||
|
||||
# Setup CMake
|
||||
- name: Setup CMake
|
||||
uses: jwlawson/actions-setup-cmake@v1.13
|
||||
with:
|
||||
cmake-version: '3.14.x'
|
||||
|
||||
# Create build directory
|
||||
- name: Create Build Directory
|
||||
run: cmake -E make_directory ${{github.workspace}}/build
|
||||
|
||||
# Configure CMake
|
||||
- name: Configure CMake
|
||||
working-directory: ${{github.workspace}}/build
|
||||
run: >
|
||||
cmake ${{github.workspace}}
|
||||
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
|
||||
-DTINYTEST_BUILD_SHARED_LIBS=${{ matrix.shared_libs }}
|
||||
-DBUILD_TESTING=ON
|
||||
|
||||
# Build
|
||||
- name: Build
|
||||
working-directory: ${{github.workspace}}/build
|
||||
run: cmake --build . --config ${{ matrix.build_type }}
|
||||
|
||||
# Test
|
||||
- name: Test
|
||||
working-directory: ${{github.workspace}}/build
|
||||
run: ctest -C ${{ matrix.build_type }} --output-on-failure
|
||||
|
||||
# Verify installation
|
||||
build-and-install:
|
||||
name: Installation Test
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup CMake
|
||||
uses: jwlawson/actions-setup-cmake@v1.13
|
||||
with:
|
||||
cmake-version: '3.14.x'
|
||||
|
||||
- name: Build and Install
|
||||
run: |
|
||||
mkdir -p build
|
||||
cd build
|
||||
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/tinytest-install
|
||||
cmake --build .
|
||||
cmake --install .
|
||||
|
||||
- name: Verify Installation
|
||||
run: |
|
||||
if [ ! -f "$HOME/tinytest-install/include/tinytest/tinytest.h" ]; then
|
||||
echo "tinytest.h not found in installation directory"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f "$HOME/tinytest-install/lib/libtinytest.a" ]; then
|
||||
echo "Library not found in installation directory"
|
||||
exit 1
|
||||
fi
|
||||
echo "Installation successful"
|
||||
Reference in New Issue
Block a user