Skip to content

Commit

Permalink
Biuld and test with Clang in CI
Browse files Browse the repository at this point in the history
Add run_tests_clang action in core_tests.yml
Also, work around clang-18 bug
  • Loading branch information
p-senichenkov committed Nov 29, 2024
1 parent cb7709c commit ce4ea48
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
19 changes: 18 additions & 1 deletion .github/composite-actions/download-libraries/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ inputs:
description: 'Install boost'
default: true

install-clang:
type: boolean
description: 'Install clang'
default: false

runs:
using: 'composite'
steps:
Expand All @@ -25,6 +30,18 @@ runs:
sudo apt-get update -y
sudo apt-get install gcc-10 g++-10 cmake build-essential -y
shell: bash
if: inputs.install-clang != 'true'

- name: Install clang
# llvm.sh installs all needed libraries, no need in build-essential
run: |
sudo apt-get update -y
sudo apt-get install cmake make -y
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 17
shell: bash
if: inputs.install-clang != 'false'

- name: Make lib directory
run: |
Expand All @@ -35,7 +52,7 @@ runs:
uses: ./.github/composite-actions/download-library
with:
directory: googletest
download-command: git clone https://github.com/google/googletest/ --branch release-1.12.1 --depth 1
download-command: git clone https://github.com/google/googletest/ --branch release-1.14.0 --depth 1
if: inputs.download-googletest != 'false'

- name: Download easyloggingpp
Expand Down
34 changes: 33 additions & 1 deletion .github/workflows/core-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ on:
#- examples/**
workflow_dispatch:
jobs:
run_tests:
run_tests_gcc:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -44,6 +44,38 @@ jobs:
uses: ./.github/composite-actions/download-datasets
- name: Build
run: |
export CC=gcc-10
export CXX=g++-10
if [[ "${{matrix.cfg.BUILD_TYPE}}" == "Debug" ]]; then
./build.sh --debug --sanitizer=${{ matrix.cfg.SANITIZER }}
else
./build.sh
fi
- name: Test
working-directory: ${{github.workspace}}/build/target
shell: bash
run: ./Desbordante_test --gtest_filter='*:-*HeavyDatasets*'
run_tests_clang:
runs-on: ubuntu-latest
strategy:
matrix:
cfg:
- { BUILD_TYPE: Release }
- { BUILD_TYPE: Debug }
- { BUILD_TYPE: Debug, SANITIZER : ADDRESS }
- { BUILD_TYPE: Debug, SANITIZER : UB }
steps:
- uses: actions/checkout@v3
- name: Download libraries
uses: ./.github/composite-actions/download-libraries
with:
install-clang: true
- name: Download datasets
uses: ./.github/composite-actions/download-datasets
- name: Build
run: |
export CC=clang-17
export CXX=clang++-17
if [[ "${{matrix.cfg.BUILD_TYPE}}" == "Debug" ]]; then
./build.sh --debug --sanitizer=${{ matrix.cfg.SANITIZER }}
else
Expand Down
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ else()
add_compile_options(-ggdb3)
endif()

# Workaround clang-18 bug:
# https://github.com/llvm/llvm-project/issues/76515?ysclid=m406q4it5k674680045
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
string(FIND "${CMAKE_CXX_COMPILER_VERSION}" "18" IDX)
if (IDX EQUAL 0) # clang major version is 18
message(WARNING "C++ compiler is Clang++-18. Supressing deprecated declaration warnings. Consider using another version of Clang")
string(JOIN ";" DEBUG_BUILD_OPTS "${DEBUG_BUILD_OPTS}" "-Wno-deprecated-declarations")
endif()
endif()

add_compile_options("$<$<CONFIG:Debug>:${DEBUG_BUILD_OPTS}>")
add_link_options("$<$<CONFIG:Debug>:${DEBUG_LINK_OPTS}>")

Expand Down

0 comments on commit ce4ea48

Please sign in to comment.