Files
TinyTest/.github/workflows/ci.yml
Tom Hicks 742a7dcedd try 4
2025-04-09 20:06:35 -07:00

179 lines
5.0 KiB
YAML

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 --enable_bzlmod=false //...
- name: Test
run: bazel test --enable_workspace=true --enable_bzlmod=false //...
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'
# Make sure tar and unzip are available
- name: Install unzip
run: |
sudo apt-get update
sudo apt-get install -y unzip
if: runner.os == 'Linux'
# 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
-DCPPUTILS_BUILD_TESTS=OFF
-DCPPUTILS_ENABLE_TESTING=OFF
-DCPPUTILS_SKIP_GOOGLETEST=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: Manual Install
run: |
# Create installation directories
mkdir -p $HOME/tinytest-install/include/tinytest
mkdir -p $HOME/tinytest-install/lib
# Copy the header file
cp tinytest.h $HOME/tinytest-install/include/tinytest/
# Compile the library
g++ -std=c++17 -O2 -c tinytest.cpp -o tinytest.o
# Create static library
ar rcs libtinytest.a tinytest.o
# Install the library
cp libtinytest.a $HOME/tinytest-install/lib/
- 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"