Skip to content

test CI with clang-format #717

test CI with clang-format

test CI with clang-format #717

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-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/[email protected]" >> $GITHUB_ENV
echo "COVERAGE=false" >> $GITHUB_ENV
#
# Install Packages (Windows)
#
- if: runner.os == 'Windows'
uses: jurplel/install-qt-action@v4
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