-
Notifications
You must be signed in to change notification settings - Fork 1
326 lines (324 loc) · 11.2 KB
/
make.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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
name: CI
on:
push:
workflow_dispatch:
schedule:
- cron: "43 17 1 * *"
jobs:
build-windows:
timeout-minutes: 10
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
config:
- {CXX: cl, build_type: Debug}
- {CXX: g++, build_type: all}
- {CXX: g++, build_type: release}
- {CXX: clang++, build_type: all}
- {CXX: clang++, build_type: release}
- {CXX: cmake, build_type: Debug}
name: "windows-latest ${{ matrix.config.CXX }} ${{ matrix.config.build_type }}"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup LLVM
# https://github.com/actions/runner-images/issues/10001
if: matrix.config.CXX == 'clang++'
run: |
choco upgrade llvm -y
echo "LLVM_PATH=C:\Program Files\LLVM\bin" >> $GITHUB_ENV
- name: Set up Microsoft Dev Cmd
if: matrix.config.CXX == 'cl'
uses: ilammy/msvc-dev-cmd@v1.13.0
with:
arch: amd64
- name: Output compiler version
shell: bash
run: |
if [[ "${{ matrix.config.CXX }}" == "cl" ]]; then
cl
else \
${{ matrix.config.CXX }} --version
fi
- name: Make all
if: matrix.config.CXX != 'cmake' && matrix.config.CXX != 'cl' && matrix.config.build_type == 'all'
shell: bash
run: |
# output 3 to stdin (to close the game) as 'make all' will start the game
echo -e "3" | make CXX=${{ matrix.config.CXX }} all -j2
- name: Make release
if: matrix.config.CXX != 'cmake' && matrix.config.CXX != 'cl' && matrix.config.build_type == 'release'
shell: bash
run: |
make release CXX=${{ matrix.config.CXX }} -j 2
- name: CMake
if: matrix.config.CXX == 'cmake'
shell: bash
run: |
cmake -B build -S . -DOUTPUT_NAME=stocksim-cmake -Werror=dev -Werror=deprecated --fresh
cmake --build build --parallel 2 --config ${{ matrix.config.build_type }} --clean-first
cmake --install build --prefix . --config ${{ matrix.config.build_type }}
- name: Compile with cl
if: matrix.config.CXX == 'cl'
shell: cmd
run: |
make msvc
- name: Run test cases
shell: bash
run: |
if [[ "${{ matrix.config.CXX }}" == "cmake" ]]; then
executable="stocksim-cmake"
elif [[ "${{ matrix.config.CXX }}" == "cl" ]]; then
executable="stocksim-msvc"
elif [[ "${{ matrix.config.build_type }}" == "release" ]]; then
executable="stocksim-release"
else
executable="stocksim"
fi
make input-check OUTPUT=$executable
- name: Upload executable
uses: actions/upload-artifact@v4
with:
name: stocksim-windows-latest-${{ matrix.config.CXX }}-${{ matrix.config.build_type }}
path: stocksim*
compression-level: 9
if-no-files-found: error
build-ubuntu:
timeout-minutes: 10
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
config:
- {CXX: g++, build_type: all}
- {CXX: g++, build_type: release}
# -pedantic on older compilers like g++10
- {CXX: g++-10, build_type: all}
- {CXX: g++-10, build_type: release}
- {CXX: clang++, build_type: all}
- {CXX: clang++, build_type: release}
- {CXX: cmake, build_type: Debug}
- {CXX: cosmoc++, build_type: all}
- {CXX: cosmoc++, build_type: release}
name: "ubuntu-latest ${{ matrix.config.CXX }} ${{ matrix.config.build_type }}"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup cosmoc++
if: matrix.config.CXX == 'cosmoc++'
shell: bash
run: |
mkdir -p cosmocc
cd cosmocc
wget https://cosmo.zip/pub/cosmocc/cosmocc.zip -q
unzip -qq cosmocc.zip
git clone https://github.com/jart/cosmopolitan --depth=1
cd cosmopolitan
sudo ape/apeinstall.sh
cd ..
cd ..
echo "$(pwd)/cosmocc/bin" >> $GITHUB_PATH
- name: Output compiler version
shell: bash
run: |
${{ matrix.config.CXX }} --version
- name: Make all
if: matrix.config.CXX != 'cmake' && matrix.config.build_type == 'all'
shell: bash
run: |
# output 3 to stdin (to close the game) as 'make all' will start the game
echo -e "3" | make CXX=${{ matrix.config.CXX }} all -j2
- name: Make release
if: matrix.config.CXX != 'cmake' && matrix.config.build_type == 'release'
shell: bash
run: |
make release CXX=${{ matrix.config.CXX }} -j 2
- name: CMake
if: matrix.config.CXX == 'cmake'
shell: bash
run: |
cmake -B build -S . -DOUTPUT_NAME=stocksim-cmake -Werror=dev -Werror=deprecated --fresh
cmake --build build --parallel 2 --config ${{ matrix.config.build_type }} --clean-first
cmake --install build --prefix . --config ${{ matrix.config.build_type }}
- name: Run test cases
shell: bash
run: |
if [[ "${{ matrix.config.CXX }}" == "cmake" ]]; then
executable="stocksim-cmake"
elif [[ "${{ matrix.config.CXX }}" == "cl" ]]; then
executable="stocksim-msvc"
elif [[ "${{ matrix.config.build_type }}" == "release" ]]; then
executable="stocksim-release"
else
executable="stocksim"
fi
make input-check OUTPUT=$executable
- name: Upload executable
uses: actions/upload-artifact@v4
with:
name: stocksim-ubuntu-latest-${{ matrix.config.CXX }}-${{ matrix.config.build_type }}
path: stocksim*
compression-level: 9
if-no-files-found: error
build-macos:
timeout-minutes: 10
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# macos-12 for x64, macos-14 for arm64
# xlarge image: "Spending limit exceeded."
os: [macos-12, macos-14]
config:
- {CXX: g++, build_type: all}
- {CXX: g++, build_type: release}
- {CXX: clang++, build_type: all}
- {CXX: clang++, build_type: release}
- {CXX: cmake, build_type: Debug}
name: "${{ matrix.os }} ${{ matrix.config.CXX }} ${{ matrix.config.build_type }}"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Output compiler version
shell: bash
run: |
${{ matrix.config.CXX }} --version
- name: Make all
if: matrix.config.CXX != 'cmake' && matrix.config.build_type == 'all'
shell: bash
run: |
# output 3 to stdin (to close the game) as 'make all' will start the game
echo -e "3" | make CXX=${{ matrix.config.CXX }} all -j2
- name: Make release
if: matrix.config.CXX != 'cmake' && matrix.config.build_type == 'release'
shell: bash
run: |
make release CXX=${{ matrix.config.CXX }} -j 2
- name: CMake
if: matrix.config.CXX == 'cmake'
shell: bash
run: |
cmake -B build -S . -DOUTPUT_NAME=stocksim-cmake -Werror=dev -Werror=deprecated --fresh
cmake --build build --parallel 2 --config ${{ matrix.config.build_type }} --clean-first
cmake --install build --prefix . --config ${{ matrix.config.build_type }}
- name: Run test cases
shell: bash
run: |
if [[ "${{ matrix.config.CXX }}" == "cmake" ]]; then
executable="stocksim-cmake"
elif [[ "${{ matrix.config.build_type }}" == "release" ]]; then
executable="stocksim-release"
else
executable="stocksim"
fi
make input-check OUTPUT=$executable
- name: Upload executable
uses: actions/upload-artifact@v4
with:
name: stocksim-${{ matrix.os }}-${{ matrix.config.CXX }}-${{ matrix.config.build_type }}
path: stocksim*
compression-level: 9
if-no-files-found: error
analyze:
needs: [build-ubuntu]
name: CodeQL Analysis (${{ matrix.language }})
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
security-events: write
packages: read
actions: read
contents: read
strategy:
fail-fast: false
matrix:
include:
- language: c-cpp
build-mode: autobuild
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
# https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
queries: security-extended,security-and-quality
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
clang-format:
runs-on: ubuntu-latest
needs: [build-ubuntu]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Make check
run: |
make format-check
coveralls:
runs-on: ubuntu-latest
needs: [build-ubuntu]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup cpp-coveralls
run: |
sudo apt-get install -y python3-pip
pip3 install cpp-coveralls
- name: Coveralls
run: |
make clean
CXXFLAGS=--coverage make goto
make input-check
coveralls --repo-token ${{ secrets.COVERALLS_REPO_TOKEN }}
deploy:
needs: [analyze, clang-format, coveralls, build-windows, build-macos]
concurrency:
group: "pages"
cancel-in-progress: false
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# Because ubuntu doxygen is currently outdated (v1.9 instead of v1.10)
- name: Install doxygen and graphviz via Chocolatey
run: |
choco install doxygen.portable graphviz --yes -r --no-progress
- name: Build documentation for every branch
shell: bash
run: |
mkdir docs-output
branches="`git branch -lr | cut -c 10- | cut -d ' ' -f 1 | grep -v HEAD`"
for branch in $branches
do
echo $branch
git checkout $branch
make clean
make docs
mv html docs-output/$branch
done
mv docs-output/main html
mv docs-output html/other-branches
- name: Upload pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'html/'
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4