reactphysics3d/.github/workflows/build-and-test.yml

287 lines
8.6 KiB
YAML
Raw Normal View History

2021-08-02 20:59:51 +00:00
# Build and run tests for ReactPhysics3D
2021-08-10 06:18:30 +00:00
name: build
2021-08-02 20:59:51 +00:00
# Controls when the action will run. Triggers the workflow on push
on:
push:
2021-08-10 06:17:31 +00:00
branches:
- master
- develop
2021-08-02 20:59:51 +00:00
pull_request:
release:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {
2021-08-03 21:19:04 +00:00
name: "Linux / GCC (Debug, Single Precision)",
os: ubuntu-latest,
build_type: "Debug",
cc: "gcc",
cxx: "g++",
generators: "Ninja",
2021-08-04 13:36:44 +00:00
double_precision: false,
2021-08-10 05:15:49 +00:00
coverage: false,
2021-08-03 21:19:04 +00:00
}
- {
name: "Linux / GCC (Release, Single Precision)",
2021-08-02 20:59:51 +00:00
os: ubuntu-latest,
build_type: "Release",
cc: "gcc",
cxx: "g++",
2021-08-03 13:06:33 +00:00
generators: "Ninja",
2021-08-04 13:36:44 +00:00
double_precision: false,
2021-08-10 05:15:49 +00:00
coverage: false,
2021-08-04 13:36:44 +00:00
}
- {
name: "Linux / GCC (Debug, Double Precision)",
os: ubuntu-latest,
build_type: "Debug",
cc: "gcc",
cxx: "g++",
generators: "Ninja",
double_precision: true,
2021-08-10 05:15:49 +00:00
coverage: false,
2021-08-04 13:36:44 +00:00
}
- {
name: "Linux / GCC (Release, Double Precision)",
os: ubuntu-latest,
build_type: "Release",
cc: "gcc",
cxx: "g++",
generators: "Ninja",
double_precision: true,
2021-08-10 05:15:49 +00:00
coverage: false,
2021-08-02 20:59:51 +00:00
}
2021-08-03 21:30:27 +00:00
- {
name: "Linux / Clang (Debug, Single Precision)",
os: ubuntu-latest,
build_type: "Debug",
cc: "clang",
cxx: "clang++",
generators: "Ninja",
2021-08-04 13:36:44 +00:00
double_precision: false,
2021-08-10 05:15:49 +00:00
coverage: false,
2021-08-04 13:36:44 +00:00
}
2021-08-04 13:49:19 +00:00
- {
2021-08-09 15:15:28 +00:00
name: "Linux / Clang (Release, Single Precision)",
os: ubuntu-latest,
build_type: "Release",
2021-08-04 13:49:19 +00:00
cc: "clang",
cxx: "clang++",
2021-08-08 19:52:55 +00:00
generators: "Ninja",
2021-08-08 19:51:43 +00:00
double_precision: false,
2021-08-10 05:15:49 +00:00
coverage: false,
2021-08-04 13:49:19 +00:00
}
2021-08-04 13:58:26 +00:00
- {
2021-08-09 15:15:28 +00:00
name: "Linux / Clang (Debug, Double Precision)",
os: ubuntu-latest,
2021-08-04 13:58:26 +00:00
build_type: "Debug",
2021-08-09 15:15:28 +00:00
cc: "clang",
cxx: "clang++",
generators: "Ninja",
double_precision: true,
2021-08-10 05:15:49 +00:00
coverage: false,
2021-08-08 19:51:43 +00:00
}
- {
2021-08-09 15:15:28 +00:00
name: "Linux / Clang (Release, Double Precision)",
os: ubuntu-latest,
2021-08-08 19:51:43 +00:00
build_type: "Release",
2021-08-09 15:15:28 +00:00
cc: "clang",
cxx: "clang++",
generators: "Ninja",
double_precision: true,
2021-08-10 05:15:49 +00:00
coverage: false,
2021-08-08 19:51:43 +00:00
}
- {
2021-08-09 15:15:28 +00:00
name: "Windows / MSVC (Debug, Single Precision)",
2021-08-08 19:51:43 +00:00
os: windows-latest,
build_type: "Debug",
cc: "cl",
cxx: "cl",
2021-08-08 19:52:55 +00:00
generators: "Visual Studio 16 2019",
2021-08-09 15:15:28 +00:00
double_precision: false,
2021-08-10 05:15:49 +00:00
coverage: false,
2021-08-08 19:51:43 +00:00
}
- {
2021-08-09 15:15:28 +00:00
name: "Windows / MSVC (Release, Single Precision)",
2021-08-08 19:51:43 +00:00
os: windows-latest,
build_type: "Release",
cc: "cl",
cxx: "cl",
2021-08-08 19:52:55 +00:00
generators: "Visual Studio 16 2019",
2021-08-09 15:15:28 +00:00
double_precision: false,
2021-08-10 05:15:49 +00:00
coverage: false,
2021-08-04 13:58:26 +00:00
}
- {
name: "Windows / MinGW (Debug, Single Precision)",
os: windows-latest,
build_type: "Debug",
cc: "gcc",
cxx: "g++",
2021-08-08 19:52:55 +00:00
generators: "Ninja",
2021-08-08 19:51:43 +00:00
double_precision: false,
2021-08-10 05:15:49 +00:00
coverage: false,
2021-08-08 19:51:43 +00:00
}
- {
name: "Windows / MinGW (Release, Single Precision)",
os: windows-latest,
build_type: "Release",
cc: "gcc",
cxx: "g++",
2021-08-08 19:52:55 +00:00
generators: "Ninja",
2021-08-08 19:51:43 +00:00
double_precision: false,
2021-08-10 05:15:49 +00:00
coverage: false,
2021-08-08 19:51:43 +00:00
}
- {
2021-08-09 15:15:28 +00:00
name: "MacOS / Clang (Debug, Single Precision)",
os: macos-latest,
2021-08-08 19:51:43 +00:00
build_type: "Debug",
2021-08-09 15:15:28 +00:00
cc: "clang",
cxx: "clang++",
2021-08-08 19:52:55 +00:00
generators: "Ninja",
2021-08-09 15:15:28 +00:00
double_precision: false,
2021-08-10 05:15:49 +00:00
coverage: false,
2021-08-08 19:51:43 +00:00
}
- {
2021-08-09 15:15:28 +00:00
name: "MacOS / Clang (Release, Single Precision)",
os: macos-latest,
2021-08-08 19:51:43 +00:00
build_type: "Release",
2021-08-09 15:15:28 +00:00
cc: "clang",
cxx: "clang++",
2021-08-08 19:52:55 +00:00
generators: "Ninja",
2021-08-09 15:15:28 +00:00
double_precision: false,
2021-08-10 05:15:49 +00:00
coverage: false,
}
2021-08-04 13:36:44 +00:00
- {
name: "Code Coverage",
os: ubuntu-latest,
build_type: "Debug",
cc: "gcc",
cxx: "g++",
generators: "Ninja",
double_precision: false,
2021-08-10 05:15:49 +00:00
coverage: true,
2021-08-03 21:30:27 +00:00
}
2021-08-02 20:59:51 +00:00
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Print env
run: |
echo github.event.action: ${{ github.event.action }}
echo github.event_name: ${{ github.event_name }}
2021-08-03 13:06:33 +00:00
2021-08-03 21:19:04 +00:00
- name: Install dependencies on Windows
2021-08-02 20:59:51 +00:00
if: startsWith(matrix.config.os, 'windows')
run: |
choco install ninja cmake
ninja --version
cmake --version
2021-08-03 21:19:04 +00:00
- name: Install dependencies on Linux
2021-08-04 13:49:19 +00:00
if: startsWith(matrix.config.os, 'ubuntu')
2021-08-02 20:59:51 +00:00
run: |
sudo apt-get update
2021-08-10 05:15:49 +00:00
sudo apt-get install ninja-build cmake lcov valgrind
2021-08-02 20:59:51 +00:00
ninja --version
cmake --version
gcc --version
2021-08-03 21:30:27 +00:00
clang --version
2021-08-03 13:06:33 +00:00
- name: Install dependencies on MacOS
2021-08-02 20:59:51 +00:00
if: startsWith(matrix.config.os, 'macos')
run: |
2021-08-10 05:15:49 +00:00
brew install cmake ninja
2021-08-02 20:59:51 +00:00
ninja --version
cmake --version
2021-08-03 13:06:33 +00:00
- name: CMake Configure
2021-08-02 20:59:51 +00:00
shell: bash
2021-08-04 09:24:47 +00:00
env:
CC: ${{ matrix.config.cc }}
CXX: ${{ matrix.config.cxx }}
2021-08-02 20:59:51 +00:00
run: |
mkdir build
cmake \
-S . \
2021-08-03 21:02:51 +00:00
-B build \
2021-08-02 20:59:51 +00:00
-DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} \
2021-08-03 13:06:33 +00:00
-DRP3D_DOUBLE_PRECISION_ENABLED=${{ matrix.config.double_precision }} \
2021-08-04 13:40:07 +00:00
-DRP3D_CODE_COVERAGE_ENABLED=${{ matrix.config.coverage }} \
2021-08-05 21:46:49 +00:00
-DCODE_COVERAGE_VERBOSE=True \
2021-08-03 13:06:33 +00:00
-DRP3D_COMPILE_TESTS=True \
2021-08-02 20:59:51 +00:00
-G "${{ matrix.config.generators }}" \
2021-08-03 13:06:33 +00:00
2021-08-02 20:59:51 +00:00
- name: Build
shell: bash
2021-08-03 21:02:51 +00:00
run: cmake --build build/ --config ${{ matrix.config.build_type }}
2021-08-03 13:06:33 +00:00
2021-08-04 14:14:19 +00:00
- name: Install Library on Linux/MacOS
2021-08-04 18:51:38 +00:00
if: ${{ !startsWith(matrix.config.os, 'windows') }}
2021-08-04 09:52:37 +00:00
shell: bash
2021-08-04 09:57:30 +00:00
run: sudo cmake --install build/
2021-08-04 09:52:37 +00:00
2021-08-04 14:14:19 +00:00
- name: Install Library on Windows
2021-10-12 06:17:51 +00:00
if: startsWith(matrix.config.os, 'windows')
2021-08-04 14:14:19 +00:00
shell: bash
run: cmake --install build/
2021-08-10 05:15:49 +00:00
- name: Unit Tests (Linux / MacOS / Windows MinGW)
2021-08-09 19:22:39 +00:00
if: ${{ !startsWith(matrix.config.os, 'windows') }}
2021-08-03 21:08:10 +00:00
shell: bash
run: ./build/test/tests
2021-08-04 09:52:37 +00:00
2021-08-10 05:15:49 +00:00
- name: Unit Tests (Wndows MSVC)
if: ${{ startsWith(matrix.config.name, 'Windows / MSVC') }}
2021-08-09 19:22:39 +00:00
shell: bash
run: "./build/test/${{ matrix.config.build_type }}/tests.exe"
2021-08-04 09:52:37 +00:00
- name: Build and Run Hello World
2021-08-04 18:56:05 +00:00
if: ${{ !matrix.config.coverage }}
2021-08-04 09:52:37 +00:00
shell: bash
2021-08-04 13:17:06 +00:00
env:
CC: ${{ matrix.config.cc }}
CXX: ${{ matrix.config.cxx }}
2021-08-04 09:52:37 +00:00
run: |
mkdir build_hello_world
cmake \
-S helloworld \
-B build_hello_world \
-DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} \
2021-08-04 13:11:42 +00:00
-DCMAKE_EXE_LINKER_FLAGS=-no-pie \
2021-08-04 12:39:10 +00:00
-G "${{ matrix.config.generators }}"
2021-08-04 09:52:37 +00:00
cmake --build build_hello_world/ --config ${{ matrix.config.build_type }}
2021-08-04 12:42:47 +00:00
./build_hello_world/helloworld
2021-08-03 21:08:10 +00:00
2021-08-10 05:15:49 +00:00
- name: Memory Leaks Test
2021-08-10 05:24:36 +00:00
if: ${{ startsWith(matrix.config.name, 'Linux / GCC (Debug, Single Precision)') }}
2021-08-10 05:15:49 +00:00
shell: bash
run: valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --error-exitcode=1 ./build/test/tests
2021-08-04 21:16:53 +00:00
- name: Compute Code Coverage
if: ${{ matrix.config.coverage }}
2021-08-09 15:15:28 +00:00
env:
CC: ${{ matrix.config.cc }}
CXX: ${{ matrix.config.cxx }}
2021-08-04 19:23:06 +00:00
shell: bash
2021-08-04 21:16:53 +00:00
run: |
2021-08-05 13:25:26 +00:00
cmake --build build/ --target coverage
2021-08-04 19:23:06 +00:00
2021-08-04 13:36:44 +00:00
- name: Upload coverage to Codecov
2021-08-04 14:14:19 +00:00
if: ${{ matrix.config.coverage }}
2021-08-04 13:36:44 +00:00
uses: codecov/codecov-action@v2
with:
2021-08-04 19:23:06 +00:00
fail_ci_if_error: true
2021-08-08 18:32:16 +00:00
verbose: false
2021-08-04 13:36:44 +00:00