diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..4da6cb33 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,79 @@ +name: CI + +on: + push: + branches: [develop, main] + pull_request: + branches: [develop, main] + +jobs: + build: + name: >- + ${{ matrix.os }} + ${{ matrix.compiler }} + ${{ matrix.build_type }} + ${{ matrix.sanitizer == 'ON' && 'asan+ubsan' || 'no-sanitizers' }} + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + compiler: [gcc, clang] + build_type: [Debug, Release] + sanitizer: [ON, OFF] + include: + - os: windows-latest + shell: msys2 {0} + + steps: + - uses: actions/checkout@v4 + + - name: Set up MSYS2 + if: runner.os == 'Windows' + uses: msys2/setup-msys2@v2 + with: + msystem: UCRT64 + update: false + install: >- + mingw-w64-ucrt-x86_64-gcc + mingw-w64-ucrt-x86_64-clang + mingw-w64-ucrt-x86_64-cmake + mingw-w64-ucrt-x86_64-ninja + + - name: Install GCC (macOS) + if: runner.os == 'macOS' && matrix.compiler == 'gcc' + run: brew install gcc + + - name: Set up compiler + shell: ${{ matrix.shell || 'bash' }} + run: | + if [[ "${{ matrix.compiler }}" == "gcc" ]]; then + if [[ "${{ runner.os }}" == "macOS" ]]; then + GCC_VER=$(brew list --versions gcc | awk '{print $2}' | cut -d. -f1) + echo "CC=gcc-${GCC_VER}" >> "$GITHUB_ENV" + echo "CXX=g++-${GCC_VER}" >> "$GITHUB_ENV" + else + echo "CC=gcc" >> "$GITHUB_ENV" + echo "CXX=g++" >> "$GITHUB_ENV" + fi + else + echo "CC=clang" >> "$GITHUB_ENV" + echo "CXX=clang++" >> "$GITHUB_ENV" + fi + + - name: Configure + shell: ${{ matrix.shell || 'bash' }} + run: >- + cmake -B build -G Ninja + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -DENABLE_ADDRESS_SANITIZER=${{ matrix.sanitizer }} + -DENABLE_UNDEFINED_SANITIZER=${{ matrix.sanitizer }} + + - name: Build + shell: ${{ matrix.shell || 'bash' }} + run: cmake --build build -j + + - name: Test + shell: ${{ matrix.shell || 'bash' }} + run: ctest --test-dir build --output-on-failure