|
| 1 | +name: ci |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - master |
| 8 | + |
| 9 | +env: |
| 10 | + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) |
| 11 | + BUILD_TYPE: RelWithDebInfo |
| 12 | + # Conan cache environment variables |
| 13 | + CONAN_SYSREQUIRES_MODE: enabled |
| 14 | + CONAN_USER_HOME: "${{ github.workspace }}/conan-cache" |
| 15 | + CONAN_USER_HOME_SHORT: "${{ github.workspace }}/conan-cache/short" |
| 16 | + |
| 17 | +jobs: |
| 18 | + Test: |
| 19 | + runs-on: ${{ matrix.os }} |
| 20 | + strategy: |
| 21 | + fail-fast: false |
| 22 | + matrix: |
| 23 | + os: |
| 24 | + - windows-2019 |
| 25 | + - ubuntu-20.04 |
| 26 | + - macos-10.15 |
| 27 | + compiler: |
| 28 | + # you can specify the version after `-` like "llvm-13.0.0". |
| 29 | + - llvm |
| 30 | + - gcc |
| 31 | + include: |
| 32 | + - os: "windows-latest" |
| 33 | + compiler: "msvc" |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@v2 |
| 36 | + |
| 37 | + - name: Cache |
| 38 | + uses: actions/cache@v2 |
| 39 | + with: |
| 40 | + path: | |
| 41 | + ~/vcpkg |
| 42 | + ./build/vcpkg_installed |
| 43 | + ${{ env.CONAN_USER_HOME }} |
| 44 | + ~/.cache/pip |
| 45 | + ${{ env.HOME }}/.cache/vcpkg/archives |
| 46 | + ${{ env.XDG_CACHE_HOME }}/vcpkg/archives |
| 47 | + ${{ env.LOCALAPPDATA }}\vcpkg\archives |
| 48 | + ${{ env.APPDATA }}\vcpkg\archives |
| 49 | + key: ${{ runner.os }}-${{ matrix.compiler }}-${{env.BUILD_TYPE}}-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('./conanfile.txt')}}-${{ hashFiles('./vcpkg.json')}} |
| 50 | + restore-keys: | |
| 51 | + ${{ runner.os }}-${{ matrix.compiler }}-${{env.BUILD_TYPE}}- |
| 52 | +
|
| 53 | + - name: Setup Cpp |
| 54 | + uses: aminya/setup-cpp@v1 |
| 55 | + with: |
| 56 | + compiler: ${{ matrix.compiler }} |
| 57 | + vcvarsall: ${{ contains(matrix.os, 'windows' )}} |
| 58 | + |
| 59 | + cmake: true |
| 60 | + ninja: true |
| 61 | + conan: true |
| 62 | + vcpkg: false |
| 63 | + ccache: true |
| 64 | + |
| 65 | + cppcheck: true |
| 66 | + |
| 67 | + gcovr: true |
| 68 | + opencppcoverage: true |
| 69 | + |
| 70 | + - name: Configure CMake |
| 71 | + run: | |
| 72 | + cmake -S . -B ./build -DCMAKE_BUILD_TYPE:STRING=${{env.BUILD_TYPE}} |
| 73 | +
|
| 74 | + - name: Build |
| 75 | + # Execute the build. You can specify a specific target with "--target <NAME>" |
| 76 | + run: | |
| 77 | + cmake --build ./build --config ${{env.BUILD_TYPE}} |
| 78 | +
|
| 79 | + - name: Unix - Test and coverage |
| 80 | + if: runner.os != 'Windows' |
| 81 | + working-directory: ./build |
| 82 | + # Execute tests defined by the CMake configuration. |
| 83 | + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail |
| 84 | + run: | |
| 85 | + ctest -C ${{env.BUILD_TYPE}} |
| 86 | + gcovr -j ${{env.nproc}} --delete --root ../ --print-summary --xml-pretty --xml coverage.xml . |
| 87 | +
|
| 88 | + - name: Windows - Test and coverage |
| 89 | + if: runner.os == 'Windows' |
| 90 | + working-directory: ./build |
| 91 | + run: | |
| 92 | + OpenCppCoverage.exe --sources cpp_starter_project --export_type cobertura:coverage.xml --cover_children -- ctest -C ${{env.BUILD_TYPE}} |
| 93 | +
|
| 94 | + - name: Publish to codecov |
| 95 | + uses: codecov/codecov-action@v2 |
| 96 | + with: |
| 97 | + flags: ${{ runner.os }} |
| 98 | + name: ${{ runner.os }}-coverage |
| 99 | + files: ./build/coverage.xml |
0 commit comments