Skip to content
This repository was archived by the owner on Apr 19, 2023. It is now read-only.

Commit c310c57

Browse files
committed
ci: use setup-cpp to set up the CI
1 parent ffb2784 commit c310c57

3 files changed

Lines changed: 100 additions & 103 deletions

File tree

.github/workflows/build_cmake.yml

Lines changed: 0 additions & 102 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# cpp_starter_project
22

33
[![Build status](https://ci.appveyor.com/api/projects/status/d1tbhi2frii45rcl/branch/main?svg=true)](https://ci.appveyor.com/project/cpp-best-practices/cpp-starter-project/branch/main)
4-
![CMake](https://github.com/cpp-best-practices/cpp_starter_project/workflows/CMake/badge.svg)
4+
![CI](https://github.com/cpp-best-practices/cpp_starter_project/workflows/ci/badge.svg)
55
[![codecov](https://codecov.io/gh/cpp-best-practices/cpp_starter_project/branch/main/graph/badge.svg)](https://codecov.io/gh/cpp-best-practices/cpp_starter_project)
66
[![Language grade: C++](https://img.shields.io/lgtm/grade/cpp/github/cpp-best-practices/cpp_starter_project)](https://lgtm.com/projects/g/cpp-best-practices/cpp_starter_project/context:cpp)
77

0 commit comments

Comments
 (0)