Skip to content

Commit

Permalink
[add] ci (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mc-Zen authored Apr 10, 2024
1 parent 8541dac commit 28bc7df
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: tests

on:
push:
branches: [ "main", "ci" ]
pull_request:
branches: [ "main" ]

jobs:

tests:
name: Tests
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false

matrix:
include:
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
- os: ubuntu-latest
c_compiler: gcc-13
cpp_compiler: g++-13
- os: ubuntu-latest
c_compiler: clang-15
cpp_compiler: clang++-15
- os: macos-latest
c_compiler: $(brew --prefix llvm@15)/bin/clang
cpp_compiler: $(brew --prefix llvm@15)/bin/clang++

steps:
- uses: actions/checkout@v3

- name: Set reusable strings
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/tests/build" >> "$GITHUB_OUTPUT"
- name: Cache Catch2
id: cache-catch2
uses: actions/cache@v3
with:
key: catch2-${{ matrix.os }}-${{ matrix.cpp_compiler }}
path: Catch2


- if: ${{ steps.cache-catch2.outputs.cache-hit != 'true' }}
name: Download and build Catch2
continue-on-error: true
run: |
git clone https://github.com/catchorg/Catch2.git
cd Catch2
cmake -B build -S . -DBUILD_TESTING=OFF
cmake --build build/
- name: Install Catch2 (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
cd Catch2
cmake --install build/ --config Debug
- name: Install Catch2 (!Windows)
if: ${{ matrix.os != 'windows-latest' }}
run: |
cd Catch2
sudo cmake --install build/
- name: Configure CMake
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=Debug
-DUNIT_TESTING=ON
-S ${{ github.workspace }}/tests
- name: Build
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config Debug

- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: ctest -C Debug --output-on-failure --verbose
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Matrix for C++

[![tests](https://github.com/Mc-Zen/Matrix/actions/workflows/ci.yml/badge.svg)](https://github.com/Mc-Zen/Matrix/actions/workflows/ci.yml)
[![license](https://img.shields.io/badge/license-MIT-blue)](https://github.com/Mc-Zen/Matrix/blob/main/LICENSE)


A tiny C++20 general-purpose library for dense, fixed-size and dynamically-sized matrices with no dependencies (other than `std`).
It makes use of C++20s concepts to enable special features such as norm for vectors and many more.
Expand Down
3 changes: 3 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.13)
project(Matrix_Tests)

find_package(Catch2 3 REQUIRED)
enable_testing()
include(Catch)


set(CMAKE_CXX_STANDARD 20)
Expand All @@ -11,3 +13,4 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_executable(tests matrix_tests.cpp solvers_tests.cpp)
target_link_libraries(tests PRIVATE Catch2::Catch2WithMain)

catch_discover_tests(tests)

0 comments on commit 28bc7df

Please sign in to comment.