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

Commit 0718bfd

Browse files
authored
Merge pull request #183 from aminya/ci
ci: use setup-cpp to set up all compilers and tools for all the CI services (GitHub, Gitlab, etc.)
2 parents 007004d + 7897fed commit 0718bfd

7 files changed

Lines changed: 172 additions & 191 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

.gitlab-ci.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
image: ubuntu:latest
2+
3+
stages:
4+
- test
5+
6+
.setup_linux: &setup_linux |
7+
DEBIAN_FRONTEND=noninteractive
8+
9+
# set time-zone
10+
TZ=Canada/Pacific
11+
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
12+
13+
# for downloading
14+
apt-get update -qq
15+
apt-get install -y --no-install-recommends curl gnupg ca-certificates
16+
17+
# keys used by apt
18+
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
19+
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5
20+
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1E9377A2BA9EF27F
21+
22+
.setup_cpp: &setup_cpp |
23+
curl -LJO "https://github.com/aminya/setup-cpp/releases/download/v0.5.8/setup_cpp_linux"
24+
chmod +x setup_cpp_linux
25+
./setup_cpp_linux --compiler $compiler --cmake true --ninja true --conan true --ccache true
26+
source ~/.profile
27+
28+
.test: &test |
29+
# Build and Test
30+
cmake -S . -B ./build -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
31+
cmake --build ./build --config RelWithDebInfo
32+
33+
test_linux_llvm:
34+
stage: test
35+
variables:
36+
compiler: llvm
37+
script:
38+
- *setup_linux
39+
- *setup_cpp
40+
- *test
41+
42+
test_linux_gcc:
43+
stage: test
44+
variables:
45+
compiler: gcc
46+
script:
47+
- *setup_linux
48+
- *setup_cpp
49+
- *test

.travis.yml

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

README.md

Lines changed: 19 additions & 4 deletions
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

@@ -33,10 +33,25 @@ Note about install commands:
3333

3434
### Too Long, Didn't Install
3535

36-
This is a really long list of dependencies, and it's easy to mess up.
37-
That's why we have a Docker image that's already set up for you.
38-
See the [Docker instructions](#docker-instructions) below.
36+
This is a really long list of dependencies, and it's easy to mess up. That's why:
3937

38+
#### Docker
39+
We have a Docker image that's already set up for you. See the [Docker instructions](#docker-instructions).
40+
41+
#### Setup-cpp
42+
43+
We have [setup-cpp](https://github.com/aminya/setup-cpp) that is a cross-platform tool to install all the compilers and dependencies on the system.
44+
45+
Please check [the setup-cpp documentation](https://github.com/aminya/setup-cpp) for more information.
46+
47+
For example, on Windows, you can run the following to install llvm, cmake, ninja, ccache, conan, and cppcheck.
48+
```ps1
49+
# windows example (open shell as admin)
50+
curl -LJO "https://github.com/aminya/setup-cpp/releases/download/v0.5.7/setup_cpp_windows.exe"
51+
./setup_cpp_windows --compiler llvm --cmake true --ninja true --ccache true --conan true --cppcheck true
52+
53+
RefreshEnv.cmd # reload the environment
54+
```
4055

4156
### Necessary Dependencies
4257
1. A C++ compiler that supports C++17.

appveyor.yml

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

conanfile.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Docs at https://docs.conan.io/en/latest/reference/conanfile_txt.html
22

33
[requires]
4-
catch2/2.13.7
5-
docopt.cpp/0.6.2
6-
fmt/8.0.1
4+
catch2/2.13.8
5+
docopt.cpp/0.6.3
6+
fmt/8.1.1
77
spdlog/1.9.2
8-
# imgui-sfml/2.1@bincrafters/stable
9-
# sdl2/2.0.10@bincrafters/stable
8+
# imgui-sfml/2.5@bincrafters/stable
9+
# sdl2/2.0.1
1010

1111
[generators]
1212
cmake_find_package

0 commit comments

Comments
 (0)