Usage improvements #329
Workflow file for this run
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: C++ CI Workflow | |
on: | |
push: | |
pull_request: | |
workflow_dispatch: | |
env: | |
Catch2_TAG: v3.0.1 | |
jobs: | |
build: | |
name: '[${{ matrix.os }}@${{ matrix.build_type }}]' | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
build_type: [Release, Debug] | |
os: [ubuntu-latest] | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v3 | |
# Print environment variables to simplify development and debugging | |
- name: Environment Variables | |
shell: bash | |
run: env | |
# ============ | |
# DEPENDENCIES | |
# ============ | |
# Remove apt repos that are known to break from time to time | |
# See https://github.com/actions/virtual-environments/issues/323 | |
- name: Remove broken apt repos | |
run: | | |
for apt_file in `grep -lr microsoft /etc/apt/sources.list.d/`; do sudo rm $apt_file; done | |
- name: Dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install libmatio-dev valgrind libeigen3-dev | |
- name: Cache Source-based Dependencies | |
id: cache-source-deps | |
uses: actions/cache@v3 | |
with: | |
path: ${{ github.workspace }}/install/deps | |
# Including ${{ runner.temp }} is a workaround taken from https://github.com/robotology/whole-body-estimators/pull/62 to fix macos configuration failure on https://github.com/ami-iit/bipedal-locomotion-framework/pull/45 | |
key: source-deps-${{ runner.os }}-${{runner.temp}}-build-type-${{ matrix.build_type }}-catch2-${{ env.Catch2_TAG }} | |
- name: Catch2 installation | |
if: steps.cache-source-deps.outputs.cache-hit != 'true' | |
shell: bash | |
run: | | |
# Catch2 | |
git clone -b ${Catch2_TAG} https://github.com/catchorg/Catch2.git | |
cd Catch2 | |
mkdir -p build | |
cd build | |
cmake -DCMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/install/deps \ | |
-DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/install/deps \ | |
-DBUILD_TESTING=OFF .. | |
cmake --build . --config ${{ matrix.build_type }} --target install | |
# =================== | |
# CMAKE-BASED PROJECT | |
# =================== | |
- name: Configure | |
shell: bash | |
run: | | |
mkdir -p build | |
cd build | |
cmake -DCMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/install/deps \ | |
-DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/install \ | |
-DBUILD_TESTING:BOOL=ON \ | |
-DFRAMEWORK_RUN_Valgrind_tests:BOOL=ON .. | |
- name: Build | |
shell: bash | |
run: | | |
cd build | |
cmake --build . --config ${{ matrix.build_type }} --target install | |
- name: Test | |
shell: bash | |
run: | | |
cd build | |
ctest --output-on-failure -C ${{ matrix.build_type }} . | |
- name: Test example | |
shell: bash | |
run: | | |
cd example | |
mkdir build | |
cd build | |
cmake -DCMAKE_PREFIX_PATH="${GITHUB_WORKSPACE}/install/deps;${GITHUB_WORKSPACE}/install" .. | |
cmake --build . --config ${{ matrix.build_type }} | |
./matiocpp_example | |