-
-
Notifications
You must be signed in to change notification settings - Fork 0
266 lines (236 loc) · 8.2 KB
/
Copy pathbuild.yml
File metadata and controls
266 lines (236 loc) · 8.2 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
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
259
260
261
262
263
264
265
266
name: CI Build
on:
push:
branches: [ main ]
paths:
- 'source/**'
- 'thirdparty/**'
- 'toolchain/**'
- 'cmake/**'
- 'CMakeLists.txt'
pull_request:
branches: [ main ]
paths:
- 'source/**'
- 'thirdparty/**'
- 'toolchain/**'
- 'cmake/**'
- 'CMakeLists.txt'
workflow_call:
inputs:
package-artifacts:
description: 'Whether to package and upload the compiled binaries'
type: boolean
required: false
default: false
target-os:
description: 'Comma-separated list of OS to build (e.g., linux,windows). Leave empty for all.'
type: string
required: false
default: ''
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
setup-matrix:
name: Determine Build Matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
should_run: ${{ steps.set-matrix.outputs.should_run }}
steps:
- name: Parse Tags and Inputs
id: set-matrix
uses: actions/github-script@v8
env:
EVENT_NAME: ${{ github.event_name }}
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
INPUT_TARGET_OS: ${{ inputs.target-os }}
with:
script: |
const eventName = process.env.EVENT_NAME;
const commitMsg = (process.env.COMMIT_MESSAGE || '').toLowerCase();
const inputOs = (process.env.INPUT_TARGET_OS || '').toLowerCase();
const allOs = ['ubuntu-latest', 'windows-latest', 'macos-latest'];
const osMap = {
'linux': 'ubuntu-latest',
'ubuntu': 'ubuntu-latest',
'windows': 'windows-latest',
'macos': 'macos-latest'
};
let selectedOs = new Set(allOs);
if (eventName === 'push') {
// Note: GitHub actions natively skips runs with [skip ci],
// but we handle it here just in case native skip is bypassed.
if (commitMsg.includes('[skip ci]')) {
selectedOs.clear();
} else {
const runMatch = commitMsg.match(/\[run\s+([^\]]+)\]/);
const skipMatch = commitMsg.match(/\[skip\s+([^\]]+)\]/);
if (runMatch) {
selectedOs.clear();
runMatch[1].split(',').forEach(t => {
const key = t.trim();
if (osMap[key]) selectedOs.add(osMap[key]);
});
} else if (skipMatch) {
skipMatch[1].split(',').forEach(t => {
const key = t.trim();
if (osMap[key]) selectedOs.delete(osMap[key]);
});
}
}
} else if (eventName === 'workflow_call') {
if (inputOs) {
selectedOs.clear();
inputOs.split(',').forEach(t => {
const key = t.trim();
if (osMap[key]) selectedOs.add(osMap[key]);
else if (allOs.includes(key)) selectedOs.add(key); // Fallback if they type exact runner name
});
}
}
// For 'pull_request', it bypasses the above blocks and defaults to allOs.
const finalOs = Array.from(selectedOs);
core.setOutput('matrix', finalOs);
core.setOutput('should_run', finalOs.length > 0);
build:
name: Build on ${{ matrix.os }}
needs: setup-matrix
if: needs.setup-matrix.outputs.should_run == 'true'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
build-type: [Development]
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
submodules: recursive
fetch-depth: 0
- name: Set up MSVC Dev Cmd
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
- name: Setup Dependencies
uses: ./.github/actions/setup-deps
with:
os: ${{ matrix.os }}
build-dir: build
- name: Setup Ccache
uses: hendrikmuhs/ccache-action@v1.2.23
with:
key: ${{ matrix.os }}-${{ matrix.build-type }}
- name: Cache CMake FetchContent
uses: actions/cache@v5
with:
path: ~/.cache/cmake_deps
key: ${{ runner.os }}-cmake-deps-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}
restore-keys: |
${{ runner.os }}-cmake-deps-
- name: Configure CMake
shell: bash
run: |
cmake -S . -B build \
-G Ninja \
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DFETCHCONTENT_BASE_DIR="$HOME/.cache/cmake_deps" \
-DGPBT_RUNNING_IN_CI=TRUE \
-DGPBT_TESTS_ENABLED=FALSE \
-DGPBT_LOG_PREFIX_ENABLED=FALSE \
-DGPBT_LOG_VERBOSE_ENABLED=TRUE \
-DGPBT_DUMP_TARGETS_PROPERTIES=TRUE \
-DGPBT_THIRDPARTY_MODE=AUTO \
-DGPBT_IS_MONOLITHIC=FALSE \
-DGPBT_EXPORT_DEPENDENCY_GRAPH=FALSE
- name: Build
run: cmake --build build --config ${{ matrix.build-type }} --parallel --verbose
- name: Upload Build Tree
uses: actions/upload-artifact@v4
with:
name: build-tree-${{ matrix.os }}
path: build/
retention-days: 1
- name: Upload Compiled Binaries
uses: actions/upload-artifact@v4
with:
name: engine-binaries-${{ matrix.os }}
path: binaries/
retention-days: 1
test:
name: Test (${{ matrix.os }})
needs: [setup-matrix, build]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
build-type: [Release]
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
submodules: recursive
- name: Download Build Tree
uses: actions/download-artifact@v4
with:
name: build-tree-${{ matrix.os }}
path: build/
- name: Download Compiled Binaries
uses: actions/download-artifact@v4
with:
name: engine-binaries-${{ matrix.os }}
path: binaries/
- name: Restore executable permissions
if: runner.os != 'Windows'
run: |
chmod -R +x binaries/bin || true
chmod -R +x build/ || true
- name: Run Tests
shell: bash
run: |
cd build
ctest --output-on-failure -C ${{ matrix.build-type }}
package:
name: Package (${{ matrix.os }})
needs: [setup-matrix, build, test]
if: inputs.package-artifacts == true
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
build-type: [Release]
steps:
- uses: actions/checkout@v5
- name: Download Build Tree
uses: actions/download-artifact@v4
with:
name: build-tree-${{ matrix.os }}
path: build/
- name: Download Compiled Binaries
uses: actions/download-artifact@v4
with:
name: engine-binaries-${{ matrix.os }}
- name: Install & Versioning
shell: bash
run: |
cmake --install build --prefix install_staging
GP_VERSION=$(head -n 1 VERSION | tr -d '\r\n ')
echo "VERSION=$GP_VERSION" >> $GITHUB_ENV
- name: Archive (Unix)
if: runner.os != 'Windows'
run: tar -czvf gp-engine-${{ matrix.os }}-${{ env.VERSION }}.tar.gz -C install_staging .
- name: Archive (Windows)
if: runner.os == 'Windows'
run: powershell Compress-Archive -Path install_staging\* -DestinationPath gp-engine-${{ matrix.os }}-${{ env.VERSION }}.zip
- name: Upload Release Artifacts
uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.os }}
path: gp-engine-${{ matrix.os }}-${{ env.VERSION }}.*
retention-days: 14