Skip to content

fix build

fix build #754

Workflow file for this run

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-24.04]
compiler: ['clang', 'gcc', 'msvc']
exclude:
- os: ubuntu-24.04
compiler: 'msvc'
- os: macos-latest
compiler: 'gcc'
- os: macos-latest
compiler: 'msvc'
- os: windows-2022
compiler: 'clang'
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-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" >> $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-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
#
# 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' && matrix.compiler == 'msvc'
name: Install Qt for Windows (MSVC)
uses: jurplel/install-qt-action@v4
with:
version: 5.15.2
dir: 'C:\'
arch: win64_msvc2019_64
cache: true
- if: runner.os == 'Windows' && matrix.compiler == 'gcc'
name: Install Qt for Windows (MinGW)
uses: jurplel/install-qt-action@v4
with:
version: 5.15.2
dir: 'C:\'
arch: win64_mingw81
cache: true
tools: 'tools_mingw1310'
- if: runner.os == 'Windows'
name: Install Packages for Windows
uses: crazy-max/ghaction-chocolatey@v3
with:
args: install openssl --version=1.1.1.2100
#
# Build
#
- if: runner.os == 'Windows'
name: Build MMapper for Windows
shell: pwsh
run: |
xcopy "C:\Program Files\OpenSSL" "C:\OpenSSL" /E /I /H /K /Y
mkdir ${{ github.workspace }}/artifact
mkdir build
cd build
cmake --version
# Compiler-specific logic
if ('${{ matrix.compiler }}' -eq 'msvc') {
$generator = "NMake Makefiles"
$qtPath = "C:\Qt\5.12.2\msvc2019_64"
} elseif ('${{ matrix.compiler }}' -eq 'gcc') {
$generator = "MinGW Makefiles"
$qtPath = "C:\Qt\5.12.2\mingw81_64"
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"
}
cmake -DCMAKE_BUILD_TYPE=Debug -G $generator -DCPACK_PACKAGE_DIRECTORY=${{ github.workspace }}/artifact -DUSE_UNITY_BUILD=false -DCMAKE_PREFIX_PATH=$qtPath -DOPENSSL_ROOT_DIR=C:/OpenSSL/ -S .. || exit -1
cmake --build . -j $env: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@v5
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