diff --git a/.github/actions/install-compiler/action.yml b/.github/actions/install-compiler/action.yml new file mode 100644 index 00000000..62b7fa3c --- /dev/null +++ b/.github/actions/install-compiler/action.yml @@ -0,0 +1,32 @@ +name: Install Compiler +description: Installs compiler +inputs: + compiler: + description: Compiler to install (gcc|clang) + required: true + version: + description: Version of compiler to install + required: true + +runs: + using: composite + steps: + - name: Install GCC + if: ${{ inputs.compiler == 'gcc' }} + shell: bash + run: | + GCC_VERSION_MAJOR=$(echo ${{ inputs.version }} | cut -d '.' -f1) + sudo add-apt-repository "deb https://ppa.launchpadcontent.net/ubuntu-toolchain-r/ppa/ubuntu focal main" + sudo apt-get update + sudo apt-get install -y \ + gcc-${GCC_VERSION_MAJOR} g++-${GCC_VERSION_MAJOR} libstdc++-${GCC_VERSION_MAJOR}-dev + echo "CXX=/usr/bin/g++-${GCC_VERSION_MAJOR}" >> $GITHUB_ENV + - name: Install Clang + if : ${{ inputs.compiler == 'clang' }} + shell: bash + run: | + wget https://apt.llvm.org/llvm.sh -O llvm.sh + chmod a+x llvm.sh + sed -i "s/libunwind-\$LLVM_VERSION-dev//" llvm.sh + sudo ./llvm.sh ${{ inputs.version }} all + echo "CXX=/usr/bin/clang++-${{ inputs.version }}" >> $GITHUB_ENV \ No newline at end of file diff --git a/.github/actions/install-qt/action.yml b/.github/actions/install-qt/action.yml index c29ddcfd..e6b92b8c 100644 --- a/.github/actions/install-qt/action.yml +++ b/.github/actions/install-qt/action.yml @@ -7,46 +7,59 @@ inputs: qt_modules: description: 'List of Qt modules to intall' default: qtbase icu - compiler: - description: 'Name of the compiler to use' + platform: + description: 'Operating system (linux|windows|macos)' required: true runs: using: composite steps: - - shell: bash + - name: Install dependencies + if: ${{ inputs.platform == 'linux' }} + shell: bash run: | - if [[ "${{ inputs.compiler }}" == "msvc" ]]; then - pip3 install aqtinstall~=2.1 - aqt install-qt -O C:\Qt windows desktop ${{ inputs.qt_version }} win64_msvc2019_64 --archives ${{ inputs.qt_modules }} - QT_BASE_DIR="C:\Qt\${{ inputs.qt_version }}\msvc2019_64" - - powershell "./.github/actions/install-qt/install-dbus.ps1" "$QT_BASE_DIR" + sudo apt-get update + sudo apt-get install -y --no-install-recommends \ + python3 python3-pip \ + build-essential \ + dbus dbus-x11 \ + libgl-dev libegl-dev + - name: Install Qt + shell: bash + run: | + pip3 install aqtinstall~=2.1 + case "${{ inputs.platform }}" in + "windows") + QT_ARCH="win64_msvc2019_64" + QT_INSTALL_PATH="C:\\Qt" + QT_BASE_DIR="${QT_INSTALL_PATH}\\${{ inputs.qt_version }}\\msvc2019_64" + QT_OS="windows" + ;; + "linux") + QT_ARCH="gcc_64" + QT_INSTALL_PATH="/opt/qt" + QT_BASE_DIR="${QT_INSTALL_PATH}/${{ inputs.qt_version }}/${QT_ARCH}" + QT_OS="linux" + ;; + "macos") + QT_ARCH="" + QT_INSTALL_PATH="/Users/runner/qt" + if [[ "$(echo ${{ inputs.qt_version }} | cut -d'.' -f1)" == "6" ]]; then + QT_BASE_DIR="${QT_INSTALL_PATH}/${{ inputs.qt_version }}/macos" + else + QT_BASE_DIR="${QT_INSTALL_PATH}/${{ inputs.qt_version }}/clang_64" + fi + QT_OS="mac" + ;; + esac - echo "$QT_BASE_DIR\\bin" >> $GITHUB_PATH - echo "CMAKE_PREFIX_PATH=$QT_BASE_DIR\\lib\\cmake" >> $GITHUB_ENV - elif [[ "${{ inputs.compiler }}" == "apple-clang" ]]; then - pip3 install aqtinstall~=2.1 - aqt install-qt -O /Users/runner/qt mac desktop ${{ inputs.qt_version }} --archives ${{ inputs.qt_modules }} + aqt install-qt -O ${QT_INSTALL_PATH} ${QT_OS} desktop ${{ inputs.qt_version }} ${QT_ARCH} --archives ${{ inputs.qt_modules }} - if [[ "$(echo ${{ inputs.qt_version }} | cut -d'.' -f1)" == "6" ]]; then - QT_BASE_DIR="/Users/runner/qt/${{ inputs.qt_version }}/macos" - else - QT_BASE_DIR="/Users/runner/qt/${{ inputs.qt_version }}/clang_64" - fi - echo "$QT_BASE_DIR/bin" >> $GITHUB_PATH - echo "LD_LIBRARY_PATH=$QT_BASE_DIR/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV - echo "XDG_DATA_DIRS=$QT_BASE_DIR/share:$XDG_DATA_DIRS" >> $GITHUB_ENV - else - sudo apt-get update - sudo apt-get install -y --no-install-recommends python3 python3-pip build-essential dbus dbus-x11 libgl-dev libegl-dev - pip3 install aqtinstall~=2.1 - if [[ "${{ inputs.compiler }}" == "clang"* ]]; then - sudo apt-get install -y --no-install-recommends libc++1-11 libc++-11-dev libc++abi-11-dev - fi - aqt install-qt -O /opt/qt linux desktop ${{ inputs.qt_version }} gcc_64 --archives ${{ inputs.qt_modules }} + echo "${QT_BASE_DIR}/bin" >> $GITHUB_PATH + echo "CMAKE_PREFIX_PATH=${QT_BASE_DIR}/lib/cmake" >> $GITHUB_ENV + echo "LD_LIBRARY_PATH=${QT_BASE_DIR}/lib:${LD_LIBRARY_PATH}" >> $GITHUB_ENV + echo "XDG_DATA_DIRS=${QT_BASE_DIR}/share:${XDG_DATA_DIRS}" >> $GITHUB_ENV - QT_BASE_DIR="/opt/qt/${{ inputs.qt_version }}/gcc_64/" - echo "$QT_BASE_DIR/bin" >> $GITHUB_PATH - echo "LD_LIBRARY_PATH=$QT_BASE_DIR/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV - echo "XDG_DATA_DIRS=$QT_BASE_DIR/share:$XDG_DATA_DIRS" >> $GITHUB_ENV + if [[ "${{ inputs.platform }}" == "windows" ]]; then + powershell "./.github/actions/install-qt/install-dbus.ps1" "$QT_BASE_DIR" fi + \ No newline at end of file diff --git a/.github/actions/install-qt/install-dbus.ps1 b/.github/actions/install-qt/install-dbus.ps1 index ba31dbd7..30fd53ea 100644 --- a/.github/actions/install-qt/install-dbus.ps1 +++ b/.github/actions/install-qt/install-dbus.ps1 @@ -3,6 +3,6 @@ Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force Set-PSRepository -Name 'PSGallery' -SourceLocation "https://www.powershellgallery.com/api/v2" -InstallationPolicy Trusted Install-Module -Name 7Zip4PowerShell -Force -curl https://files.kde.org/craft/master/Qt_5.15.2-1/windows/msvc2019_64/cl/RelWithDebInfo/libs/dbus/dbus-1.13.18-3-131-20210415T121131-windows-msvc2019_64-cl.7z -o C:\Qt\dbus.7z +Invoke-WebRequest -Uri https://files.kde.org/craft/master/22.05/windows/msvc2019_64/cl/RelWithDebInfo/libs/dbus/dbus-1.14.0-178-20220428T163337-windows-msvc2019_64-cl.7z -OutFile C:\Qt\dbus.7z Expand-7Zip -ArchiveFileName C:\Qt\dbus.7z -TargetPath $args[0] diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1f889a73..9e1aa75c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,178 +12,47 @@ env: BUILD_TYPE: RelWithDebInfo QTEST_FUNCTION_TIMEOUT: 60000 -jobs: - linux-gcc: - strategy: - fail-fast: false - matrix: - qt_version: [ 5.15.2, 6.2.0 ] - gcc_version: [ 10.3.0, 11.3.0 ] - - runs-on: ubuntu-20.04 - name: linux-gcc-${{ matrix.gcc_version }}-qt-${{ matrix.qt_version }} +jobs: + generate-matrix: + name: Generate build matrix + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - name: Checkout sources uses: actions/checkout@v2 - - - name: Install Qt - run: | - GCC_VERSION_MAJOR=$(echo ${{ matrix.gcc_version }} | cut -d '.' -f1) - sudo add-apt-repository "deb https://ppa.launchpadcontent.net/ubuntu-toolchain-r/ppa/ubuntu focal main" - sudo apt-get update - sudo apt-get install -y \ - lsb-release wget software-properties-common build-essential \ - dbus dbus-x11 libgl-dev libegl-dev \ - gcc-${GCC_VERSION_MAJOR} g++-${GCC_VERSION_MAJOR} libstdc++-${GCC_VERSION_MAJOR}-dev - - pip3 install aqtinstall~=2.1 - - aqt install-qt -O /opt/qt linux desktop ${{ matrix.qt_version }} gcc_64 --archives qtbase icu - - QT_BASE_DIR="/opt/qt/${{ matrix.qt_version }}/gcc_64/" - echo "$QT_BASE_DIR/bin" >> $GITHUB_PATH - echo "LD_LIBRARY_PATH=$QT_BASE_DIR/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV - echo "XDG_DATA_DIRS=$QT_BASE_DIR/share:$XDG_DATA_DIRS" >> $GITHUB_ENV - - - name: Create Build Environment - run: | - cmake -E make_directory ${{ github.workspace }}/build - - - name: Configure CMake - shell: bash - run: | - cd ${{ github.workspace }}/build - GCC_VERSION_MAJOR=$(echo ${{ matrix.gcc_version }} | cut -d '.' -f1) - QT_VERSION_MAJOR=$(echo ${{ matrix.qt_version }} | cut -d'.' -f1) - cmake $GITHUB_WORKSPACE \ - -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ - -DUSE_QT_VERSION=$QT_VERSION_MAJOR \ - -DQCORO_WITH_QTDBUS=ON \ - -DCMAKE_CXX_COMPILER=/usr/bin/g++-${GCC_VERSION_MAJOR} - - - name: Build - shell: bash + - id: set-matrix + name: Generate matrix run: | - cd ${{ github.workspace }}/build - cmake --build . --config $BUILD_TYPE --parallel $(nproc) --verbose - - - name: Test - shell: bash - run: | - cd ${{ github.workspace }}/build - QT_LOGGING_TO_CONSOLE=1 ctest -C $BUILD_TYPE --output-on-failure --verbose --output-junit linux-gcc-${{ matrix.gcc_version }}-qt-${{ matrix.qt_version }}.xml - - - name: Upload Test Results - if: always() - uses: actions/upload-artifact@v2 - with: - name: Unit Tests Results (linux-gcc-${{ matrix.gcc_version }}-qt-${{ matrix.qt_version }}) - path: | - ${{ github.workspace }}/build/linux-gcc-${{ matrix.gcc_version }}-qt-${{ matrix.qt_version }}.xml + matrix_json=$(python3 ./.github/workflows/generate-matrix.py) + echo "::set-output name=matrix::${matrix_json}" - - name: Upload build logs on failure - if: failure() - uses: actions/upload-artifact@v2 - with: - name: build-linux-gcc-${{ matrix.gcc_version }}-qt-${{ matrix.qt_version }} - path: build/** - - linux-clang: + build: + needs: generate-matrix strategy: + matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }} fail-fast: false - matrix: - qt_version: [ 5.15.2, 6.2.0 ] - clang_version: [ 11, 14, 15 ] - runs-on: ubuntu-20.04 - name: linux-clang-${{ matrix.clang_version }}-qt-${{ matrix.qt_version}} + runs-on: ${{ matrix.runs_on }} + name: ${{ matrix.platform }}-${{ matrix.compiler_full }}-qt-${{ matrix.qt_version }} steps: - name: Checkout sources uses: actions/checkout@v2 - - name: Install Qt - run: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends \ - lsb-release wget software-properties-common build-essential \ - dbus dbus-x11 libgl-dev libegl-dev - pip3 install aqtinstall~=2.1 - - aqt install-qt -O /opt/qt linux desktop ${{ matrix.qt_version }} gcc_64 --archives qtbase icu - - QT_BASE_DIR="/opt/qt/${{ matrix.qt_version }}/gcc_64/" - echo "$QT_BASE_DIR/bin" >> $GITHUB_PATH - echo "LD_LIBRARY_PATH=$QT_BASE_DIR/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV - echo "XDG_DATA_DIRS=$QT_BASE_DIR/share:$XDG_DATA_DIRS" >> $GITHUB_ENV - - - name: Install clang - run: | - wget https://apt.llvm.org/llvm.sh -O llvm.sh - chmod a+x llvm.sh - sed -i "s/libunwind-\$LLVM_VERSION-dev//" llvm.sh - sudo ./llvm.sh ${{ matrix.clang_version }} all - - - name: Create Build Environment - run: | - cmake -E make_directory ${{ github.workspace }}/build - - - name: Configure CMake - shell: bash - working-directory: ${{ github.workspace }}/build - run: | - QT_VERSION_MAJOR=$(echo ${{ matrix.qt_version }} | cut -d'.' -f1) - cmake $GITHUB_WORKSPACE \ - -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ - -DUSE_QT_VERSION=$QT_VERSION_MAJOR \ - -DQCORO_WITH_DBUS=ON \ - -DQCORO_WITH_ASAN=ON \ - -DCMAKE_CXX_COMPILER=/usr/bin/clang++-${{ matrix.clang_version }} - - - name: Build - working-directory: ${{ github.workspace }}/build - shell: bash - run: cmake --build . --config $BUILD_TYPE --parallel $(nproc) --verbose - - - name: Test - working-directory: ${{ github.workspace }}/build - shell: bash - run: QT_LOGGING_TO_CONSOLE=1 ctest -C $BUILD_TYPE --output-on-failure --verbose --output-junit linux-clang-${{ matrix.clang_version }}-qt-${{ matrix.qt_version }}.xml - - - name: Upload Test Results - if: always() - uses: actions/upload-artifact@v2 - with: - name: Unit Tests Results (linux-clang-${{ matrix.clang_version }}-qt-${{ matrix.qt_version }}) - path: | - ${{ github.workspace }}/build/linux-clang-${{ matrix.clang_version }}-qt-${{ matrix.qt_version }}.xml - - - name: Upload build logs on failure - if: failure() - uses: actions/upload-artifact@v2 + - name: Install compiler + if: ${{ matrix.compiler == 'gcc' || matrix.compiler == 'clang' }} + uses: ./.github/actions/install-compiler with: - name: build-linux-clang-${{ matrix.clang_version }}-qt-${{ matrix.qt_version }} - path: build/** - - windows-msvc: - strategy: - fail-fast: false - matrix: - qt_version: [ 5.15.2, 6.2.0 ] - - runs-on: windows-2022 - name: window-msvc-qt-${{ matrix.qt_version }} - - steps: - - name: Checkout sources - uses: actions/checkout@v2 + compiler: ${{ matrix.compiler }} + version: ${{ matrix.compiler_version }} - name: Install Qt uses: ./.github/actions/install-qt with: qt_version: ${{ matrix.qt_version }} - compiler: msvc + platform: ${{ matrix.platform }} - name: Create Build Environment run: | @@ -194,9 +63,14 @@ jobs: working-directory: ${{ github.workspace }}/build run: | QT_VERSION_MAJOR=$(echo ${{ matrix.qt_version }} | cut -d'.' -f1) - cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BULD_TYPE -DUSE_QT_VERSION=$QT_VERSION_MAJOR -DQCORO_WITH_DBUS=ON + cmake $GITHUB_WORKSPACE \ + -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ + -DUSE_QT_VERSION=$QT_VERSION_MAJOR \ + -DQCORO_WITH_QTDBUS=${{ matrix.with_qtdbus }} \ + -DQCORO_WITH_ASAN=ON - name: Add ASAN DLL directory to PATH + if: ${{ matrix.platform == 'windows' }} shell: cmd run: | setlocal enabledelayedexpansion @@ -211,89 +85,35 @@ jobs: ) - name: Build - working-directory: ${{ github.workspace }}/build shell: bash - run: cmake --build . --config $BUILD_TYPE --parallel 4 --verbose - - - name: Test working-directory: ${{ github.workspace }}/build - shell: bash - run: QT_LOGGING_TO_CONSOLE=1 ctest -C $BUILD_TYPE --output-on-failure --verbose --output-junit windows-msvc-qt-${{ matrix.qt_version }}.xml - - - name: Upload Test Results - if: always() - uses: actions/upload-artifact@v2 - with: - name: Unit Tests Results (windows-msvc-qt-${{ matrix.qt_version }}) - path: | - ${{ github.workspace }}/build/windows-msvc-qt-${{ matrix.qt_version }}.xml - - - name: Upload build logs on failure - if: failure() - uses: actions/upload-artifact@v2 - with: - name: build-windows-msvc-qt-${{ matrix.qt_version }} - path: build/** - - apple-clang: - strategy: - fail-fast: false - matrix: - qt_version: [ 5.15.2, 6.2.0 ] - - runs-on: macos-11 - name: apple-clang-qt-${{ matrix.qt_version }} - - steps: - - name: Checkout sources - uses: actions/checkout@v2 - - - name: Install Qt - uses: ./.github/actions/install-qt - with: - qt_version: ${{ matrix.qt_version }} - compiler: apple-clang - - - name: Create Build Environment run: | - cmake -E make_directory ${{ github.workspace }}/build + cmake --build . --config $BUILD_TYPE --parallel $(nproc) --verbose - - name: Configure CMake + - name: Test shell: bash working-directory: ${{ github.workspace }}/build run: | - QT_VERSION_MAJOR=$(echo ${{ matrix.qt_version }} | cut -d'.' -f1) - cmake $GITHUB_WORKSPACE \ - -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ - -DUSE_QT_VERSION=$QT_VERSION_MAJOR \ - -DQCORO_WITH_DBUS=ON \ - -DQCORO_WITH_ASAN=ON - - - name: Build - working-directory: ${{ github.workspace }}/build - shell: bash - run: cmake --build . --config $BUILD_TYPE --parallel $(nproc) --verbose - - - name: Test - working-directory: ${{ github.workspace }}/build - shell: bash - run: QT_LOGGING_TO_CONSOLE=1 ctest -C $BUILD_TYPE --output-on-failure --verbose --output-junit apple-clang-qt-${{ matrix.qt_version }}.xml + QT_LOGGING_TO_CONSOLE=1 ctest -C $BUILD_TYPE \ + --output-on-failure \ + --verbose \ + --output-junit ${{ matrix.platform }}-${{ matrix.compiler_full }}-qt-${{ matrix.qt_version }}.xml - name: Upload Test Results if: always() uses: actions/upload-artifact@v2 with: - name: Unit Tests Results (apple-clang-qt-${{ matrix.qt_version }}) + name: Unit Tests Results (${{ matrix.platform }}-${{ matrix.compiler_full }}-qt-${{ matrix.qt_version }}) path: | - ${{ github.workspace }}/build/apple-clang-qt-${{ matrix.qt_version }}.xml + ${{ github.workspace }}/build/${{ matrix.platform }}-${{ matrix.compiler_full }}-qt-${{ matrix.qt_version }}.xml - name: Upload build logs on failure if: failure() uses: actions/upload-artifact@v2 with: - name: build-apple-clang-qt-${{ matrix.qt_version }} + name: build-${{ matrix.platform }}-${{ matrix.compiler_full }}-qt-${{ matrix.qt_version }} path: build/** - + event_file: name: "Event File" runs-on: ubuntu-latest diff --git a/.github/workflows/generate-matrix.py b/.github/workflows/generate-matrix.py new file mode 100644 index 00000000..b89f4879 --- /dev/null +++ b/.github/workflows/generate-matrix.py @@ -0,0 +1,68 @@ +import json +from socket import create_connection + +qt_versions = [ "5.15.2", "6.2.0" ] + +platforms = [ + { + "name": "windows", + "compilers": [{ "name": "msvc" }] + }, + { + "name": "macos", + "compilers": [{ "name": "apple-clang" }] + }, + { + "name": "linux", + "compilers": [ + { + "name": "gcc", + "versions": [ "10.3.0", "11.3.0" ] + }, + { + "name": "clang", + "versions": [ "11", "14", "15" ] + } + ] + } +] + + +output = { + "include": [] +} + + +def get_os_for_platform(platform): + if platform == "windows": + return "windows-2022" + if platform == "linux": + return "ubuntu-20.04" + if platform == "macos": + return "macos-11" + raise RuntimeError(f"Invalid platform '{platform}'.") + + +def create_configuration(qt_version, platform, compiler, compiler_version = ""): + return { + "qt_version": qt_version, + "platform": platform, + "compiler": compiler, + "compiler_version": compiler_version, + "compiler_full": compiler if not compiler_version else f"{compiler}-{compiler_version}", + "runs_on": get_os_for_platform(platform), + "with_qtdbus": "OFF" if platform == "macos" else "ON" + } + +for qt_version in qt_versions: + for platform in platforms: + for compiler in platform["compilers"]: + if "versions" in compiler: + for compiler_version in compiler["versions"]: + output["include"].append( + create_configuration(qt_version, platform["name"], compiler["name"], compiler_version)) + else: + output["include"].append( + create_configuration(qt_version, platform["name"], compiler["name"])) + +print(json.dumps(output)) \ No newline at end of file diff --git a/tests/testobject.h b/tests/testobject.h index d7d48118..c64b35d9 100644 --- a/tests/testobject.h +++ b/tests/testobject.h @@ -41,20 +41,18 @@ class TestContext { class EventLoopChecker : public QTimer { Q_OBJECT public: - explicit EventLoopChecker(int minTicks = 10, std::chrono::milliseconds interval = 10ms) + explicit EventLoopChecker(int minTicks = 10, std::chrono::milliseconds interval = 5ms) : mMinTicks{minTicks} { - connect(this, &EventLoopChecker::timeout, this, &EventLoopChecker::timeoutCheck); + connect(this, &EventLoopChecker::timeout, this, [this]() { ++mTick; }); setInterval(interval); start(); } operator bool() const { - return mTick > mMinTicks; - } - -private Q_SLOTS: - void timeoutCheck() { - ++mTick; + if (mTick < mMinTicks) { + qDebug() << "EventLoopChecker failed: ticks=" << mTick << ", minTicks=" << mMinTicks; + } + return mTick >= mMinTicks; } private: