save #133
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: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest] | |
compiler: [gcc, clang, msvc] | |
blas: [NONE, OpenBLAS, MKL] | |
include: | |
- compiler: gcc | |
cc: gcc-12 | |
cxx: g++-12 | |
- compiler: clang | |
cc: clang-19 | |
cxx: clang++-19 | |
exclude: | |
- os: ubuntu-latest | |
compiler: msvc | |
- os: windows-latest | |
compiler: gcc | |
- os: windows-latest | |
blas: MKL | |
- os: windows-latest | |
blas: OpenBLAS | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install dependencies (Ubuntu) | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y cmake ninja-build | |
if [ "${{ matrix.compiler }}" = "gcc" ]; then | |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test | |
sudo apt-get update | |
sudo apt-get install -y gcc-12 g++-12 | |
elif [ "${{ matrix.compiler }}" = "clang" ]; then | |
wget https://apt.llvm.org/llvm.sh | |
chmod +x llvm.sh | |
sudo ./llvm.sh 19 | |
sudo apt-get install -y clang-tidy-19 clang-format-19 | |
fi | |
if [ "${{ matrix.blas }}" = "OpenBLAS" ]; then | |
sudo apt-get install -y gfortran | |
elif [ "${{ matrix.blas }}" = "MKL" ]; then | |
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | |
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | |
echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list | |
sudo apt-get update | |
sudo apt-get install -y intel-oneapi-mkl-devel libomp-dev | |
fi | |
- name: Install dependencies (Windows) | |
if: runner.os == 'Windows' | |
run: | | |
choco install cmake ninja | |
if ("${{ matrix.compiler }}" -eq "clang") { | |
choco install llvm | |
} | |
- name: Check Clang-Format | |
if: matrix.compiler == 'clang' && runner.os == 'Linux' | |
run: | | |
find include/squint -iname '*.hpp' -o -iname '*.cpp' | xargs clang-format-19 -i | |
git diff --exit-code | |
shell: bash | |
- name: Set up MSVC | |
if: matrix.os == 'windows-latest' && matrix.compiler == 'msvc' | |
uses: microsoft/setup-msbuild@v2 | |
- name: Configure CMake | |
run: | | |
if [ "${{ runner.os }}" = "Windows" ] && [ "${{ matrix.compiler }}" = "msvc" ]; then | |
pwsh -Command "cmake -B build -DSQUINT_BUILD_DOCUMENTATION=OFF -DSQUINT_BLAS_BACKEND=${{ matrix.blas }}" | |
else | |
if [ "${{ runner.os }}" = "Windows" ]; then | |
if [ "${{ matrix.compiler }}" = "clang" ]; then | |
export CC=clang | |
export CXX=clang++ | |
elif [ "${{ matrix.compiler }}" = "gcc" ]; then | |
export CC=gcc | |
export CXX=g++ | |
fi | |
else | |
export CC=${{ matrix.cc }} | |
export CXX=${{ matrix.cxx }} | |
fi | |
if [ "${{ matrix.blas }}" = "MKL" ] && [ "${{ runner.os }}" = "Linux" ]; then | |
source /opt/intel/oneapi/setvars.sh | |
fi | |
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DSQUINT_BUILD_DOCUMENTATION=OFF -DSQUINT_BLAS_BACKEND=${{ matrix.blas }} | |
fi | |
shell: bash | |
- name: Build | |
run: cmake --build build --config Release | |
- name: Test | |
working-directory: build | |
run: | | |
if [ "${{ runner.os }}" = "Windows" ] && [ "${{ matrix.compiler }}" = "msvc" ]; then | |
ctest -C Release --output-on-failure | |
else | |
ctest --output-on-failure | |
fi | |
shell: bash | |
- name: Run Clang-Tidy | |
if: matrix.compiler == 'clang' && runner.os == 'Linux' && matrix.blas == 'NONE' | |
run: | | |
find ./include/squint \ | |
-not -path './include/squint/tensor/cuda/*' \ | |
\( -name '*.cpp' -or -name '*.hpp' \) | \ | |
xargs -P $(nproc) -I {} bash -c 'clang-tidy-19 -p build {}' > clang_tidy_output.txt | |
if [ -s clang_tidy_output.txt ]; then | |
echo "Clang-Tidy found issues:" | |
cat clang_tidy_output.txt | |
exit 1 | |
else | |
echo "Clang-Tidy passed without issues." | |
fi | |
shell: bash |