-
Notifications
You must be signed in to change notification settings - Fork 0
258 lines (225 loc) · 9.91 KB
/
cmake-multi-platform.yml
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
name: CMake on multiple platforms
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
concurrency:
group: ${{ github.repository }}-${{ github.event.number || github.head_ref || github.sha }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false
# Set up a matrix to run the following 3 configurations:
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
#
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
build_type: [RelWithDebInfo]
c_compiler: [clang, cl]
include:
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
- os: macos-latest
c_compiler: clang
cpp_compiler: clang++
exclude:
- os: windows-latest
c_compiler: gcc
- os: windows-latest
c_compiler: clang
- os: ubuntu-latest
c_compiler: cl
- os: ubuntu-latest
c_compiler: gcc
- os: macos-latest
c_compiler: gcc
- os: macos-latest
c_compiler: cl
steps:
- uses: actions/checkout@v4
- name: "[C++] Ccache for gh actions"
uses: hendrikmuhs/[email protected]
with:
key: ${{ github.job }}-${{ matrix.os }} # Eg. "some_build-ubuntu-latest"
- name: "Set reusable strings"
# Turn repeated input strings (such as the build output directory) into step outputs.
# These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: "[C++] Cache CMake dependency source code"
uses: actions/cache@v4
env:
cache-name: cache-cmake-dependency-sources
with:
# CMake cache is at ${{github.workspace}}/build/_deps but we only will cache folders ending in '-src' to cache source code
path: ${{github.workspace}}/build/_deps/*-src
# Cache hash is dependent on CMakeLists files anywhere as these can change what's in the cache, as well as cmake modules files
key: ${{ env.cache-name }}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
# it's acceptable to reuse caches for different CMakeLists content if exact match is not available and unlike build caches, we
# don't need to restrict these by OS or compiler as it's only source code that's being cached
restore-keys: |
${{ env.cache-name }}-
- name: "[C++] Cache CMake dependency build objects"
uses: actions/cache@v4
env:
cache-name: cache-cmake-dependency-builds
with:
# CMake cache is at ${{github.workspace}}/build/_deps but we only care about the folders ending in -build or -subbuild
path: |
${{github.workspace}}/build/_deps/*-build
${{github.workspace}}/build/_deps/*-subbuild
# Cache hash is dependent on CMakeLists files anywhere as these can change what's in the cache, as well as cmake modules files
key: ${{ env.cache-name }}-${{ matrix.os }}-${{ matrix.cxx }}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
# it's acceptable to reuse caches for different CMakeLists content if exact match is not available
# as long as the OS and Compiler match exactly
restore-keys: |
${{ env.cache-name }}-${{ matrix.os }}-${{ matrix.cxx }}-
- name: "[C++] Configure CMake"
# Configure CMake in a 'build' subdirectory.
# `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake
-B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER_LAUNCHER=ccache
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-S ${{ github.workspace }}
- name: "[C++] Build"
# Build your program with the given configuration.
# Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: >
cmake
--build ${{ steps.strings.outputs.build-output-dir }}
--config ${{ matrix.build_type }}
- name: "[C++] Test"
working-directory: ${{ steps.strings.outputs.build-output-dir }}
# Execute tests defined by the CMake configuration.
# Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --build-config ${{ matrix.build_type }}
- name: "[C++] Generate PB Tech"
run: ./gen_tech_pb
- name: "[C++] Store Build Products"
uses: actions/upload-artifact@v4
with:
name: ${{ github.job }}-${{ matrix.os }} # -${{ matrix.build_type }}
path: |
build/python # Generated Python Protobuffer Classes
build/*_tech.pb.json # KPEX Tech Info Protobuffers
test:
needs: build
strategy:
# fail-fast: true
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ['3.13']
runs-on: ${{ matrix.os }}
env:
ALLURE_RESULTS_PATH: 'build/${{ matrix.os }}_${{ matrix.python-version }}/allure-results'
ALLURE_REPORTS_PATH: 'build/${{ matrix.os }}_${{ matrix.python-version }}/allure-reports'
COVERAGE_REPORT_PATH: 'build/${{ matrix.os }}_${{ matrix.python-version }}/python-coverage-report'
PYTHONPATH: .:build/python:$PYTHONPATH
steps:
- name: "[Python] checkout repository"
uses: actions/checkout@v4
- name: "[Python] Retrieve C++ Build Artifact"
uses: actions/download-artifact@v4
with:
name: build-${{ matrix.os }}
- name: "[Python] Setup python ${{ matrix.python-version }}"
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: "[Python] Install Poetry"
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
virtualenvs-path: .venv
installer-parallel: true
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: "[Python] Load cached venv"
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: "[Python] Install dependencies"
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
#----------------------------------------------
# install your root project, if required
#----------------------------------------------
- name: "[Python] Install project"
run: poetry install --no-interaction
#----------------------------------------------
# run test suite
#----------------------------------------------
- name: "[Python] Run tests"
run: >
poetry run pytest
--alluredir $ALLURE_RESULTS_PATH
--color no
--cov $COVERAGE_REPORT_PATH
--cov-report html
- name: "[Python] Create coverage report"
run: poetry run coverage report
- name: "[Python] Store coverage results"
uses: actions/upload-artifact@v4
with:
name: python-coverage-report
path: $COVERAGE_REPORT_PATH
retention-days: 1
- name: "Set up JDK (for Allure)"
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 17
- name: "Load test report history (Allure)"
uses: actions/checkout@v4
if: always()
continue-on-error: true
with:
ref: gh-pages
path: gh-pages
- name: "Build test report"
uses: simple-elf/[email protected]
if: always()
with:
gh_pages: gh-pages
allure_history: allure-history
allure_results: build/allure-results
- name: "Publish test report"
uses: peaceiris/actions-gh-pages@v3
if: always()
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: allure-history