summaryrefslogtreecommitdiff
path: root/.github/workflows/build_and_test.yml
blob: 50aad2883afc6ed6571193ffaa503d20ac2a8fcc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Build and test

on:
  push:
    branches: [ dev, stable ]
  pull_request:
    branches: [ dev, stable ]
  schedule:
    - cron: '0 0 */16 * *'
  workflow_dispatch:

env:
  BUILD_TYPE: Debug

jobs:
  build:
    strategy:
      matrix:
        os: [ ubuntu-latest, macos-latest, windows-2019 ]

    runs-on: ${{ matrix.os }}

    steps:
      - uses: actions/checkout@v2

      - name: Set up CMake 3.18
        uses: jwlawson/actions-setup-cmake@v1.8
        with:
          cmake-version: 3.18

      - name: Install gcovr
        if: runner.os != 'Windows'
        run: |
          python3 -m pip install gcovr==5.0

      - name: Install OpenCppCoverage
        if: runner.os == 'Windows'
        shell: bash
        run: |
          choco install opencppcoverage
          echo "C:/Program Files/OpenCppCoverage" >> $GITHUB_PATH

      - name: Build
        if: runner.os != 'Windows'
        run: |
          cmake -D CMAKE_BUILD_TYPE=$BUILD_TYPE -B build -S .
          cmake --build build --config $BUILD_TYPE

      - name: Build with Visual Studio
        if: runner.os == 'Windows'
        shell: bash
        run: |
          cmake -B build -S .
          cmake --build build --config $BUILD_TYPE

      - name: Run tests & generate coverage on Linux
        if: runner.os == 'Linux'
        working-directory: ${{ github.workspace }}/build
        run: |
          ctest -V -C $BUILD_TYPE
          gcovr --gcov-executable gcov-11 -j $(nproc) --delete --root ../source/ --exclude '\.\./source/test/' --print-summary --xml-pretty --xml coverage.xml .

      - name: Run tests & generate coverage on macOS
        if: runner.os == 'macOS'
        working-directory: ${{ github.workspace }}/build
        run: |
          ctest -V -C $BUILD_TYPE
          gcovr --gcov-executable gcov-11 -j 2 --delete --root ../source/ --exclude '\.\./source/test/' --print-summary --xml-pretty --xml coverage.xml .

      - name: Run tests & generate coverage on Windows
        if: runner.os == 'Windows'
        shell: bash
        working-directory: ${{ github.workspace }}/build
        run: |
          OpenCppCoverage.exe --sources source\\* --excluded_sources source\\test\\* --export_type cobertura:coverage.xml --cover_children -- ctest -V -C $BUILD_TYPE

      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@v2
        with:
          files: ./build/coverage.xml
          flags: ${{ runner.os }}
          name: ${{ runner.os }} build
          fail_ci_if_error: false

  integration:
    strategy:
      matrix:
        os: [ ubuntu-latest, macos-latest, windows-2019 ]
        name: [ fetch_content, find_package ]

    runs-on: ${{ matrix.os }}

    steps:
      - uses: actions/checkout@v2

      - name: Set up CMake 3.18
        uses: jwlawson/actions-setup-cmake@v1.8
        with:
          cmake-version: 3.18

      - name: Build with GCC
        if: runner.os != 'Windows'
        run: |
          cmake -D CMAKE_BUILD_TYPE=$BUILD_TYPE -B build -S .
          cmake --build build --config $BUILD_TYPE
        working-directory: ./source/test/integration/${{ matrix.name }}

      - name: Build with Visual Studio
        if: runner.os == 'Windows'
        shell: bash
        run: |
          cmake -B build -S .
          cmake --build build --config $BUILD_TYPE
        working-directory: ./source/test/integration/${{ matrix.name }}

      - name: Run
        shell: bash
        run: |
          ctest -V -C $BUILD_TYPE
        working-directory: ./source/test/integration/${{ matrix.name }}/build