From a4f0071395939a93bcb3afd72085415a25216701 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Tue, 14 Jun 2022 10:28:51 +0200 Subject: CI: bump used versions for GitHub Actions Also, use MSVC 2019 on Windows. --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 172c027f..212273bd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,12 +48,12 @@ jobs: compiler: MSVC platform: x64 qt-version: '5.12.12' - qt-arch: win64_msvc2017_64 + qt-arch: win64_msvc2019_64 - os: windows-2019 compiler: MSVC platform: x64 qt-version: '5.12.12' - qt-arch: win64_msvc2017_64 + qt-arch: win64_msvc2019_64 update-api: update-api env: @@ -72,7 +72,7 @@ jobs: key: ${{ runner.os }}${{ matrix.platform }}-Qt${{ matrix.qt-version }}-cache - name: Install Qt - uses: jurplel/install-qt-action@v2.11.1 + uses: jurplel/install-qt-action@v2.14.0 with: version: ${{ matrix.qt-version }} arch: ${{ matrix.qt-arch }} @@ -192,7 +192,7 @@ jobs: - name: Initialize CodeQL tools if: env.CODEQL_ANALYSIS - uses: github/codeql-action/init@v1 + 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. @@ -235,7 +235,7 @@ jobs: - name: Perform CodeQL analysis if: env.CODEQL_ANALYSIS - uses: github/codeql-action/analyze@v1 + uses: github/codeql-action/analyze@v2 - name: Run sonar-scanner if: matrix.sonar != '' -- cgit v1.2.3 From b55c110ecbca5ad41ac9ccb5647836709ac8f4a8 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Tue, 14 Jun 2022 11:40:34 +0200 Subject: CI: Switch to Qt 5.15 and introduce Qt 6 options Qt 6 builds are allowed to fail for now. --- .github/workflows/ci.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 212273bd..d46cfb6c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,14 +14,14 @@ concurrency: ci-${{ github.ref }} jobs: CI: runs-on: ${{ matrix.os }} - continue-on-error: false + continue-on-error: ${{ matrix.qt-version != '5.15.2' }} # Qt 6 will fail for now strategy: fail-fast: false max-parallel: 1 matrix: os: [ ubuntu-20.04, macos-10.15 ] compiler: [ Clang ] # GCC builds are added individually below - qt-version: [ '5.12.12' ] + qt-version: [ '5.15.2', '6.3.1' ] # Not using binary values here, to make the job captions more readable e2ee: [ '', e2ee ] update-api: [ '', update-api ] @@ -29,6 +29,8 @@ jobs: platform: [ '' ] qt-arch: [ '' ] exclude: + - qt-version: '6.3.1' + update-api: update-api - os: windows-2019 e2ee: e2ee # Not supported by the current CI script - os: macos-10.15 @@ -36,23 +38,23 @@ jobs: include: - os: ubuntu-latest compiler: GCC - qt-version: '5.12.12' + qt-version: '5.15.2' e2ee: e2ee sonar: sonar - os: ubuntu-20.04 compiler: GCC - qt-version: '5.12.12' + qt-version: '5.15.2' e2ee: e2ee update-api: update-api - os: windows-2019 compiler: MSVC platform: x64 - qt-version: '5.12.12' + qt-version: '5.15.2' qt-arch: win64_msvc2019_64 - os: windows-2019 compiler: MSVC platform: x64 - qt-version: '5.12.12' + qt-version: '5.15.2' qt-arch: win64_msvc2019_64 update-api: update-api -- cgit v1.2.3 From da5156f5e2da08123549b554d9eafcf366fa4e11 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Tue, 14 Jun 2022 18:13:39 +0200 Subject: Rearrange CI jobs to spend time more efficiently - CodeQL analysis was executed on every job that ran Clang, humping the total execution time by 10+ minutes alone. Now it only runs on a single job. - libolm is no more compiled but installed from the repo, along with libssl-dev; and both are installed in the same transaction as ninja and valgrind, shaving out one apt transaction - One more Windows job has been added to test building with Qt 6.3.1 on that OS. - Qt version is pushed earlier in the job matrix, as it becomes more significant than the compiler for a given platform. --- .github/workflows/ci.yml | 144 +++++++++++++++++++++++------------------------ 1 file changed, 71 insertions(+), 73 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d46cfb6c..ab581238 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,43 +20,59 @@ jobs: max-parallel: 1 matrix: os: [ ubuntu-20.04, macos-10.15 ] - compiler: [ Clang ] # GCC builds are added individually below qt-version: [ '5.15.2', '6.3.1' ] + compiler: [ LLVM ] # Not using binary values here, to make the job captions more readable e2ee: [ '', e2ee ] update-api: [ '', update-api ] - sonar: [ '' ] + static-analysis: [ '' ] platform: [ '' ] qt-arch: [ '' ] exclude: - qt-version: '6.3.1' - update-api: update-api - - os: windows-2019 - e2ee: e2ee # Not supported by the current CI script + update-api: update-api # Generated code is not specific to Qt version + - os: ubuntu-20.04 + e2ee: e2ee # Will be re-added with static analysis below + # TODO: Enable E2EE on Windows and macOS - os: macos-10.15 - e2ee: e2ee # Missing OpenSSL + e2ee: e2ee include: + - os: windows-2019 + qt-version: '5.15.2' + compiler: MSVC + platform: x64 + qt-arch: win64_msvc2019_64 + - os: ubuntu-20.04 + qt-version: '5.15.2' + compiler: LLVM + e2ee: e2ee + static-analysis: codeql - os: ubuntu-latest - compiler: GCC qt-version: '5.15.2' + compiler: GCC e2ee: e2ee - sonar: sonar + static-analysis: sonar - os: ubuntu-20.04 - compiler: GCC qt-version: '5.15.2' + compiler: GCC e2ee: e2ee update-api: update-api + - os: ubuntu-20.04 + qt-version: '5.15.2' + compiler: LLVM + update-api: update-api - os: windows-2019 + qt-version: '6.3.1' compiler: MSVC + # e2ee: e2ee # TODO platform: x64 - qt-version: '5.15.2' qt-arch: win64_msvc2019_64 - os: windows-2019 + qt-version: '5.15.2' compiler: MSVC + update-api: update-api platform: x64 - qt-version: '5.15.2' qt-arch: win64_msvc2019_64 - update-api: update-api env: SONAR_SERVER_URL: 'https://sonarcloud.io' @@ -66,44 +82,14 @@ jobs: with: fetch-depth: 0 - - name: Cache Qt - id: cache-qt - uses: actions/cache@v2 - with: - path: ${{ runner.workspace }}/Qt - key: ${{ runner.os }}${{ matrix.platform }}-Qt${{ matrix.qt-version }}-cache - - - name: Install Qt - uses: jurplel/install-qt-action@v2.14.0 - with: - version: ${{ matrix.qt-version }} - arch: ${{ matrix.qt-arch }} - cached: ${{ steps.cache-qt.outputs.cache-hit }} - - - name: Install Ninja (macOS/Windows) - if: ${{ !startsWith(matrix.os, 'ubuntu') }} - uses: seanmiddleditch/gha-setup-ninja@v3 - - - name: Install Ninja and Valgrind (Linux) - if: startsWith(matrix.os, 'ubuntu') - run: | - sudo apt-get -qq install ninja-build valgrind - echo "VALGRIND=valgrind --tool=memcheck --leak-check=yes --gen-suppressions=all --suppressions=$GITHUB_WORKSPACE/quotest/.valgrind.supp" >>$GITHUB_ENV - - name: Setup build environment run: | - if [ "${{ matrix.compiler }}" == "GCC" ]; then - CXX_VERSION_POSTFIX='-10' - echo "CC=gcc$CXX_VERSION_POSTFIX" >>$GITHUB_ENV - echo "CXX=g++$CXX_VERSION_POSTFIX" >>$GITHUB_ENV - elif [[ '${{ matrix.compiler }}' == 'Clang' ]]; then - if [[ '${{ runner.os }}' == 'Linux' ]]; then - CXX_VERSION_POSTFIX='-11' - # Do CodeQL analysis on one of Linux branches - echo "CODEQL_ANALYSIS=true" >>$GITHUB_ENV - fi - echo "CC=clang$CXX_VERSION_POSTFIX" >>$GITHUB_ENV - echo "CXX=clang++$CXX_VERSION_POSTFIX" >>$GITHUB_ENV + if [ '${{ matrix.compiler }}' == 'GCC' ]; then + echo "CC=gcc-10" >>$GITHUB_ENV + echo "CXX=g++-10" >>$GITHUB_ENV + elif [[ '${{ runner.os }}' != 'Windows' ]]; then + echo "CC=clang" >>$GITHUB_ENV + echo "CXX=clang++" >>$GITHUB_ENV fi if grep -q 'refs/tags' <<<'${{ github.ref }}'; then VERSION="$(git describe --tags)" @@ -112,20 +98,18 @@ jobs: else VERSION="$(git describe --all --contains)-ci${{ github.run_number }}-$(git rev-parse --short HEAD)" fi - echo "QUOTEST_ORIGIN=$VERSION @ ${{ runner.os }}/${{ matrix.compiler }}" >>$GITHUB_ENV - # Build libQuotient as a shared library across platforms but also - # check the static configuration somewhere + echo "QUOTEST_ORIGIN=$VERSION @ ${{ runner.os }}/Qt-${{ matrix.qt-version }}/${{ matrix.compiler }}" >>$GITHUB_ENV + CMAKE_ARGS="-G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DBUILD_SHARED_LIBS=${{ runner.os == 'Linux' }} \ -DCMAKE_INSTALL_PREFIX=~/.local \ -DCMAKE_PREFIX_PATH=~/.local \ -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON" - if [ -n "${{ matrix.sonar }}" ]; then + if [ '${{ matrix.static-analysis }}' == 'sonar' ]; then mkdir -p $HOME/.sonar CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_CXX_FLAGS=--coverage" - echo "COV=gcov$CXX_VERSION_POSTFIX" >>$GITHUB_ENV fi echo "CMAKE_ARGS=$CMAKE_ARGS" >>$GITHUB_ENV @@ -139,14 +123,42 @@ jobs: cmake -E make_directory ${{ runner.workspace }}/build echo "BUILD_PATH=${{ runner.workspace }}/build/libQuotient" >>$GITHUB_ENV - - name: Setup MSVC environment + - name: Cache Qt + id: cache-qt + uses: actions/cache@v2 + with: + path: ${{ runner.workspace }}/Qt + key: ${{ runner.os }}${{ matrix.platform }}-Qt${{ matrix.qt-version }}-cache + + - name: Install Qt + uses: jurplel/install-qt-action@v2.14.0 + with: + version: ${{ matrix.qt-version }} + arch: ${{ matrix.qt-arch }} + cached: ${{ steps.cache-qt.outputs.cache-hit }} + + - name: Install Ninja (macOS/Windows) + if: ${{ !startsWith(matrix.os, 'ubuntu') }} + uses: seanmiddleditch/gha-setup-ninja@v3 + + - name: Install dependencies (Linux) + if: startsWith(matrix.os, 'ubuntu') + run: | + if [ -n "${{ matrix.e2ee }}" ]; then + EXTRA_DEPS="libssl-dev libolm-dev" + echo "QUOTEST_ORIGIN=$QUOTEST_ORIGIN with E2EE" >>$GITHUB_ENV + fi + sudo apt-get -qq install ninja-build valgrind $EXTRA_DEPS + echo "VALGRIND=valgrind --tool=memcheck --leak-check=yes --gen-suppressions=all --suppressions=$GITHUB_WORKSPACE/quotest/.valgrind.supp" >>$GITHUB_ENV + + - name: Setup MSVC uses: ilammy/msvc-dev-cmd@v1 if: matrix.compiler == 'MSVC' with: arch: ${{ matrix.platform }} - name: Download and set up Sonar Cloud tools - if: matrix.sonar != '' + if: matrix.static-analysis == 'sonar' env: SONAR_SCANNER_VERSION: 4.6.2.2472 run: | @@ -159,20 +171,6 @@ jobs: unzip -o sonar-scanner-cli*.zip popd - - name: Install OpenSSL - if: ${{ contains(matrix.os, 'ubuntu') && matrix.e2ee }} - run: | - sudo apt-get install libssl-dev - - - name: Build and install olm - if: matrix.e2ee - working-directory: ${{ runner.workspace }} - run: | - git clone https://gitlab.matrix.org/matrix-org/olm.git - cmake -S olm -B build/olm $CMAKE_ARGS - cmake --build build/olm --target install - echo "QUOTEST_ORIGIN=$QUOTEST_ORIGIN with E2EE" >>$GITHUB_ENV - - name: Build and install QtKeychain run: | cd .. @@ -193,7 +191,7 @@ jobs: echo "QUOTEST_ORIGIN=$QUOTEST_ORIGIN with API files regeneration" >>$GITHUB_ENV - name: Initialize CodeQL tools - if: env.CODEQL_ANALYSIS + if: matrix.static-analysis == 'codeql' uses: github/codeql-action/init@v2 with: languages: cpp @@ -236,18 +234,18 @@ jobs: timeout-minutes: 4 # quotest is supposed to finish within 3 minutes, actually - name: Perform CodeQL analysis - if: env.CODEQL_ANALYSIS + if: matrix.static-analysis == 'codeql' uses: github/codeql-action/analyze@v2 - name: Run sonar-scanner - if: matrix.sonar != '' + if: matrix.static-analysis == 'sonar' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} run: | mkdir .coverage && pushd .coverage find $BUILD_PATH -name '*.gcda' -print0 \ - | xargs -0 $COV -s $GITHUB_WORKSPACE -pr + | xargs -0 gcov -s $GITHUB_WORKSPACE -pr # Coverage of the test source code is not tracked, as it is always 100% # (if not, some tests failed and broke the build at an earlier stage) rm -f quotest* autotests* -- cgit v1.2.3 From 2504e6e5f216e34fc9aabfda0c462b1b37620a5e Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Fri, 17 Jun 2022 10:40:49 +0200 Subject: Further fix building with Qt 6 Also: build with Qt 6 first, so that it fails sooner. --- .github/workflows/ci.yml | 5 +++-- lib/accountregistry.h | 25 +++++++++++++------------ lib/avatar.cpp | 8 ++++---- lib/connection.cpp | 4 ++-- lib/room.cpp | 4 ++-- 5 files changed, 24 insertions(+), 22 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab581238..f03af94b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: max-parallel: 1 matrix: os: [ ubuntu-20.04, macos-10.15 ] - qt-version: [ '5.15.2', '6.3.1' ] + qt-version: [ '6.3.1', '5.15.2' ] compiler: [ LLVM ] # Not using binary values here, to make the job captions more readable e2ee: [ '', e2ee ] @@ -105,7 +105,8 @@ jobs: -DBUILD_SHARED_LIBS=${{ runner.os == 'Linux' }} \ -DCMAKE_INSTALL_PREFIX=~/.local \ -DCMAKE_PREFIX_PATH=~/.local \ - -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON" + -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON \ + -DBUILD_WITH_QT6=${{ startsWith(matrix.qt-version, '6') }}" if [ '${{ matrix.static-analysis }}' == 'sonar' ]; then mkdir -p $HOME/.sonar diff --git a/lib/accountregistry.h b/lib/accountregistry.h index 38cfe6c6..9560688e 100644 --- a/lib/accountregistry.h +++ b/lib/accountregistry.h @@ -31,8 +31,9 @@ class QUOTIENT_API AccountRegistry : public QAbstractListModel, /// Can be used to inform the user or to show a login screen if size() == 0 and no accounts are loaded Q_PROPERTY(QStringList accountsLoading READ accountsLoading NOTIFY accountsLoadingChanged) public: - using const_iterator = QVector::const_iterator; - using const_reference = QVector::const_reference; + using vector_t = QVector; + using const_iterator = vector_t::const_iterator; + using const_reference = vector_t::const_reference; enum EventRoles { AccountRole = Qt::UserRole + 1, @@ -42,24 +43,24 @@ public: [[deprecated("Use Accounts variable instead")]] // static AccountRegistry& instance(); - // Expose most of QVector's const-API but only provide add() and drop() + // Expose most of vector_t's const-API but only provide add() and drop() // for changing it. In theory other changing operations could be supported // too; but then boilerplate begin/end*() calls has to be tucked into each // and this class gives no guarantees on the order of entries, so why care. - const QVector& accounts() const { return *this; } + const vector_t& accounts() const { return *this; } void add(Connection* a); void drop(Connection* a); - const_iterator begin() const { return QVector::begin(); } - const_iterator end() const { return QVector::end(); } - const_reference front() const { return QVector::front(); } - const_reference back() const { return QVector::back(); } + const_iterator begin() const { return vector_t::begin(); } + const_iterator end() const { return vector_t::end(); } + const_reference front() const { return vector_t::front(); } + const_reference back() const { return vector_t::back(); } bool isLoggedIn(const QString& userId) const; Connection* get(const QString& userId); - using QVector::isEmpty, QVector::empty; - using QVector::size, QVector::count, QVector::capacity; - using QVector::cbegin, QVector::cend, QVector::contains; + using vector_t::isEmpty, vector_t::empty; + using vector_t::size, vector_t::count, vector_t::capacity; + using vector_t::cbegin, vector_t::cend, vector_t::contains; // QAbstractItemModel interface implementation @@ -88,4 +89,4 @@ private: inline QUOTIENT_API AccountRegistry Accounts {}; inline AccountRegistry& AccountRegistry::instance() { return Accounts; } -} +} // namespace Quotient diff --git a/lib/avatar.cpp b/lib/avatar.cpp index 9304a3de..13de99bf 100644 --- a/lib/avatar.cpp +++ b/lib/avatar.cpp @@ -39,7 +39,7 @@ public: // The below are related to image caching, hence mutable mutable QImage _originalImage; - mutable std::vector> _scaledImages; + mutable std::vector> _scaledImages; mutable QSize _requestedSize; mutable enum { Unknown, Cache, Network, Banned } _imageSource = Unknown; mutable QPointer _thumbnailRequest = nullptr; @@ -124,9 +124,9 @@ QImage Avatar::Private::get(Connection* connection, QSize size, }); } - for (const auto& p : _scaledImages) - if (p.first == size) - return p.second; + for (const auto& [scaledSize, scaledImage] : _scaledImages) + if (scaledSize == size) + return scaledImage; auto result = _originalImage.isNull() ? QImage() : _originalImage.scaled(size, Qt::KeepAspectRatio, diff --git a/lib/connection.cpp b/lib/connection.cpp index 3e44513b..c390cc05 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -92,7 +92,7 @@ public: // state is Invited. The spec mandates to keep Invited room state // separately; specifically, we should keep objects for Invite and // Leave state of the same room if the two happen to co-exist. - QHash, Room*> roomMap; + QHash, Room*> roomMap; /// Mapping from serverparts to alias/room id mappings, /// as of the last sync QHash roomAliasMap; @@ -1707,7 +1707,7 @@ Room* Connection::provideRoom(const QString& id, Omittable joinState) Q_ASSERT_X(!id.isEmpty(), __FUNCTION__, "Empty room id"); // If joinState is empty, all joinState == comparisons below are false. - const auto roomKey = qMakePair(id, joinState == JoinState::Invite); + const std::pair roomKey { id, joinState == JoinState::Invite }; auto* room = d->roomMap.value(roomKey, nullptr); if (room) { // Leave is a special case because in transition (5a) (see the .h file) diff --git a/lib/room.cpp b/lib/room.cpp index 284d19df..f692c354 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -118,7 +118,7 @@ public: // A map from evtId to a map of relation type to a vector of event // pointers. Not using QMultiHash, because we want to quickly return // a number of relations for a given event without enumerating them. - QHash, RelatedEvents> relations; + QHash, RelatedEvents> relations; QString displayname; Avatar avatar; QHash notifications; @@ -2687,7 +2687,7 @@ bool Room::Private::processRedaction(const RedactionEvent& redaction) } if (const auto* reaction = eventCast(oldEvent)) { const auto& targetEvtId = reaction->relation().eventId; - const QPair lookupKey { targetEvtId, EventRelation::AnnotationType }; + const std::pair lookupKey { targetEvtId, EventRelation::AnnotationType }; if (relations.contains(lookupKey)) { relations[lookupKey].removeOne(reaction); emit q->updatedEvent(targetEvtId); -- cgit v1.2.3