-
Notifications
You must be signed in to change notification settings - Fork 26
189 lines (175 loc) · 6.25 KB
/
build-test.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
name: build-test
on:
push:
branches:
- master
pull_request:
workflow_dispatch:
jobs:
build:
runs-on: ${{ matrix.os }}
continue-on-error: false
strategy:
fail-fast: false
matrix:
os: [windows-2022, macos-latest, ubuntu-22.04]
compiler: ['clang', 'gcc', 'msvc']
exclude:
- os: ubuntu-22.04
compiler: 'msvc'
- os: macos-latest
compiler: 'gcc'
- os: macos-latest
compiler: 'msvc'
- os: windows-2022
compiler: 'clang'
- os: windows-2022
compiler: 'gcc'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- uses: lukka/get-cmake@latest
- if: matrix.compiler == 'msvc'
uses: ilammy/msvc-dev-cmd@v1
#
# Install Packages (Ubuntu)
#
- if: contains( matrix.os, 'ubuntu' )
name: Install Packages for Ubuntu
run: |
sudo apt update -qq
sudo apt install -y build-essential git qt5-qmake libqt5opengl5-dev zlib1g-dev libssl-dev libminiupnpc-dev
- if: contains( matrix.os, 'ubuntu' ) && matrix.compiler == 'gcc'
name: Install GCC for Ubuntu
run: |
sudo apt install -y gcc-11 g++-11 lcov
echo "QMAKESPEC=linux-g++" >> $GITHUB_ENV
echo "CC=gcc-11" >> $GITHUB_ENV
echo "CXX=g++-11" >> $GITHUB_ENV
echo "MMAPPER_CMAKE_EXTRA=-DUSE_CODE_COVERAGE=true" >> $GITHUB_ENV
echo "COVERAGE=true" >> $GITHUB_ENV
- if: contains( matrix.os, 'ubuntu' ) && matrix.compiler == 'clang'
name: Install Clang for Ubuntu
run: |
sudo apt install -y clang-13 binutils
echo "QMAKESPEC=linux-clang" >> $GITHUB_ENV
echo "CC=clang-13" >> $GITHUB_ENV
echo "CXX=clang++-13" >> $GITHUB_ENV
echo "STYLE=true" >> $GITHUB_ENV
#
# Install Packages (Mac)
#
- if: runner.os == 'macOS'
name: Install Packages for Mac
run: |
brew install qt5 openssl\@1.1 lcov miniupnpc
brew link qt5 --force
echo "$(brew --prefix qt5)/bin" >> $GITHUB_PATH
echo "MMAPPER_CMAKE_EXTRA=-DUSE_CODE_COVERAGE=true -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl@1.1" >> $GITHUB_ENV
echo "COVERAGE=false" >> $GITHUB_ENV
#
# Install Packages (Windows)
#
- if: runner.os == 'Windows'
uses: jurplel/install-qt-action@v3
with:
version: 5.15.2
dir: 'C:\'
arch: win64_msvc2019_64
cache: true
tools: 'tools_opensslv3_x64'
#
# Build
#
- if: runner.os == 'Windows' && matrix.compiler == 'msvc'
name: Build MMapper for Windows
shell: cmd
run: |
mkdir -p ${{ github.workspace }}/artifact
mkdir -p build
cd build
cmake --version
cmake -DCMAKE_BUILD_TYPE=Debug -G "NMake Makefiles" -DCPACK_PACKAGE_DIRECTORY=${{ github.workspace }}/artifact -DUSE_UNITY_BUILD=false -DCMAKE_PREFIX_PATH="C:\Qt\5.12.2\msvc2019_64" -DOPENSSL_ROOT_DIR=C:/Qt/Tools/OpenSSLv3/Win_x64 -S .. || exit -1
cmake --build . -j %NUMBER_OF_PROCESSORS%
- 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' -DUSE_UNITY_BUILD=false -DCPACK_PACKAGE_DIRECTORY=${{ github.workspace }}/artifact $MMAPPER_CMAKE_EXTRA -S .. || exit -1
cmake --build .
#
# Run tests
#
- if: env.COVERAGE == 'true'
name: Prepare lcov counters
run: cd build && lcov --zerocounters --directory .
- name: Run unit tests
run: cd build && ctest -V --no-compress-output -T test
env:
QT_QPA_PLATFORM: offscreen
ASAN_OPTIONS: detect_leaks=0
- name: Transform test results from ctest to junit format
shell: pwsh
run: |
$XSLInputElement = New-Object System.Xml.Xsl.XslCompiledTransform
$XSLInputElement.Load("https://raw.githubusercontent.com/rpavlik/jenkins-ctest-plugin/master/ctest-to-junit.xsl")
$XSLInputElement.Transform((Resolve-Path .\build\Testing\*\Test.xml), (Join-Path (Resolve-Path .) "ctest-to-junit-results.xml"))
- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: test-results ${{ matrix.os }} ${{ matrix.compiler }}
path: ctest-to-junit-results.xml
- if: env.COVERAGE == 'true'
name: Run lcov
run: |
cd build
lcov --directory . --capture --output-file coverage.info
lcov --list coverage.info
lcov --remove coverage.info '/usr/*' --output-file filtered.info
- if: env.COVERAGE == 'true'
uses: codecov/codecov-action@v4
with:
files: ./build/filtered.info
- 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 == 'macOS'
name: Upload Package for Mac
uses: actions/upload-artifact@v4
with:
name: build-test Mac ${{ matrix.os }} ${{ matrix.compiler }}
path: ${{ github.workspace }}/artifact/*.dmg
- if: contains( matrix.os, 'ubuntu' )
name: Upload Package for Ubuntu
uses: actions/upload-artifact@v4
with:
name: build-test Linux ${{ matrix.os }} ${{ matrix.compiler }}
path: ${{ github.workspace }}/artifact/*.deb
- if: runner.os == 'Windows'
name: Upload Package for Windows
uses: actions/upload-artifact@v4
with:
name: build-test Windows ${{ matrix.os }} ${{ matrix.compiler }}
path: ${{ github.workspace }}/artifact/*.exe