Extend unit tests to check for optimized, native-arch builds. #920
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
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
name: Run unit tests | |
jobs: | |
test: | |
name: ${{ matrix.config.name }} | |
runs-on: ${{ matrix.config.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- { | |
name: "Ubuntu Latest GCC (debug, coverage enabled)", | |
os: ubuntu-latest, | |
cov: true | |
} | |
- { | |
name: "Ubuntu Latest GCC (all optimizations)", | |
os: ubuntu-latest, | |
optimized: true | |
} | |
- { | |
name: "macOS Latest Clang (debug)", | |
os: macos-latest | |
} | |
- { | |
name: "macOS Latest Clang (all optimizations)", | |
os: macos-latest, | |
optimized: true | |
} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get latest CMake | |
uses: lukka/get-cmake@latest | |
- name: Enable code coverage | |
if: ${{ matrix.config.cov }} | |
run: echo "CMAKE_CODE_COVERAGE='-DCODE_COVERAGE=ON'" >> $GITHUB_ENV | |
- name: Enable release build | |
if: ${{ matrix.config.optimized }} | |
run: echo "CMAKE_BUILD_TYPE='-DCMAKE_BUILD_TYPE=Release -DUSE_MARCH_NATIVE=ON'" >> $GITHUB_ENV | |
- name: Configure the build | |
if: ${{ matrix.config.os == 'ubuntu-latest' && matrix.config.cov }} | |
run: cmake -S . -B build ${{ env.CMAKE_BUILD_TYPE }} ${{ env.CMAKE_CODE_COVERAGE }} | |
- name: Run the build | |
run: cmake --build build | |
- name: Run the tests | |
run: | | |
cd build/tests | |
# Avoid using ctest because it's so slow; it starts a | |
# new process for each individual test, which is crazy. | |
for exe in $(ctest --show-only=json-v1 | jq -r ".tests[] | .command | .[0]" | sort | uniq) | |
do | |
echo "#### RUNNING ${exe} ####" | |
echo | |
${exe} --gtest_brief=1 | |
echo | |
done | |
- name: Generate code coverage | |
if: ${{ matrix.config.cov }} | |
run: | | |
cd build/tests/CMakeFiles/ | |
find -type f -name "*.gcno" -execdir gcov -abcfu {} + | |
- name: Upload to Codecov | |
if: ${{ matrix.config.cov }} | |
uses: codecov/codecov-action@v3 | |
with: | |
directory: build/tests/CMakeFiles/ |