Re-enable address sanitizer on gcc CI tests #469
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: [dev] | |
env: | |
build_dir: build | |
build_config: Debug | |
cflags_gnuc: -Werror -fsanitize=address | |
lflags_gnuc: -fsanitize=address | |
cflags_clang: -Werror -fsanitize=address | |
lflags_clang: -fsanitize=address | |
cflags_msvc: /WX | |
lflags_msvc: '' | |
test_target: ulib-test | |
cpp_test_target: ulib-cpp-test | |
bench_target: ulib-bench | |
docs_target: ulib-docs | |
jobs: | |
build: | |
name: Build and test | |
runs-on: ${{matrix.os}} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
lib_type: [STATIC, SHARED] | |
types: [normal, tiny, huge] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Configure runner | |
run: | | |
if [ $RUNNER_OS == 'Windows' ]; then | |
echo 'cflags="${{env.cflags_msvc}}"' >> $GITHUB_ENV | |
echo 'lflags="${{env.lflags_msvc}}"' >> $GITHUB_ENV | |
elif [ $RUNNER_OS == 'Linux' ]; then | |
echo 'cflags="${{env.cflags_gnuc}}"' >> $GITHUB_ENV | |
echo 'lflags="${{env.lflags_gnuc}}"' >> $GITHUB_ENV | |
elif [ $RUNNER_OS == 'macOS' ]; then | |
echo 'cflags="${{env.cflags_clang}}"' >> $GITHUB_ENV | |
echo 'lflags="${{env.lflags_clang}}"' >> $GITHUB_ENV | |
fi | |
shell: bash | |
- name: Configure CMake | |
run: > | |
cmake -B ${{env.build_dir}} | |
-DULIB_LIBRARY_TYPE=${{matrix.lib_type}} | |
-DULIB_TINY=${{matrix.types == 'tiny' && 'ON' || 'OFF'}} | |
-DULIB_HUGE=${{matrix.types == 'huge' && 'ON' || 'OFF'}} | |
-DULIB_LEAKS=ON | |
-DCMAKE_SYSTEM_VERSION='' | |
-DCMAKE_BUILD_TYPE=${{env.build_config}} | |
-DCMAKE_C_FLAGS=${{env.cflags}} | |
-DCMAKE_CXX_FLAGS=${{env.cflags}} | |
-DCMAKE_SHARED_LINKER_FLAGS=${{env.lflags}} | |
-DCMAKE_EXE_LINKER_FLAGS=${{env.lflags}} | |
- name: Build | |
run: > | |
cmake --build ${{env.build_dir}} | |
--config ${{env.build_config}} | |
--target ${{env.test_target}} ${{env.cpp_test_target}} ${{env.bench_target}} | |
- name: Configure tests | |
working-directory: ${{env.build_dir}}/test | |
if: matrix.os == 'windows-latest' | |
run: | | |
mv ${{env.build_config}}/*.exe ./ | |
if [ ${{matrix.lib_type}} == 'SHARED' ]; then | |
mv ../${{env.build_config}}/*.dll ./ | |
fi | |
shell: bash | |
- name: Test | |
working-directory: ${{env.build_dir}}/test | |
run: ./${{env.test_target}} | |
- name: Test (C++) | |
working-directory: ${{env.build_dir}}/test | |
run: ./${{env.cpp_test_target}} | |
- name: Benchmark | |
working-directory: ${{env.build_dir}}/test | |
run: ./${{env.bench_target}} | |
docs: | |
name: Generate the documentation | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Configure runner | |
run: | | |
sudo apt install doxygen | |
pip3 install -U Sphinx sphinx-rtd-theme breathe | |
- name: Build docs | |
run: | | |
cmake -B ${{env.build_dir}} | |
cmake --build ${{env.build_dir}} --target ${{env.docs_target}} |