diff options
Diffstat (limited to '.github/workflows')
-rw-r--r-- | .github/workflows/ci.yml | 249 |
1 files changed, 206 insertions, 43 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8a4a9d88..40ed85d1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,92 +9,255 @@ defaults: run: shell: bash +concurrency: ci-${{ github.ref }} + jobs: CI: runs-on: ${{ matrix.os }} + 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-18.04, macos-10.15] - compiler: [ GCC, Clang ] + os: [ ubuntu-22.04, macos-11 ] + qt-version: [ '6.3.1', '5.15.2' ] + compiler: [ LLVM ] # Not using binary values here, to make the job captions more readable - update-api: [ '', 'update-api' ] + e2ee: [ '', e2ee ] + update-api: [ '', update-api ] + static-analysis: [ '' ] + platform: [ '' ] + qt-arch: [ '' ] exclude: - - os: macos-10.15 + - qt-version: '6.3.1' + update-api: update-api # Generated code is not specific to Qt version + - os: ubuntu-22.04 + e2ee: e2ee # Will be re-added with static analysis below + # TODO: Enable E2EE on Windows and macOS + - os: macos-11 + e2ee: e2ee + include: + - os: windows-2019 + qt-version: '5.15.2' + compiler: MSVC + platform: x64 + qt-arch: win64_msvc2019_64 + - os: ubuntu-22.04 + qt-version: '5.15.2' + compiler: LLVM + e2ee: e2ee + static-analysis: codeql + - os: ubuntu-22.04 + qt-version: '5.15.2' + compiler: GCC + e2ee: e2ee + static-analysis: sonar + - os: ubuntu-22.04 + qt-version: '5.15.2' compiler: GCC + e2ee: e2ee + update-api: update-api + - os: ubuntu-22.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-arch: win64_msvc2019_64 + - os: windows-2019 + qt-version: '5.15.2' + compiler: MSVC + update-api: update-api + platform: x64 + qt-arch: win64_msvc2019_64 + + env: + SONAR_SERVER_URL: 'https://sonarcloud.io' steps: - uses: actions/checkout@v2 with: - submodules: false + fetch-depth: 0 - name: Cache Qt id: cache-qt uses: actions/cache@v2 with: path: ${{ runner.workspace }}/Qt - key: ${{ runner.os }}-QtCache + 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: '5.9.9' + version: ${{ matrix.qt-version }} + arch: ${{ matrix.qt-arch }} cached: ${{ steps.cache-qt.outputs.cache-hit }} - - name: Install Valgrind - if: contains(matrix.os, 'ubuntu') - run: | - sudo apt-get install valgrind - echo "VALGRIND=valgrind --tool=memcheck --leak-check=yes --gen-suppressions=all --suppressions=tests/.valgrind.supp" >>$GITHUB_ENV - - name: Setup build environment run: | - if [ "${{ matrix.compiler }}" == "GCC" ]; then - if [ -n "${{ matrix.update-api }}" ]; then VERSION_POSTFIX='-9'; fi - echo "CC=gcc$VERSION_POSTFIX" >>$GITHUB_ENV - echo "CXX=g++$VERSION_POSTFIX" >>$GITHUB_ENV + if [ '${{ matrix.compiler }}' == 'GCC' ]; then + echo "CC=gcc" >>$GITHUB_ENV + echo "CXX=g++" >>$GITHUB_ENV + if [ '${{ startsWith(matrix.qt-version, '5') }}' == 'true' ]; 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 + echo "VALGRIND=valgrind --tool=memcheck --leak-check=yes --gen-suppressions=all --suppressions=$GITHUB_WORKSPACE/quotest/.valgrind.supp" >>$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)" + elif [ '${{ github.ref }}' == 'refs/heads/master' ]; then + VERSION="ci${{ github.run_number }}-$(git rev-parse --short HEAD)" else - echo "CC=clang" >>$GITHUB_ENV - echo "CXX=clang++" >>$GITHUB_ENV + VERSION="$(git describe --all --contains)-ci${{ github.run_number }}-$(git rev-parse --short HEAD)" + fi + + 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 \ + -DBUILD_WITH_QT6=${{ startsWith(matrix.qt-version, '6') }}" + + if [ '${{ matrix.static-analysis }}' == 'sonar' ]; then + mkdir -p $HOME/.sonar + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_CXX_FLAGS=--coverage" fi - echo "QUOTEST_ORIGIN=${{ runner.os }}/${{ matrix.compiler }}" >>$GITHUB_ENV - echo "DESTDIR=${{ runner.workspace }}" >>$GITHUB_ENV - echo "CMAKE_ARGS=-DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_PREFIX_PATH=${{ runner.workspace }}/usr" >>$GITHUB_ENV + echo "CMAKE_ARGS=$CMAKE_ARGS" >>$GITHUB_ENV + + if [[ '${{ runner.os }}' != 'Windows' ]]; then + BIN_DIR=/bin + echo "LIB_PATH=$HOME/.local/lib" >>$GITHUB_ENV + fi + echo "BIN_DIR=$BIN_DIR" >>$GITHUB_ENV + echo "~/.local$BIN_DIR" >>$GITHUB_PATH + cmake -E make_directory ${{ runner.workspace }}/build + echo "BUILD_PATH=${{ runner.workspace }}/build/libQuotient" >>$GITHUB_ENV - - name: Pull API definitions and build GTAD - if: matrix.update-api + - 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: | - cd ${{ runner.workspace }} - git clone https://github.com/matrix-org/matrix-doc.git - git clone --recursive https://github.com/KitsuneRal/gtad.git - pushd gtad - cmake . $CMAKE_ARGS - cmake --build . + 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 + + - 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.static-analysis == 'sonar' + env: + SONAR_SCANNER_VERSION: 4.6.2.2472 + run: | + pushd $HOME/.sonar + curl -sSL --remote-name-all \ + $SONAR_SERVER_URL/static/cpp/build-wrapper-linux-x86.zip \ + https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip + unzip -o build-wrapper*.zip + echo "BUILD_WRAPPER=$HOME/.sonar/build-wrapper-linux-x86/build-wrapper-linux* --out-dir $BUILD_PATH/sonar" >>$GITHUB_ENV + unzip -o sonar-scanner-cli*.zip popd - echo "CMAKE_ARGS=$CMAKE_ARGS -DMATRIX_DOC_PATH=${{ runner.workspace }}/matrix-doc -DGTAD_PATH=${{ runner.workspace }}/gtad/gtad" >>$GITHUB_ENV - echo "QUOTEST_ORIGIN=$QUOTEST_ORIGIN with generated API files" >>$GITHUB_ENV + + - name: Build and install QtKeychain + run: | + cd .. + git clone -b v0.13.2 https://github.com/frankosterfeld/qtkeychain.git + cmake -S qtkeychain -B qtkeychain/build $CMAKE_ARGS + cmake --build qtkeychain/build --target install + + - name: get CS API definitions; clone and build GTAD + if: matrix.update-api + run: | + git clone --depth=1 https://github.com/quotient-im/matrix-spec.git ../matrix-spec + git submodule update --init --recursive --depth=1 + cmake -S gtad/gtad -B ../build/gtad $CMAKE_ARGS -DBUILD_SHARED_LIBS=OFF + cmake --build ../build/gtad + echo "CMAKE_ARGS=$CMAKE_ARGS -DMATRIX_SPEC_PATH=${{ runner.workspace }}/matrix-spec \ + -DGTAD_PATH=${{ runner.workspace }}/build/gtad/gtad" \ + >>$GITHUB_ENV + echo "QUOTEST_ORIGIN=$QUOTEST_ORIGIN with API files regeneration" >>$GITHUB_ENV + + - name: Initialize CodeQL tools + if: matrix.static-analysis == '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 libQuotient - run: cmake -S $GITHUB_WORKSPACE -B build $CMAKE_ARGS + run: | + cmake -S $GITHUB_WORKSPACE -B $BUILD_PATH $CMAKE_ARGS \ + -DQuotient_ENABLE_E2EE=${{ matrix.e2ee }} -DQuotient_INSTALL_TESTS=ON - - name: Generate API files + - name: Regenerate API code if: matrix.update-api - run: cmake --build build --target update-api + run: cmake --build ../build/libQuotient --target update-api - name: Build and install libQuotient - run: cmake --build build --target install - - - name: Build tests run: | - cmake tests -Bbuild-test $CMAKE_ARGS - cmake --build build-test --target all + $BUILD_WRAPPER cmake --build $BUILD_PATH --target all + cmake --build $BUILD_PATH --target install + ls ~/.local$BIN_DIR/quotest - name: Run tests env: TEST_USER: ${{ secrets.TEST_USER }} TEST_PWD: ${{ secrets.TEST_PWD }} + QT_LOGGING_RULES: 'quotient.main.debug=true;quotient.jobs.debug=true;quotient.events.debug=true' + QT_MESSAGE_PATTERN: '%{time h:mm:ss.zzz}|%{category}|%{if-debug}D%{endif}%{if-info}I%{endif}%{if-warning}W%{endif}%{if-critical}C%{endif}%{if-fatal}F%{endif}|%{message}' run: | - [[ -z "$TEST_USER" ]] || $VALGRIND build-test/quotest "$TEST_USER" "$TEST_PWD" quotest-gha '#quotest:matrix.org' "$QUOTEST_ORIGIN" - timeout-minutes: 5 # quotest is supposed to finish within 3 minutes, actually + CTEST_ARGS="--test-dir $BUILD_PATH --output-on-failure" + if [[ -z '${{ matrix.e2ee }}' || '${{ runner.os }}' != 'Linux' ]]; then + ctest $CTEST_ARGS -E testolmaccount + else + autotests/run-tests.sh $CTEST_ARGS + fi + [[ -z "$TEST_USER" ]] || \ + LD_LIBRARY_PATH=$LIB_PATH \ + $VALGRIND quotest "$TEST_USER" "$TEST_PWD" quotest-gha '#quotest:matrix.org' "$QUOTEST_ORIGIN" + timeout-minutes: 4 # quotest is supposed to finish within 3 minutes, actually + + - name: Perform CodeQL analysis + if: matrix.static-analysis == 'codeql' + uses: github/codeql-action/analyze@v2 + + - name: Run sonar-scanner + 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 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* + popd + $HOME/.sonar/sonar-scanner*/bin/sonar-scanner \ + -Dsonar.host.url="$SONAR_SERVER_URL" \ + -Dsonar.cfamily.build-wrapper-output="$BUILD_PATH/sonar" \ + -Dsonar.cfamily.threads=2 \ + -Dsonar.cfamily.gcov.reportsPath=.coverage |