Drop NAM::instance() where it's not needed #537
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
pull_request: | |
types: [opened, reopened] | |
defaults: | |
run: | |
shell: bash | |
# A note on bash code style (specifically if's) | |
# - No attempt to be POSIX-compliant, it's Bash (4.x+) here | |
# - In if's, use [[ instead of [; BUT quote strings around and next to ${{ }} | |
# expansions because inside those expansions strings must always be quoted | |
# - Quotes: use "" only where shell "$VARIABLES" should be expanded; | |
# ${{ }} is expanded before feeding the script to Bash, therefore single | |
# quotes or even absense of any are enough '${{ }}' (but see above re if's) | |
jobs: | |
Prepare: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.generate.outputs.version }} | |
reftype: ${{ steps.generate.outputs.reftype }} | |
steps: | |
- id: generate | |
run: | | |
IFS=/ read -r ign type name merge <<<'${{ github.ref }}' # leading refs is (ign)ored | |
case $type in | |
heads) VERSION="${name:+$name-}ci${{ github.run_number }}" ;; | |
pull) VERSION="merge$name" ;; | |
tags) VERSION="$name" ;; | |
*) VERSION='ci{{ github.run_number }}' | |
esac | |
echo "Version string: $VERSION, ref type $type" | |
echo "version=$VERSION" >>$GITHUB_OUTPUT | |
echo "reftype=$type" >>$GITHUB_OUTPUT | |
Build: | |
runs-on: ${{ matrix.os }} | |
needs: Prepare | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ ubuntu-22.04, macos-11, windows-2019 ] | |
qt-version: [ 5, 6 ] | |
override-compiler: [ '', GCC ] # Defaults: MSVC on Windows, Clang elsewhere | |
composition: [ own-quotient, static, dynamic ] | |
exclude: | |
- os: ubuntu-22.04 | |
qt-version: 5 | |
composition: own-quotient # AppImage wants older Ubuntu (see below) | |
# Unsupported combinations | |
- os: windows-2019 | |
composition: dynamic | |
- os: macos-11 | |
composition: dynamic | |
- os: windows-2019 | |
override-compiler: GCC | |
- os: macos-11 | |
override-compiler: GCC | |
include: | |
- os: ubuntu-20.04 | |
qt-version: 5 | |
composition: own-quotient | |
- os: ubuntu-22.04 | |
qt-version: 6 | |
composition: own-quotient | |
check: appstream # Use one of faster paths for validation | |
- os: ubuntu-22.04 | |
qt-version: 5 # Use one variation with external libQuotient | |
composition: dynamic # to do CodeQL analysis (libQuotient is analysed | |
check: codeql # in its own repo) | |
env: | |
QTKEYCHAIN_REF: v0.13.2 | |
QUOTIENT_REF: dev | |
VERSION: ${{ needs.Prepare.outputs.version }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: ${{ matrix.composition == 'own-quotient' }} | |
- name: Install Qt | |
uses: jurplel/[email protected] | |
with: | |
version: "${{ matrix.qt-version == 6 && '6.4' || matrix.qt-version }}.*" | |
cache: true | |
cache-key-prefix: Qt | |
modules: ${{ matrix.qt-version == 6 && 'qtmultimedia' || '' }} | |
tools: "tools_ninja${{ !startsWith(matrix.os, 'macos') && ' tools_openssl_x64' || '' }}" | |
- name: Install other dependencies (macOS) | |
if: startsWith(matrix.os, 'macos') | |
run: brew install openssl | |
- name: Setup environment | |
run: | | |
if [[ '${{ matrix.override-compiler }}' == 'GCC' ]]; then | |
echo "CC=gcc" >>$GITHUB_ENV | |
echo "CXX=g++" >>$GITHUB_ENV | |
if [ '${{ matrix.qt-version }}' == '5' ]; then | |
# Patch Qt to avoid GCC tumbling over QTBUG-90568/QTBUG-91909 | |
sed -i 's/ThreadEngineStarter<void>(ThreadEngine<void> \*_threadEngine)/ThreadEngineStarter(ThreadEngine<void> \*_threadEngine)/' \ | |
$Qt5_DIR/include/QtConcurrent/qtconcurrentthreadengine.h | |
fi | |
elif [[ '${{ runner.os }}' != 'Windows' ]]; then | |
echo "CC=clang" >>$GITHUB_ENV | |
echo "CXX=clang++" >>$GITHUB_ENV | |
fi | |
echo "CMAKE_ARGS=-GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo \ | |
-DCMAKE_MAKE_PROGRAM=$IQTA_TOOLS/Ninja/ninja \ | |
-DCMAKE_PREFIX_PATH=~/.local \ | |
-DQuotient_ENABLE_E2EE=ON \ | |
-DOPENSSL_ROOT_DIR=${{ runner.os == 'macOS' && '`brew --prefix [email protected]`' || '$IQTA_TOOLS/OpenSSL/*/' }} \ | |
-DBUILD_SHARED_LIBS=${{ matrix.composition == 'dynamic' }} \ | |
-DBUILD_WITH_QT6=${{ matrix.qt-version == 6 }}" \ | |
>>$GITHUB_ENV | |
echo "QT_DIR=${Qt${{ matrix.qt-version }}_DIR}" >>$GITHUB_ENV | |
- name: Setup MSVC environment | |
uses: ilammy/msvc-dev-cmd@v1 | |
if: startsWith(matrix.os, 'windows') | |
with: | |
arch: x64 | |
- name: Get, build and install QtKeychain | |
run: | | |
git clone --depth=1 -b $QTKEYCHAIN_REF https://github.com/frankosterfeld/qtkeychain | |
cd qtkeychain | |
cmake -S . -B build $CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=~/.local | |
cmake --build build --target install | |
if [[ '${{ matrix.composition }}' == 'dynamic' ]]; then | |
QTKEYCHAIN_SO_PATH=$(dirname $(find ~/.local/lib* -name 'libqt?keychain.so')) | |
test -n "$QTKEYCHAIN_SO_PATH" | |
echo "DEP_SO_PATH=$QTKEYCHAIN_SO_PATH" >>$GITHUB_ENV | |
fi | |
- name: Get, build and install Olm | |
run: | | |
git clone --depth=1 https://gitlab.matrix.org/matrix-org/olm.git | |
cmake -S olm -B olm/build $CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=~/.local | |
cmake --build olm/build --target install | |
- name: Get, build and install libQuotient | |
if: matrix.composition != 'own-quotient' | |
run: | | |
git clone --depth=1 -b $QUOTIENT_REF https://github.com/quotient-im/libQuotient | |
cd libQuotient | |
cmake -S . -B build $CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=~/.local -DCMAKE_PREFIX_PATH=~/.local | |
cmake --build build --target install | |
if [[ '${{ matrix.composition }}' == 'dynamic' ]]; then | |
QUOTIENT_SO_PATH=$(dirname $(find ~/.local/lib* -name libQuotient*.so)) | |
test -n "$QUOTIENT_SO_PATH" | |
echo "DEP_SO_PATH=$DEP_SO_PATH:$QUOTIENT_SO_PATH" >>$GITHUB_ENV | |
fi | |
- name: Initialize CodeQL tools | |
if: matrix.check == 'codeql' | |
uses: github/codeql-action/init@v2 | |
with: | |
languages: cpp | |
# If you wish to specify custom queries, you can do so here or in a config file. | |
# By default, queries listed here will override any specified in a config file. | |
# Prefix the list here with "+" to use these queries and those in the config file. | |
# queries: ./path/to/local/query, your-org/your-repo/queries@main | |
- name: Configure Quaternion | |
run: | | |
if [[ '${{ runner.os }}' == 'Windows' ]]; then | |
# DESTDIR doesn't work (and is not necessary) on Windows, see | |
# https://cmake.org/cmake/help/latest/envvar/DESTDIR.html | |
# NB: Using ${{ runner.temp }} (or any absolute path?) for install | |
# root on Windows somehow confuses the shell code using it | |
# (because of the volume letter?) - therefore relative path here. | |
INSTALL_PATH=Quaternion-$VERSION | |
else | |
INSTALL_PATH=/usr | |
DESTDIR=$GITHUB_WORKSPACE/install | |
echo "DESTDIR=$DESTDIR" >>$GITHUB_ENV | |
fi | |
cmake -LA -S $GITHUB_WORKSPACE -B build $CMAKE_ARGS -DDEPLOY_VERBOSITY=$DEPLOY_VERBOSITY \ | |
-DCMAKE_INSTALL_PREFIX=$INSTALL_PATH | |
echo "FULL_INSTALL_PATH=$DESTDIR$INSTALL_PATH" >>$GITHUB_ENV | |
- name: Build and install Quaternion | |
run: cmake --build build --target install | |
- name: Perform CodeQL analysis | |
if: matrix.check == 'codeql' | |
uses: github/codeql-action/analyze@v2 | |
- name: Validate installation (Linux) | |
if: startsWith(matrix.os, 'ubuntu') | |
run: | | |
find $FULL_INSTALL_PATH -name 'quaternion_*.qm' | |
LD_LIBRARY_PATH=$DEP_SO_PATH:$QT_DIR/lib \ | |
$FULL_INSTALL_PATH/bin/quaternion -platform offscreen --version | |
if [[ '${{ matrix.check }}' == 'appstream' ]]; then | |
sudo apt-get -qq install flatpak | |
flatpak install --user -y https://flathub.org/repo/appstream/org.freedesktop.appstream-glib.flatpakref | |
flatpak run org.freedesktop.appstream-glib validate $FULL_INSTALL_PATH/share/metainfo/*.appdata.xml | |
fi | |
- name: Make a package | |
if: matrix.composition == 'own-quotient' && matrix.qt-version == 5 && matrix.override-compiler == '' | |
id: package | |
env: | |
DEPLOY_VERBOSITY: 1 | |
run: | | |
PACKAGE_STEM=quaternion-${{ needs.Prepare.outputs.version }} | |
case ${{ runner.os }} in | |
Linux) | |
sudo apt-get -qq install appstream libgstreamer-plugins-base1.0.0 \ | |
libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 \ | |
libxcb-render-util0 libxcb-shape0 libxcb-xinerama0 libxkbcommon-x11-0 | |
for f in linuxdeploy linuxdeploy-plugin-qt; do | |
wget -c -nv --directory-prefix=linuxdeploy \ | |
https://github.com/linuxdeploy/$f/releases/download/continuous/$f-x86_64.AppImage | |
chmod +x linuxdeploy/$f-x86_64.AppImage | |
done | |
# NB: $OUTPUT is both used in this script further below and | |
# propagated by linuxdeploy to appimagetool as the target path | |
export OUTPUT=$PACKAGE_STEM.AppImage | |
LD_LIBRARY_PATH=$QT_DIR/lib QMAKE=$QT_DIR/bin/qmake \ | |
QML_SOURCES_PATHS=$GITHUB_WORKSPACE/client/qml \ | |
linuxdeploy/linuxdeploy-x86_64.AppImage --appdir $DESTDIR \ | |
--plugin qt --output appimage | |
;; | |
macOS) | |
OUTPUT=$PACKAGE_STEM.dmg | |
cmake --build build --target image | |
mv build/quaternion.dmg $OUTPUT | |
;; | |
Windows) | |
rm -rf $FULL_INSTALL_PATH/{bearer,qmltooling} | |
ls -l $FULL_INSTALL_PATH/quaternion.exe # Fail if it's not there | |
OUTPUT=$PACKAGE_STEM.zip | |
7z a $OUTPUT $FULL_INSTALL_PATH | |
;; | |
esac | |
find $OUTPUT -size +10M | |
echo "path=$OUTPUT" >>$GITHUB_OUTPUT | |
- name: Store artefacts | |
if: steps.package.outputs.path != '' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: quaternion-${{ env.VERSION }}-${{ runner.os }} | |
path: ${{ steps.package.outputs.path }} | |
retention-days: 7 | |
Publish: | |
runs-on: ubuntu-latest | |
needs: [ Prepare, Build ] | |
strategy: | |
fail-fast: false | |
matrix: | |
type: [ macOS, Linux, Windows ] | |
steps: | |
- name: Retrieve artefacts | |
id: get-package | |
uses: actions/download-artifact@v3 | |
with: | |
name: quaternion-${{ needs.Prepare.outputs.version}}-${{ matrix.type }} | |
path: package | |
- name: Upload artefacts to Cloudsmith (interim builds) | |
if: needs.Prepare.outputs.reftype != 'tags' # Tags will go to GitHub Releases | |
uses: cloudsmith-io/[email protected] | |
with: | |
api-key: '${{ secrets.CLOUDSMITH_API_KEY }}' | |
format: raw | |
owner: quotient | |
repo: quaternion | |
file: "`find package -name '*.*'`" # Globs don't seem to work: https://github.com/cloudsmith-io/action/issues/21 | |
name: ${{ matrix.type }} | |
summary: CI builds of Quaternion, ${{ matrix.type }} | |
description: | | |
The builds produced by the continuous integration; only intended for testing, | |
not for production usage. No workability guarantees whatsoever. | |
version: ${{ needs.Prepare.outputs.version }} | |
republish: true | |
- name: Upload artefact to GitHub Releases (tag builds) | |
if: needs.Prepare.outputs.reftype == 'tags' | |
uses: ncipollo/release-action@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
artifacts: ${{ steps.get-package.outputs.download-path }}/* | |
# It tends to false-prerelease things but that's better than false-release them | |
prerelease: ${{ contains(needs.Prepare.outputs.version, '-') }} | |
allowUpdates: true | |
omitNameDuringUpdate: true | |
omitBodyDuringUpdate: true |