Skip to content

feat: switch the default mode to safe_mode (#44) #115

feat: switch the default mode to safe_mode (#44)

feat: switch the default mode to safe_mode (#44) #115

Workflow file for this run

name: BuildAndTest
on:
push:
paths-ignore:
- 'README.md'
- '.gitignore'
- 'Doxyfile'
- 'asset/**'
- 'LICENSE'
- '.github/workflows/doc.yml'
pull_request:
paths-ignore:
- 'README.md'
- '.gitignore'
- 'Doxyfile'
- 'asset/**'
- 'LICENSE'
- '.github/workflows/doc.yml'
jobs:
build:
strategy:
matrix:
include:
- os: ubuntu-20.04
type: Debug
cxx: gcc
- os: ubuntu-20.04
type: Release
cxx: gcc
coverage: -DCMAKE_CXX_FLAGS=--coverage
- os: ubuntu-20.04
type: Debug
cxx: clang
- os: ubuntu-20.04
type: Release
cxx: clang
- os: windows-2019
type: Debug
- os: windows-2019
type: Release
- os: macos-13
type: Debug
- os: macos-13
type: Release
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: install build tools (gcc)
run: |
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt install g++-11 -y
echo "CC=gcc-11" >> $GITHUB_ENV
echo "CXX=g++-11" >> $GITHUB_ENV
sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-11 90
if: ${{ startsWith(matrix.os, 'ubuntu') && matrix.cxx == 'gcc' }}
- name: install build tools (clang)
run: |
sudo apt install clang-12 -y
sudo rm -rf /usr/lib/gcc/x86_64-linux-gnu/11 /usr/include/c++/11
echo "CC=clang-12" >> $GITHUB_ENV
echo "CXX=clang++-12" >> $GITHUB_ENV
if: ${{ startsWith(matrix.os, 'ubuntu') && matrix.cxx == 'clang' }}
- name: enable compatibility test (linux)
run: echo "COMPATIBILITY=-DENABLE_COMPATIBILITY_TEST=ON" >> $GITHUB_ENV
if: ${{ startsWith(matrix.os, 'ubuntu') }}
- name: install protobuf for compatibility test
run: sudo apt install protobuf-compiler libprotobuf-dev -y
if: ${{ startsWith(matrix.os, 'ubuntu') }}
- name: install benchmark deps
run: |
sudo apt install libbenchmark-dev -y
echo "BENCHMARK=-DENABLE_BENCHMARK=ON" >> $GITHUB_ENV
if: ${{ startsWith(matrix.os, 'ubuntu') && matrix.type == 'Release' }}
- name: install build tools (mac)
run: |
echo "CC=`which gcc-11`" >> $GITHUB_ENV
echo "CXX=`which g++-11`" >> $GITHUB_ENV
if: ${{ startsWith(matrix.os, 'macos') }}
- name: install protobuf for compatibility test (mac)
run: brew install protobuf
if: ${{ startsWith(matrix.os, 'macos') }}
- name: install benchmark deps (mac)
run: |
brew install google-benchmark
if: ${{ startsWith(matrix.os, 'macos') && matrix.type == 'Release' }}
# - name: install protobuf for compatibility test (windows)
# run: |
# vcpkg install protobuf:x64-windows
# echo "COMPATIBILITY=-DENABLE_COMPATIBILITY_TEST=ON" >> $Env:GITHUB_ENV
# if: ${{ startsWith(matrix.os, 'windows') }}
# - name: install benchmark deps (windows)
# run: |
# vcpkg install benchmark:x64-windows
# echo "BENCHMARK=-DENABLE_BENCHMARK=ON" >> $Env:GITHUB_ENV
# if: ${{ startsWith(matrix.os, 'windows') && matrix.type == 'Release' }}
- name: install coverage tools
run: sudo apt install lcov -y
if: ${{ matrix.coverage }}
- name: generate build script
run: cmake $BENCHMARK $COMPATIBILITY -DCMAKE_BUILD_TYPE=${{ matrix.type }} ${{ matrix.coverage }} .
if: ${{ !startsWith(matrix.os, 'windows') }}
- name: generate build script
run: cmake $Env:BENCHMARK $Env:COMPATIBILITY -DCMAKE_TOOLCHAIN_FILE="$Env:VCPKG_INSTALLATION_ROOT\scripts\buildsystems\vcpkg.cmake" -DCMAKE_BUILD_TYPE=${{ matrix.type }} ${{ matrix.coverage }} .
if: ${{ startsWith(matrix.os, 'windows') }}
- name: build project
run: cmake --build . --config ${{ matrix.type }}
- name: run unit testing
run: ctest
- name: run benchmark
run: ./test/benchmark/protopuf_benchmark
if: ${{ startsWith(matrix.os, 'ubuntu') && matrix.type == 'Release' }}
# - name: run benchmark (windows)
# run: .\test\benchmark\Release\protopuf_benchmark
# if: ${{ startsWith(matrix.os, 'windows') && matrix.type == 'Release' }}
- name: capture coverage
run: lcov --directory . --capture --output-file coverage.info
if: ${{ matrix.coverage }}
- name: upload coverage
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.info
if: ${{ matrix.coverage }}