Skip to content

Add github action for cpp build and test #76

Add github action for cpp build and test

Add github action for cpp build and test #76

Workflow file for this run

name: libintx CI
on:
pull_request:
push:
branches: [main]
defaults:
run:
shell: bash
jobs:
configure-build:
strategy:
fail-fast: false
matrix:
os :
- ubuntu-latest
- ubuntu-24.04-arm
compiler :
- clang
- gcc
build_type :
# - Debug
- Release
simd:
- ON
- OFF
name: "${{ matrix.os }}: ${{ matrix.compiler }} ${{ matrix.build_type }} ${{matrix.simd == 'ON' && '(simd)' || ''}}"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup Cache
uses: actions/cache@v4
with:
path: |
~/.ccache
key: ${{ runner.os }}-${{ runner.arch }}-${{ matrix.compiler }}-${{ matrix.build_type }}-${{ matrix.simd }}-${{ hashFiles('**/CMakeLists.txt') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-${{ matrix.compiler }}-${{ matrix.build_type }}-${{ matrix.simd }}
- name: Set compiler
run: |
if [[ "${{ matrix.compiler }}" == "gcc" ]]; then
echo "CC=gcc" >> $GITHUB_ENV
echo "CXX=g++" >> $GITHUB_ENV
elif [[ "${{ matrix.compiler }}" == "clang" ]]; then
echo "CC=clang" >> $GITHUB_ENV
echo "CXX=clang++" >> $GITHUB_ENV
else
echo "Unsupported compiler: ${{ matrix.compiler }}"
exit 1
fi
- name: Verify compiler
run: |
set -x;
$CC --version
$CXX --version
- name: Install Build Dependencies
run: |
set -x;
sudo apt-get update && sudo apt-get install -y \
ccache \
libopenblas-dev \
liblapacke-dev
- name: Set up ccache environment
run: |
echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV
echo "CCACHE_MAXSIZE=1G" >> $GITHUB_ENV
- name: ccache stats
run: |
ccache --zero-stats && ccache --show-stats
- name: Configure
run: |
set -x;
cmake -S . -B ./build -G "Ninja Multi-Config" \
-DLIBINTX_MAX_L=2 \
-DLIBINTX_SIMD=${{matrix.simd}} \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_BUILD_TYPE:STRING=${{matrix.build_type}}
- name: Build
working-directory: ${{github.workspace}}/build
run: |
cmake --build . --target all all.tests --config ${{matrix.build_type}}
- name: Show ccache stats (after build)
run: ccache -s
- name: Test
working-directory: ${{github.workspace}}/build
run: |
ctest --output-on-failure -C ${{matrix.build_type}}