-
Notifications
You must be signed in to change notification settings - Fork 7
287 lines (252 loc) · 10.1 KB
/
workflow.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
# This file is a part of Simple-XX/SimplePhysicsEngine
# (https://github.com/Simple-XX/SimplePhysicsEngine).
#
# workflow.yml for Simple-XX/SimplePhysicsEngine.
name: build
on:
- push
- release
env:
CMAKE_BUILD_TYPE: Release
jobs:
build_docs:
name: Build and publish documentation
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt update
sudo apt install --fix-missing -y doxygen graphviz clang-format clang-tidy cppcheck lcov
sudo apt install --fix-missing -y gcc g++ libspdlog-dev libcgal-dev freeglut3-dev libboost-all-dev libvtk9-dev qtbase5-dev xorg-dev libglu1-mesa-dev libglm-dev libglfw3-dev libglew-dev
- name: Build
run: |
cmake --preset=build
cmake --build build --target doc
- name: Publish
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ${{github.workspace}}/doc/html
build_ubuntu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check for CUDA
id: check_cuda
run: |
if command -v nvcc &> /dev/null; then
echo "CUDA is installed."
echo "has_cuda=true" >> $GITHUB_ENV
else
echo "CUDA is not installed."
echo "has_cuda=false" >> $GITHUB_ENV
fi
- name: Install dependencies
run: |
sudo apt update
sudo apt install --fix-missing -y doxygen graphviz clang-format clang-tidy cppcheck lcov
sudo apt install --fix-missing -y gcc g++ libspdlog-dev libcgal-dev freeglut3-dev libboost-all-dev libvtk9-dev qtbase5-dev xorg-dev libglu1-mesa-dev libglm-dev libglfw3-dev libglew-dev
sudo apt-get install --no-install-recommends -y xvfb ffmpeg
# Optionally install CUDA dependencies if CUDA is available
if [ "$has_cuda" = "true" ]; then
sudo apt install --fix-missing -y cuda-toolkit
fi
- name: Build
run: |
cmake --preset=build
cmake --build build --target all
cmake --build build --target coverage
- name: Start Xvfb
run: |
nohup Xvfb :99 -screen 0 800x600x24 &
echo "DISPLAY=:99" >> $GITHUB_ENV
- name: Run demo2d
run: |
for i in {1..7}; do
# Start recording with ffmpeg
ffmpeg -y -f x11grab -video_size 800x600 -i :99 -t 5 -r 10 ./build/bin/demo2d_$i.gif &
FFmpeg_PID=$!
# Run the demo2d program in the background
./build/bin/demo2d --instruction $i --edge_num 33 &
Demo2d_PID=$!
# Wait for 5 seconds
sleep 5
# Stop the ffmpeg recording
kill $FFmpeg_PID
# Terminate the demo2d program
kill $Demo2d_PID
done
env:
DISPLAY: :99
- name: Run MassSpring3D
run: |
for i in {1..1}; do
ffmpeg -y -f x11grab -video_size 800x600 -i :99 -t 5 -r 10 ./build/bin/MassSpring3D_$i.gif &
FFmpeg_PID=$!
./build/bin/MassSpring3D --instruction $i &
MassSpring3D_PID=$!
sleep 5
kill $FFmpeg_PID
kill $MassSpring3D_PID
done
env:
DISPLAY: :99
- name: Upload GIFs
uses: actions/upload-artifact@v4
with:
name: gifs_ubuntu
path: build/bin/*.gif
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
files: build/coverage/coverage.info
verbose: true
build_ubuntu_with_cuda:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: Jimver/[email protected]
with:
# Cuda version
cuda: 11.7.0 # optional, default is 12.5.0
# Only installs specified subpackages, must be in the form of a JSON array. For example, if you only want to install nvcc and visual studio integration: ["nvcc", "visual_studio_integration"] double quotes required! Note that if you want to use this on Linux, 'network' method MUST be used.
sub-packages: '[]' # optional, default is []
# Only installs specified subpackages that do not have the cuda prefix, must be in the form of a JSON array. For example, if you only want to install libcublas and libcufft: ["libcublas", "libcufft"] double quotes required! Note that this only works with 'network' method on only on Linux.
non-cuda-sub-packages: '[]' # optional, default is []
# Installation method, can be either 'local' or 'network'. 'local' downloads the entire installer with all packages and runs that (you can still only install certain packages with sub-packages on Windows). 'network' downloads a smaller executable which only downloads necessary packages which you can define in subPackages
method: network # optional, default is local
# (Linux and 'local' method only) override arguments for the linux .run installer. For example if you don't want samples use ["--toolkit"] double quotes required!
linux-local-args: '["--toolkit", "--samples"]' # optional, default is ["--toolkit", "--samples"]
# Use GitHub cache to cache downloaded installer on GitHub servers
use-github-cache: true # optional, default is true
# Use local cache to cache downloaded installer on the local runner
use-local-cache: true # optional, default is true
# Suffix of log file name in artifact
log-file-suffix: log.txt # optional, default is log.txt
- name: Check for CUDA
id: check_cuda
run: |
if command -v nvcc &> /dev/null; then
echo "CUDA is installed."
echo "has_cuda=true" >> $GITHUB_ENV
else
echo "CUDA is not installed."
echo "has_cuda=false" >> $GITHUB_ENV
fi
- name: Install dependencies
run: |
sudo apt update
sudo apt install --fix-missing -y doxygen graphviz clang-format clang-tidy cppcheck lcov
sudo apt install --fix-missing -y gcc g++ libspdlog-dev libcgal-dev freeglut3-dev libboost-all-dev libvtk9-dev qtbase5-dev xorg-dev libglu1-mesa-dev libglm-dev libglfw3-dev libglew-dev
sudo apt-get install --no-install-recommends -y xvfb ffmpeg
# Optionally install CUDA dependencies if CUDA is available
if [ "$has_cuda" = "true" ]; then
sudo apt install --fix-missing -y cuda-toolkit
fi
- name: Build
run: |
ls
cmake --preset=build
cmake --build build --target all
cmake --build build --target coverage
- name: Start Xvfb
run: |
nohup Xvfb :99 -screen 0 800x600x24 &
echo "DISPLAY=:99" >> $GITHUB_ENV
- name: Run MassSpring3D
run: |
for i in {1..1}; do
ffmpeg -y -f x11grab -video_size 800x600 -i :99 -t 5 -r 10 ./build/bin/MassSpring3D_$i.gif &
FFmpeg_PID=$!
./build/bin/MassSpring3D --instruction $i &
MassSpring3D_PID=$!
sleep 5
kill $FFmpeg_PID
kill $MassSpring3D_PID
done
env:
DISPLAY: :99
- name: Upload GIFs
uses: actions/upload-artifact@v4
with:
name: gifs_ubuntu
path: build/bin/*.gif
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
files: build/coverage/coverage.info
verbose: true
build_macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
brew install doxygen graphviz llvm cppcheck lcov spdlog boost freeglut glfw glew vtk cgal glm ffmpeg
ln -s "$(brew --prefix llvm)/bin/clang-format" "/usr/local/bin/clang-format"
ln -s "$(brew --prefix llvm)/bin/clang-tidy" "/usr/local/bin/clang-tidy"
brew install --cask xquartz
- name: Start Xvfb
run: |
sudo /opt/X11/bin/Xvfb :99 -screen 0 800x600x24 &
echo "DISPLAY=:99" >> $GITHUB_ENV
export DISPLAY=:99
sleep 3 # Give Xvfb some time to start
- name: Build
run: |
cmake --preset=build
cmake --build build --target all
- name: Run demo2d
run: |
for i in {1..7}; do
# Start recording with ffmpeg
ffmpeg -y -f x11grab -video_size 800x600 -i :99 -t 5 -r 10 ./build/bin/demo2d_$i.gif &
FFmpeg_PID=$!
# Run the demo2d program in the background
./build/bin/demo2d --instruction $i &
Demo2d_PID=$!
# Wait for 5 seconds
sleep 5
# Stop the ffmpeg recording
if ps -p $FFmpeg_PID > /dev/null; then
kill $FFmpeg_PID
fi
# Terminate the demo2d program
if ps -p $Demo2d_PID > /dev/null; then
kill $Demo2d_PID
fi
done
env:
DISPLAY: :99
- name: Run MassSpring3D
run: |
for i in {1..1}; do
ffmpeg -y -f x11grab -video_size 800x600 -i :99 -t 5 -r 10 ./build/bin/MassSpring3D_$i.gif &
FFmpeg_PID=$!
./build/bin/MassSpring3D --instruction $i &
MassSpring3D_PID=$!
sleep 5
if ps -p $FFmpeg_PID > /dev/null; then
kill $FFmpeg_PID
fi
if ps -p $MassSpring3D_PID > /dev/null; then
kill $MassSpring3D_PID
fi
done
env:
DISPLAY: :99
- name: Upload GIFs
uses: actions/upload-artifact@v4
with:
name: gifs_macos
path: build/bin/*.gif
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
files: build/coverage/coverage.info
verbose: true
# @bug 在 osx 下无法正常执行 lcov
# cmake --build build --target coverage