Repository navigation
135 lines (117 loc) · 4.26 KB
/
Copy pathcpp.yml
File metadata and controls
135 lines (117 loc) · 4.26 KB
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# This GitHub workflow file is meant to be a test for the template repo itself.
# You should replace it with your own workflow file for your project.
name: CI
on: [push, pull_request]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
type: [exe, static, shared]
env:
# The option prefix is the upper-cased IDICMAKE_PROJECT_NAME from platform-config.cmake (here template_project).
# Rename it with the project: CMake ignores options with another prefix without a warning.
CMAKE_ARGS: -DTEMPLATE_PROJECT_BUILD_DEMOS=1 -DTEMPLATE_PROJECT_BUILD_TESTS=1 -DTEMPLATE_PROJECT_USE_BUILD_TIMESTAMPS=1 -DTEMPLATE_PROJECT_DO_TEMPLATE_COMPONENT_TEST=1 -DTEMPLATE_PROJECT_CI_GIT_BRANCH_NAME="${{ github.ref_name }}"
steps:
- name: Checkout the source code
uses: actions/checkout@v7
with:
submodules: recursive
- name: Configure
shell: bash
run: |
export PATH=$HOME/cmake/bin:$PATH
mkdir -p build
cd build
cmake --version
cmake .. $CMAKE_ARGS -DIDICMAKE_PLATFORM_CONFIG="../platform-config.${{ matrix.type }}.cmake"
- name: Build
shell: bash
run: |
export PATH=$HOME/cmake/bin:$PATH
cd build
cmake --build . -j 8
- name: Test
shell: bash
run: |
export PATH=$HOME/cmake/bin:$PATH
cd build
ctest -C Debug --output-on-failure --output-junit ctest.xml
- name: Upload Artifact
if: always()
uses: actions/upload-artifact@v7
with:
name: idi-cpp-template-${{ matrix.type }}-${{ matrix.os }}-${{ github.sha }}
path: build/ctest.xml
# Lint: clang-format and the clang-tidy gate must both pass.
# Pin the clang version so local runs (cmake/idi/tools/lint.sh --clang-version 21) match CI.
lint:
runs-on: ubuntu-latest
env:
CMAKE_ARGS: -DTEMPLATE_PROJECT_BUILD_DEMOS=1 -DTEMPLATE_PROJECT_BUILD_TESTS=1
steps:
- name: Checkout the source code
uses: actions/checkout@v7
with:
submodules: recursive
- name: Install tools
run: |
wget -qO- https://apt.llvm.org/llvm.sh | sudo bash -s 21
sudo apt-get install -y -qq ninja-build clang-format-21 clang-tidy-21
- name: Format check
shell: bash
run: cmake/idi/tools/lint.sh --format-only --clang-version 21 -- $CMAKE_ARGS
- name: clang-tidy
shell: bash
run: cmake/idi/tools/lint.sh --tidy-only --clang-version 21 -- $CMAKE_ARGS
# Tests under AddressSanitizer + UndefinedBehaviorSanitizer (leaks included). Add a job with
# -DIDICMAKE_SANITIZERS=thread for code that uses threads.
sanitizers:
runs-on: ubuntu-latest
env:
CMAKE_ARGS: -DTEMPLATE_PROJECT_BUILD_DEMOS=1 -DTEMPLATE_PROJECT_BUILD_TESTS=1 -DTEMPLATE_PROJECT_DO_TEMPLATE_COMPONENT_TEST=1
CC: clang-21
CXX: clang++-21
steps:
- name: Checkout the source code
uses: actions/checkout@v7
with:
submodules: recursive
- name: Install tools
run: |
wget -qO- https://apt.llvm.org/llvm.sh | sudo bash -s 21
sudo apt-get install -y -qq ninja-build libclang-rt-21-dev
- name: Build and test
shell: bash
run: |
cmake -S . -B build $CMAKE_ARGS -DIDICMAKE_SANITIZERS="address;undefined"
cmake --build build -j 8
ctest --test-dir build -C Debug --output-on-failure --output-junit ctest.xml
- name: Upload Artifact
if: always()
uses: actions/upload-artifact@v7
with:
name: idi-cpp-template-sanitizers-${{ github.sha }}
path: build/ctest.xml
coverage:
runs-on: ubuntu-latest
env:
CMAKE_ARGS: -DTEMPLATE_PROJECT_BUILD_DEMOS=1 -DTEMPLATE_PROJECT_BUILD_TESTS=1
steps:
- name: Checkout the source code
uses: actions/checkout@v7
with:
submodules: recursive
- name: Install tools
run: sudo apt-get update -qq && sudo apt-get install -y -qq ninja-build lcov gcovr
- name: Coverage
shell: bash
run: cmake/idi/tools/coverage.sh -- $CMAKE_ARGS
- name: Upload report
if: always()
uses: actions/upload-artifact@v7
with:
name: idi-cpp-template-coverage-${{ github.sha }}
path: build-coverage/reports/coverage/