forked from MUME/MMapper
-
Notifications
You must be signed in to change notification settings - Fork 0
273 lines (263 loc) · 10.2 KB
/
Copy pathbuild-test.yml
File metadata and controls
273 lines (263 loc) · 10.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
267
268
269
270
271
272
273
name: build-test
on:
push:
branches:
- master
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
jobs:
build:
runs-on: ${{ matrix.os }}
continue-on-error: false
permissions:
id-token: write
contents: read
strategy:
fail-fast: false
matrix:
os: [windows-2022, macos-15, ubuntu-latest]
compiler: ['clang', 'gcc', 'msvc']
exclude:
- os: ubuntu-latest
compiler: 'msvc'
- os: macos-15
compiler: 'gcc'
- os: macos-15
compiler: 'msvc'
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
submodules: true
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
create-symlink: ${{ runner.os != 'Windows' }}
key: ${{ github.job }}-${{ matrix.os }}-${{ matrix.compiler }}
variant: ${{ matrix.compiler == 'msvc' && 'sccache' || 'ccache' }}
- if: runner.os == 'Windows' || runner.os == 'macOS'
uses: lukka/get-cmake@latest
- if: matrix.compiler == 'msvc'
uses: ilammy/msvc-dev-cmd@v1
#
# Install Packages (Ubuntu)
#
- if: runner.os == 'Linux'
name: Install Packages for Ubuntu
run: |
sudo apt update -qq
sudo apt install -y \
qt6-base-dev qt6-base-dev-tools libqt6opengl6-dev libqt6websockets6-dev \
qt6-multimedia-dev libqt6multimedia6 qt6-svg-dev \
libgl1-mesa-dev qtkeychain-qt6-dev build-essential cmake ninja-build mold git \
zlib1g-dev libssl-dev
- if: runner.os == 'Linux' && matrix.compiler == 'gcc'
name: Install GCC for Ubuntu
run: |
sudo apt install -y gcc-13 g++-13 lcov
echo "QMAKESPEC=linux-g++" >> $GITHUB_ENV
echo "CC=gcc-13" >> $GITHUB_ENV
echo "CXX=g++-13" >> $GITHUB_ENV
echo "MMAPPER_CMAKE_EXTRA=-DUSE_CODE_COVERAGE=true -DUSE_MOLD=true -DPACKAGE_TYPE=Deb" >> $GITHUB_ENV
echo "COVERAGE=true" >> $GITHUB_ENV
echo "GCOV_TOOL=gcov-13" >> $GITHUB_ENV
- if: runner.os == 'Linux' && matrix.compiler == 'clang'
name: Install Clang for Ubuntu
run: |
sudo apt install -y clang-18 binutils
echo "QMAKESPEC=linux-clang" >> $GITHUB_ENV
echo "CC=clang-18" >> $GITHUB_ENV
echo "CXX=clang++-18" >> $GITHUB_ENV
echo "STYLE=true" >> $GITHUB_ENV
echo "MMAPPER_CMAKE_EXTRA=-DUSE_MOLD=true -DPACKAGE_TYPE=Deb" >> $GITHUB_ENV
#
# Install Packages (Mac)
#
- if: runner.os == 'macOS'
name: Install Qt for Mac
uses: jurplel/install-qt-action@v4
with:
version: 6.8.3
arch: clang_64
cache: true
modules: 'qtwebsockets qtmultimedia'
- if: runner.os == 'macOS'
name: Install Packages for Mac
run: |
brew install lcov
echo "MMAPPER_CMAKE_EXTRA=-DCMAKE_PREFIX_PATH=$QT_ROOT_DIR -DUSE_CODE_COVERAGE=true -DPACKAGE_TYPE=Dmg" >> $GITHUB_ENV
#
# Install Packages (Windows)
#
- if: runner.os == 'Windows' && matrix.compiler == 'msvc'
name: Install Qt for Windows (MSVC)
uses: jurplel/install-qt-action@v4
with:
version: '6.8.3'
dir: 'C:\'
arch: win64_msvc2022_64
cache: true
modules: 'qtwebsockets qtmultimedia'
- if: runner.os == 'Windows' && matrix.compiler == 'gcc'
name: Install Qt for Windows (MinGW)
uses: jurplel/install-qt-action@v4
with:
version: '6.8.3'
dir: 'C:\'
arch: win64_mingw
cache: true
modules: 'qtwebsockets qtmultimedia'
tools: 'tools_mingw1310'
- if: runner.os == 'Windows' && matrix.compiler == 'clang'
name: Install Qt for Windows (LLVM-MinGW)
uses: jurplel/install-qt-action@v4
with:
version: '6.8.3'
dir: 'C:\'
arch: win64_llvm_mingw
cache: true
modules: 'qtwebsockets qtmultimedia'
tools: 'tools_llvm_mingw1706'
#
# Build
#
- if: runner.os == 'Windows'
name: Build MMapper for Windows
shell: pwsh
run: |
mkdir ${{ github.workspace }}/artifact
mkdir build
cd build
cmake --version
if ('${{ matrix.compiler }}' -eq 'gcc') {
echo "C:/Qt/Tools/mingw1310_64/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
$env:PATH = "C:\Qt\Tools\mingw1310_64\bin;$env:PATH"
}
if ('${{ matrix.compiler }}' -eq 'clang') {
$llvmDir = Get-ChildItem -Path "C:\Qt\Tools" -Filter "llvm-mingw*" -Directory | Sort-Object Name -Descending | Select-Object -First 1
if ($null -ne $llvmDir) {
$llvmBin = Join-Path $llvmDir.FullName "bin"
echo "$($llvmBin.Replace('\', '/'))" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
$env:PATH = "$llvmBin;$env:PATH"
$env:CC = Join-Path $llvmBin "clang.exe"
$env:CXX = Join-Path $llvmBin "clang++.exe"
} else {
Write-Error "LLVM-MinGW toolchain not found"
exit 1
}
}
$packageDir = ($env:GITHUB_WORKSPACE -replace '\\', '/') + "/artifact"
$launcher = ${{ matrix.compiler == 'msvc' && 'sccache' || 'ccache' }}
cmake -DCMAKE_BUILD_TYPE=Debug -G 'Ninja' -DWITH_MAP=OFF -DCPACK_PACKAGE_DIRECTORY="$packageDir" -DCMAKE_PREFIX_PATH=$env:QT_ROOT_DIR -DWITH_WEBSOCKET=ON -DWITH_QTKEYCHAIN=ON -DPACKAGE_TYPE=Nsis -DCMAKE_C_COMPILER_LAUNCHER="$launcher" -DCMAKE_CXX_COMPILER_LAUNCHER="$launcher" -S .. || exit 1
cmake --build . --parallel
- if: runner.os == 'Linux' || runner.os == 'macOS'
name: Build MMapper for Linux and Mac
run: |
mkdir -p build ${{ github.workspace }}/artifact
cd build
cmake --version
cmake -DCMAKE_BUILD_TYPE=Debug -G 'Ninja' -DWITH_MAP=OFF -DCPACK_PACKAGE_DIRECTORY=${{ github.workspace }}/artifact $MMAPPER_CMAKE_EXTRA -DWITH_WEBSOCKET=ON -DWITH_QTKEYCHAIN=ON -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -S .. || exit -1
cmake --build . --parallel
#
# Run tests
#
- name: Run unit tests
run: cd build && ctest -V --no-compress-output -T test --output-junit ../ctest-to-junit-results.xml
env:
QT_QPA_PLATFORM: offscreen
ASAN_OPTIONS: detect_leaks=0
- name: Upload test results
uses: actions/upload-artifact@v7
with:
name: test-results ${{ matrix.os }} ${{ matrix.compiler }}
path: ctest-to-junit-results.xml
- if: env.COVERAGE == 'true' && !cancelled()
name: Run lcov
run: |
lcov --version
gcov --version
lcov --directory build --capture --base-directory $(pwd) --output-file build/coverage.info --gcov-tool ${GCOV_TOOL:-gcov} --no-external --ignore-errors mismatch --ignore-errors negative --ignore-errors gcov --ignore-errors inconsistent --rc geninfo_unexecuted_blocks=1
lcov --list build/coverage.info --ignore-errors inconsistent
lcov --remove build/coverage.info '*/tests/*' '*/external/*' '*/build/*' --output-file build/filtered.info --ignore-errors unused --ignore-errors inconsistent
- if: env.COVERAGE == 'true' && !cancelled()
uses: codecov/codecov-action@v7
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./build/filtered.info
fail_ci_if_error: false
continue-on-error: true
- if: env.STYLE == 'true'
name: Text Encoding Sanity Check
run: |
cd build
if [[ -n $(nm -C src/mmapper | grep -w 'QString::\(to\|from\)StdString') ]]; then
nm -C src/mmapper | grep -w 'QString::\(to\|from\)StdString'
echo
echo
echo "Please avoid using QString::fromStdString() and QString::toStdString()"
echo
echo "Both functions assume the user wants utf8, but MMapper almost always expects"
echo "std::string to have latin1 encoding."
echo
echo "Convert any uses to corresponding functions in TextUtils e.g. ::toQStringUtf8()"
exit -1
fi
#
# Package
#
- name: Package MMapper
run: cd build && cpack
- if: runner.os == 'Linux'
name: Get Linux package file base name
id: get_linux_package_name
run: |
PACKAGE_FILE=$(ls ${{ github.workspace }}/artifact/*.deb)
PACKAGE_BASENAME=$(basename "$PACKAGE_FILE" | sed 's/\./-/g')
echo "PACKAGE_BASENAME=$PACKAGE_BASENAME" >> $GITHUB_OUTPUT
- if: runner.os == 'macOS'
name: Get Mac package file base name
id: get_mac_package_name
run: |
PACKAGE_FILE=$(ls ${{ github.workspace }}/artifact/*.dmg)
PACKAGE_BASENAME=$(basename "$PACKAGE_FILE" | sed 's/\./-/g')
echo "PACKAGE_BASENAME=$PACKAGE_BASENAME" >> $GITHUB_OUTPUT
- if: runner.os == 'Windows'
name: Get Windows package file base name
id: get_windows_package_name
shell: pwsh
run: |
$packageFile = Get-ChildItem -Path "${{ github.workspace }}/artifact/*.exe" | Select-Object -First 1
$packageBasename = $packageFile.BaseName -replace '\.', '-'
"PACKAGE_BASENAME=$packageBasename" >> $env:GITHUB_OUTPUT
- if: runner.os == 'macOS'
name: Upload Package for Mac
uses: actions/upload-artifact@v7
with:
name: debug-${{ steps.get_mac_package_name.outputs.PACKAGE_BASENAME }}
path: ${{ github.workspace }}/artifact/*.dmg*
- if: runner.os == 'Linux'
name: Upload Package for Ubuntu
uses: actions/upload-artifact@v7
with:
name: debug-${{ matrix.compiler }}-${{ steps.get_linux_package_name.outputs.PACKAGE_BASENAME }}
path: ${{ github.workspace }}/artifact/*.deb*
- if: runner.os == 'Windows'
name: Upload Package for Windows
uses: actions/upload-artifact@v7
with:
name: debug-${{ matrix.compiler }}-${{ steps.get_windows_package_name.outputs.PACKAGE_BASENAME }}
path: ${{ github.workspace }}/artifact/*.exe*
report:
name: Test Report
runs-on: ubuntu-latest
needs: build
steps:
- uses: dorny/test-reporter@v3
with:
artifact: /test-results (.*)/
name: Test Report $1
path: '*.xml'
reporter: java-junit