forked from ddnet/ddnet
-
Notifications
You must be signed in to change notification settings - Fork 1
218 lines (192 loc) · 8.38 KB
/
build.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
name: Build
on:
push:
branches-ignore:
- gh-readonly-queue/**
pull_request:
merge_group:
jobs:
build-cmake:
runs-on: ${{ matrix.os }}
env:
CARGO_HTTP_MULTIPLEXING: false
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest, ubuntu-20.04]
include:
- os: ubuntu-latest
cmake-args: -G Ninja
cmake-init-env: CXXFLAGS=-Werror
package-file: "*-linux_x86_64.tar.xz"
fancy: true
- os: ubuntu-20.04
cmake-path: /usr/bin/
cmake-args: -G Ninja -DTEST_MYSQL=ON
cmake-init-env: CXXFLAGS=-Werror
gtest-env: GTEST_FILTER=-*SQLite*
package-file: "*-linux_x86_64.tar.xz"
fancy: false
- os: macOS-latest
cmake-args: -G Ninja
cmake-init-env: CXXFLAGS=-Werror
package-file: "*-macos.dmg"
fancy: false
- os: windows-latest
cmake-args: -A x64
cmake-init-env: CXXFLAGS=/WX LDFLAGS=/WX
package-file: "*-win64.zip"
fancy: false
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Prepare Linux
if: contains(matrix.os, 'ubuntu')
run: |
sudo apt-get update -y
# mount: /var/lib/grub/esp: special device /dev/disk/by-id/scsi-... does not exist.
# sudo apt-get upgrade -y
sudo apt-get install pkg-config cmake ninja-build libfreetype6-dev libnotify-dev libsdl2-dev libsqlite3-dev libvulkan-dev glslang-tools spirv-tools libavcodec-dev libavformat-dev libavutil-dev libswresample-dev libswscale-dev libx264-dev libpng-dev valgrind gcovr libglew-dev -y
- name: Prepare Linux (non-fancy)
if: ${{ contains(matrix.os, 'ubuntu') && !matrix.fancy }}
run: |
# Our minimum supported Rust version (MSRV)
rustup default 1.63.0
sudo rm -rf /var/lib/mysql/ /var/run/mysqld
sudo mkdir /var/lib/mysql/ /var/run/mysqld/
sudo chown mysql:mysql /var/lib/mysql/ /var/run/mysqld/
sudo mysqld --initialize-insecure --user=mysql --basedir=/usr --datadir=/var/lib/mysql/
sudo /usr/bin/mysqld_safe --basedir=/usr --datadir='/var/lib/mysql/' &
sleep 10
sudo mysql <<EOF
CREATE DATABASE ddnet;
CREATE USER 'ddnet'@'localhost' IDENTIFIED BY 'thebestpassword';
GRANT ALL PRIVILEGES ON ddnet.* TO 'ddnet'@'localhost';
FLUSH PRIVILEGES;
EOF
- name: Prepare Linux (fancy)
if: contains(matrix.os, 'ubuntu') && matrix.fancy
run: |
sudo apt-get install libmariadb-dev libwebsockets-dev mariadb-server -y
sudo systemctl stop mysql
sudo rm -rf /var/lib/mysql/
sudo mysql_install_db --user=mysql --datadir=/var/lib/mysql/
cd /usr; sudo mysqld_safe --datadir='/var/lib/mysql/' --no-watch
sleep 10
sudo mysql <<EOF
CREATE DATABASE ddnet;
CREATE USER 'ddnet'@'localhost' IDENTIFIED BY 'thebestpassword';
GRANT ALL PRIVILEGES ON ddnet.* TO 'ddnet'@'localhost';
FLUSH PRIVILEGES;
EOF
- name: Prepare macOS
if: contains(matrix.os, 'macOS')
run: |
brew update || true
brew install pkg-config sdl2 ffmpeg ninja molten-vk vulkan-headers glslang spirv-tools rust || true
brew upgrade freetype
pip3 install --break-system-packages dmgbuild
echo /Library/Frameworks/Python.framework/Versions/3.12/bin >> $GITHUB_PATH
sudo rm -rf /Library/Developer/CommandLineTools
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
- name: Build in debug mode
run: |
mkdir debug
cd debug
${{ matrix.cmake-path }}cmake -E env ${{ matrix.cmake-init-env }} ${{ matrix.cmake-path }}cmake ${{ matrix.cmake-args }} -DCMAKE_BUILD_TYPE=Debug -Werror=dev -DDOWNLOAD_GTEST=ON -DDEV=ON -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=. ..
${{ matrix.cmake-path }}cmake --build . --config Debug --target everything ${{ matrix.build-args }}
- name: Test debug
run: |
cd debug
${{ matrix.cmake-path }}cmake -E env ${{ matrix.gtest-env }} ${{ matrix.cmake-path }}cmake --build . --config Debug --target run_tests ${{ matrix.build-args }}
- name: Run debug server
run: |
cd debug
./DDNet-Server shutdown
- name: Build in release mode
run: |
mkdir release
cd release
${{ matrix.cmake-path }}cmake -E env ${{ matrix.cmake-init-env }} ${{ matrix.cmake-path }}cmake ${{ matrix.cmake-args }} -DCMAKE_BUILD_TYPE=Release -Werror=dev -DDOWNLOAD_GTEST=ON -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=. ..
${{ matrix.cmake-path }}cmake --build . --config Release --target everything ${{ matrix.build-args }}
- name: Test release
run: |
cd release
${{ matrix.cmake-path }}cmake -E env ${{ matrix.gtest-env }} ${{ matrix.cmake-path }}cmake --build . --config Release --target run_tests ${{ matrix.build-args }}
- name: Run release server
run: |
cd release
./DDNet-Server shutdown
- name: Build headless client
if: contains(matrix.os, 'ubuntu-latest')
run: |
mkdir headless
cd headless
${{ matrix.cmake-path }}cmake --version
${{ matrix.cmake-path }}cmake -E env CXXFLAGS="--coverage -Werror" ${{ matrix.cmake-path }}cmake -E env LDFLAGS="--coverage -Werror" ${{ matrix.cmake-path }}cmake ${{ matrix.cmake-args }} -DHEADLESS_CLIENT=ON -DCMAKE_BUILD_TYPE=Debug -Werror=dev -DDOWNLOAD_GTEST=ON -DDEV=ON -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=. ..
${{ matrix.cmake-path }}cmake -E env RUSTFLAGS="-Clink-arg=--coverage" ${{ matrix.cmake-path }}cmake --build . --config Debug ${{ matrix.build-args }}
- name: Test headless client (unit tests)
if: contains(matrix.os, 'ubuntu-latest')
run: |
cd headless
${{ matrix.cmake-path }}cmake -E env RUSTFLAGS="-Clink-arg=--coverage" RUSTDOCFLAGS="-Clink-arg=--coverage" ${{ matrix.cmake-path }}cmake --build . --config Debug --target run_tests ${{ matrix.build-args }}
- name: Upload Codecov report (unit tests)
if: contains(matrix.os, 'ubuntu-latest')
uses: codecov/codecov-action@v4
with:
flags: unittests
- name: Test headless client (start & connect)
if: contains(matrix.os, 'ubuntu-latest')
run: |
cd headless
# Remove old coverage data:
find . -name '*.gcno' -o -name '*.gcda' -delete
./DDNet-Server &
./DDNet "cl_download_skins 0;connect localhost:8303;quit"
- name: Upload Codecov report (start & connect)
if: contains(matrix.os, 'ubuntu-latest')
uses: codecov/codecov-action@v4
with:
flags: startconnect
- name: Build in release mode with debug info and all features on
if: matrix.fancy
run: |
mkdir fancy
cd fancy
${{ matrix.cmake-path }}cmake -E env ${{ matrix.cmake-init-env }} ${{ matrix.cmake-path }}cmake ${{ matrix.cmake-args }} -DCMAKE_BUILD_TYPE=RelWithDebInfo -DDOWNLOAD_GTEST=ON -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=. -DANTIBOT=ON -DWEBSOCKETS=ON ..
${{ matrix.cmake-path }}cmake --build . --config RelWithDebInfo --target everything ${{ matrix.build-args }}
- name: Test fancy
if: matrix.fancy
run: |
cd fancy
${{ matrix.cmake-path }}cmake -E env ${{ matrix.gtest-env }} ${{ matrix.cmake-path }}cmake --build . --config RelWithDebInfo --target run_tests ${{ matrix.build-args }}
- name: Run fancy server
if: matrix.fancy
run: |
cd fancy
./DDNet-Server shutdown
- name: Run integration tests with Valgrind's Memcheck
if: contains(matrix.os, 'ubuntu-latest')
run: |
cd headless
# Remove old coverage data:
find . -name '*.gcno' -o -name '*.gcda' -delete
./integration_test.sh --valgrind-memcheck
- name: Upload Codecov report (integration tests)
if: contains(matrix.os, 'ubuntu-latest')
uses: codecov/codecov-action@v4
with:
flags: integrationtests
- name: Package
run: |
cd release
${{ matrix.cmake-path }}cmake --build . --config Release --target package_default ${{ matrix.build-args }}
mkdir artifacts
mv ${{ matrix.package-file }} artifacts
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ddnet-${{ matrix.os }}
path: release/artifacts