Update README.md #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build-and-test | |
on: [push] | |
env: | |
CMAKE_VERSION: 3.29.2 | |
NINJA_VERSION: 1.9.0 | |
jobs: | |
build: | |
name: ${{ matrix.os }}.${{ matrix.compiler }}.${{ matrix.build_type }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
build_type: [ 'Debug', 'Release' ] | |
os: [ 'ubuntu-22.04' ] | |
compiler: [ 'gcc-12', 'gcc-13', 'clang-16', 'clang-17' ] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: download ninja and cmake | |
id: cmake_and_ninja | |
shell: cmake -P {0} | |
run: | | |
set(cmake_version $ENV{CMAKE_VERSION}) | |
set(ninja_version $ENV{NINJA_VERSION}) | |
message(STATUS "Using host CMake version: ${CMAKE_VERSION}") | |
set(ninja_suffix "linux.zip") | |
set(cmake_suffix "linux-x86_64.tar.gz") | |
set(cmake_dir "cmake-${cmake_version}-linux-x86_64/bin") | |
set(ninja_url "https://github.com/ninja-build/ninja/releases/download/v${ninja_version}/ninja-${ninja_suffix}") | |
file(DOWNLOAD "${ninja_url}" ./ninja.zip SHOW_PROGRESS) | |
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./ninja.zip) | |
set(cmake_url "https://github.com/Kitware/CMake/releases/download/v${cmake_version}/cmake-${cmake_version}-${cmake_suffix}") | |
file(DOWNLOAD "${cmake_url}" ./cmake.zip SHOW_PROGRESS) | |
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./cmake.zip) | |
# Save the path for other steps | |
file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/${cmake_dir}" cmake_dir) | |
file(APPEND $ENV{GITHUB_OUTPUT} "cmake_dir=${cmake_dir}") | |
execute_process( | |
COMMAND chmod +x ninja | |
COMMAND chmod +x ${cmake_dir}/cmake | |
) | |
- name: install gcc-12 | |
id: install_gcc_12 | |
if: matrix.compiler == 'gcc-12' | |
shell: bash | |
working-directory: ${{ env.HOME }} | |
run: | | |
sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa -y | |
sudo apt update | |
sudo apt install -y g++-12 gcc-12 | |
echo "CC=gcc-12" >> $GITHUB_ENV | |
echo "CXX=g++-12" >> $GITHUB_ENV | |
- name: install gcc-13 | |
id: install_gcc_13 | |
if: matrix.compiler == 'gcc-13' | |
shell: bash | |
working-directory: ${{ env.HOME }} | |
run: | | |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y | |
sudo apt update | |
sudo apt install -y g++-13 gcc-13 | |
echo "CC=gcc-13" >> $GITHUB_ENV | |
echo "CXX=g++-13" >> $GITHUB_ENV | |
- name: install clang-16 | |
id: install_clang_16 | |
if: matrix.compiler == 'clang-16' | |
shell: bash | |
working-directory: ${{ env.HOME }} | |
run: | | |
curl -O -L https://apt.llvm.org/llvm.sh | |
chmod +x llvm.sh | |
sudo ./llvm.sh 16 | |
echo "CC=clang-16" >> $GITHUB_ENV | |
echo "CXX=clang++-16" >> $GITHUB_ENV | |
- name: install clang-17 | |
id: install_clang_17 | |
if: matrix.compiler == 'clang-17' | |
shell: bash | |
working-directory: ${{ env.HOME }} | |
run: | | |
curl -O -L https://apt.llvm.org/llvm.sh | |
chmod +x llvm.sh | |
sudo ./llvm.sh 17 | |
echo "CC=clang-17" >> $GITHUB_ENV | |
echo "CXX=clang++-17" >> $GITHUB_ENV | |
- name: configure | |
shell: cmake -P {0} | |
run: | | |
message(STATUS "CXX=$ENV{CXX}") | |
message(STATUS "CC=$ENV{CC}") | |
set(ENV{PATH} "$ENV{GITHUB_WORKSPACE}:$ENV{PATH}") | |
execute_process( | |
COMMAND ${{ steps.cmake_and_ninja.outputs.cmake_dir }}/cmake | |
-S . | |
-B build | |
-G Ninja | |
-DCMAKE_MAKE_PROGRAM=ninja | |
-DCMAKE_C_COMPILER=${{ env.CC }} | |
-DCMAKE_CXX_COMPILER=${{ env.CXX }} | |
-DCMAKE_VERBOSE_MAKEFILE=ON | |
-DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} | |
RESULT_VARIABLE result | |
) | |
if (NOT result EQUAL 0) | |
message(FATAL_ERROR "Bad exit status") | |
endif() | |
- name: build | |
shell: cmake -P {0} | |
continue-on-error: false | |
run: | | |
set(ENV{NINJA_STATUS} "[%f/%t %o/sec] ") | |
set(ENV{PATH} "$ENV{GITHUB_WORKSPACE}:$ENV{PATH}") | |
execute_process( | |
COMMAND ${{ steps.cmake_and_ninja.outputs.cmake_dir }}/cmake --build build | |
RESULT_VARIABLE result | |
) | |
if (NOT result EQUAL 0) | |
message(FATAL_ERROR "Bad exit status") | |
endif() | |
- name: run tests | |
shell: cmake -P {0} | |
continue-on-error: false | |
run: | | |
include(ProcessorCount) | |
ProcessorCount(N) | |
set(ENV{CTEST_OUTPUT_ON_FAILURE} "ON") | |
execute_process( | |
COMMAND ${{ steps.cmake_and_ninja.outputs.cmake_dir }}/ctest --verbose -j ${N} | |
WORKING_DIRECTORY build | |
RESULT_VARIABLE result | |
) | |
if (NOT result EQUAL 0) | |
message(FATAL_ERROR "Running tests failed!") | |
endif() |