From 7c15b368e2adcb917095cc46d07c7da5e97cc76d Mon Sep 17 00:00:00 2001 From: Ivan Komissarov Date: Sat, 15 Aug 2020 15:03:44 +0200 Subject: Initial support for GitHub Actions This commit adds jobs similar to what we have in Travis. Some tests are disabled when running on GitHub since they do not pass for various reasons. Note that those tests are usually skipped on Travis due to missing dependencies. Change-Id: Icec96dc22e2939d12568d2de1f1a4537c35977ad Reviewed-by: Christian Kandeler --- .github/actions/download-qt/action.yml | 22 ++ .github/actions/download-qtc/action.yml | 15 + .github/workflows/main.yml | 403 +++++++++++++++++++++ docker-compose.yml | 2 + examples/cocoa-application/dmg.qbs | 1 + qbs.qbs | 1 + scripts/build-qbs-with-qbs.sh | 10 + scripts/cpu-count.sh | 50 +++ scripts/install-qt.sh | 8 +- scripts/run-analyzer.sh | 9 +- scripts/test-baremetal.sh | 2 + scripts/test-qbs.sh | 57 +++ scripts/test-qt-for-android.sh | 2 + .../auto/blackbox/testdata-java/java/vehicles.qbs | 7 + tests/auto/blackbox/tst_blackbox.cpp | 16 + tests/auto/blackbox/tst_blackboxandroid.cpp | 4 + tests/auto/blackbox/tst_blackboxapple.cpp | 2 + tests/auto/blackbox/tst_blackboxjava.cpp | 3 + 18 files changed, 604 insertions(+), 10 deletions(-) create mode 100644 .github/actions/download-qt/action.yml create mode 100644 .github/actions/download-qtc/action.yml create mode 100644 .github/workflows/main.yml create mode 100755 scripts/cpu-count.sh create mode 100755 scripts/test-qbs.sh diff --git a/.github/actions/download-qt/action.yml b/.github/actions/download-qt/action.yml new file mode 100644 index 000000000..cf7ade428 --- /dev/null +++ b/.github/actions/download-qt/action.yml @@ -0,0 +1,22 @@ +name: 'Download Qt' +description: 'Downloads Qt' +inputs: + version: + description: 'Qt version' + required: false + default: '5.15.0' + target: + description: 'Qt target (desktop, ios, android)' + required: false + default: 'desktop' + toolchain: + description: 'Qt toolchain' + required: true +runs: + using: "composite" + steps: + - name: Install Qt + run: | + export QT_DIR=$(./scripts/install-qt.sh -d $HOME/Qt --version ${{ inputs.version }} --target ${{ inputs.target }} --toolchain ${{ inputs.toolchain }} qtbase qtdeclarative qttools qtscript qtscxml) + echo ::add-path::$QT_DIR + shell: bash diff --git a/.github/actions/download-qtc/action.yml b/.github/actions/download-qtc/action.yml new file mode 100644 index 000000000..ba5486298 --- /dev/null +++ b/.github/actions/download-qtc/action.yml @@ -0,0 +1,15 @@ +name: 'Download Qt Creator' +description: 'Downloads Qt Creator' +inputs: + version: + description: 'Qt Creator version' + required: false + default: '4.12.4' +runs: + using: "composite" + steps: + - name: Install Qt Creator + run: | + export QTC_DIR=$(./scripts/install-qt.sh -d $HOME/Qt --version ${{ inputs.version }} qtcreator) + echo ::add-path::$QTC_DIR + shell: bash diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..a852b8809 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,403 @@ +name: Build and test Qbs + +on: [push] + +jobs: + build-linux: + name: ${{ matrix.config.name }} + runs-on: ubuntu-latest + timeout-minutes: 45 + strategy: + fail-fast: false + matrix: + config: + - { + name: 'Build on Linux (gcc)', + options: 'modules.cpp.compilerWrapper:ccache modules.qbs.debugInformation:true modules.qbsbuildconfig.enableBundledQt:true', + script: './scripts/build-qbs-with-qbs.sh', + cacheid: '{{ runner.os }}-gcc-ccache', + } + env: + BUILD_OPTIONS: ${{ matrix.config.options }} + WITH_TESTS: 0 + steps: + - uses: actions/checkout@v1 + - name: Create .ccache dir + run: mkdir -p ~/.ccache + - name: prepare timestamp + id: ccache_cache_timestamp + run: | + export TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ") + echo ::set-output name=timestamp::$TIMESTAMP + - name: ccache cache files + uses: actions/cache@v2 + with: + path: ~/.ccache + key: ${{ matrix.config.cacheid }}-${{ steps.ccache_cache_timestamp.outputs.timestamp }} + restore-keys: ${{ matrix.config.cacheid }} + - name: Pull the Bionic Image + run: docker-compose pull bionic + - name: Print ccache stats + run: docker-compose run bionic ccache -s + - name: Build Qbs + run: docker-compose run bionic ${{ matrix.config.script }} + - name: Print ccache stats + run: docker-compose run bionic ccache -s + - name: Create acrhive + run: tar -C release/install-root/ -cJf qbs-${{ runner.os }}-${{ github.run_id }}.tar.xz usr/local + - name: Upload artifacts + uses: 'actions/upload-artifact@v2' + with: + name: qbs-${{ runner.os }}-${{ github.run_id }}.tar.xz + path: qbs-${{ runner.os }}-${{ github.run_id }}.tar.xz + + build-linux-extra: + name: ${{ matrix.config.name }} + runs-on: ubuntu-latest + timeout-minutes: 45 + strategy: + fail-fast: false + matrix: + config: + - { + name: 'Build on Linux (clang_tidy)', + script: './scripts/run-analyzer.sh', + options: 'profile:qt-clang_64 modules.cpp.compilerWrapper:ccache', + cacheid: '{{ runner.os }}-clang-ccache', + } + - { + name: 'Build on Linux (CMake)', + script: './scripts/build-qbs-with-cmake.sh', + cacheid: '{{ runner.os }}-cmake-ccache', + } + - { + name: 'Build on Linux (QMake)', + script: './scripts/build-qbs-with-qmake.sh', + options: 'CONFIG+=ccache', + cacheid: '{{ runner.os }}-qmake-ccache', + } + env: + BUILD_OPTIONS: ${{ matrix.config.options }} + QTEST_FUNCTION_TIMEOUT: 9000000 + steps: + - uses: actions/checkout@v1 + - name: Create .ccache dir + run: mkdir -p ~/.ccache + - name: prepare timestamp + id: ccache_cache_timestamp + run: | + export TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ") + echo ::set-output name=timestamp::$TIMESTAMP + - name: ccache cache files + uses: actions/cache@v2 + with: + path: ~/.ccache + key: ${{ matrix.config.cacheid }}-${{ steps.ccache_cache_timestamp.outputs.timestamp }} + restore-keys: ${{ matrix.config.cacheid }} + - name: Pull the Bionic Image + run: docker-compose pull bionic + - name: Print ccache stats + run: docker-compose run bionic ccache -s + - name: Build Qbs + run: docker-compose run bionic ${{ matrix.config.script }} + - name: Print ccache stats + run: docker-compose run bionic ccache -s + + build-macos: + name: Build on macOS + runs-on: macos-latest + timeout-minutes: 45 + env: + BUILD_OPTIONS: 'modules.cpp.compilerWrapper:ccache modules.qbs.debugInformation:true modules.qbsbuildconfig.enableAddressSanitizer:false modules.qbsbuildconfig.enableBundledQt:true' + WITH_TESTS: 0 + steps: + - uses: actions/checkout@v1 + - name: Create .ccache dir + run: mkdir -p ~/.ccache + - name: prepare timestamp + id: ccache_cache_timestamp + run: | + export TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ") + echo ::set-output name=timestamp::$TIMESTAMP + - name: ccache cache files + uses: actions/cache@v2 + with: + path: ~/.ccache + key: ${{ runner.os }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} + restore-keys: ${{ runner.os }}-ccache- + - name: Install required packages + run: | + brew install ccache p7zip + /usr/bin/python3 -m pip install --user beautifulsoup4 lxml + - name: Install Qt + uses: ./.github/actions/download-qt + with: + toolchain: clang_64 + - name: Install Qt Creator + uses: ./.github/actions/download-qtc + - name: Print ccache stats + run: ccache -s + - name: Setup Qbs + run: | + qbs setup-toolchains --detect + qbs setup-qt --detect + qbs config profiles.qt.baseProfile xcode-macosx-x86_64 + qbs config defaultProfile qt + qbs config --list + - name: Build Qbs + run: scripts/build-qbs-with-qbs.sh + - name: Print ccache stats + run: ccache -s + - name: Create acrhive + run: tar -C release/install-root/ -cJf qbs-${{ runner.os }}-${{ github.run_id }}.tar.xz usr/local + - name: Upload artifacts + uses: 'actions/upload-artifact@v2' + with: + name: qbs-${{ runner.os }}-${{ github.run_id }}.tar.xz + path: qbs-${{ runner.os }}-${{ github.run_id }}.tar.xz + + build-windows: + name: Build on Windows + runs-on: windows-latest + timeout-minutes: 45 + env: + BUILD_OPTIONS: 'modules.cpp.compilerWrapper:clcache modules.qbsbuildconfig.enableAddressSanitizer:false modules.qbsbuildconfig.enableBundledQt:true' + WITH_TESTS: 0 + steps: + - uses: actions/checkout@v1 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install beautifulsoup4 lxml + pip install git+https://github.com/frerich/clcache.git@cae73d8255d78db8ba11e23c51fd2c9a89e7475b + - name: clcache cache files + uses: actions/cache@v2 + with: + path: ~/clcache + key: ${{ runner.os }}-clcache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} + restore-keys: ${{ runner.os }}-clcache- + - name: Print clcache stats + run: clcache -s + - name: Install Qt + uses: ./.github/actions/download-qt + with: + toolchain: win64_msvc2019_64 + - name: Install Qt Creator + uses: ./.github/actions/download-qtc + - name: Setup Qbs + run: | + qbs setup-toolchains --detect + qbs setup-qt $(which qmake).exe qt + qbs config defaultProfile qt + qbs config --list + shell: bash + - name: Build Qbs + run: scripts/build-qbs-with-qbs.sh + shell: bash + - name: Print clcache stats + run: clcache -s + - name: Create acrhive + run: 7z a qbs-${{ runner.os }}-${{ github.run_id }}.7z release/install-root/ -r + shell: bash + - name: Upload artifacts + uses: 'actions/upload-artifact@v2' + with: + name: qbs-${{ runner.os }}-${{ github.run_id }}.7z + path: qbs-${{ runner.os }}-${{ github.run_id }}.7z + + test-linux: + name: ${{ matrix.config.name }} + runs-on: ubuntu-latest + timeout-minutes: 45 + needs: build-linux + strategy: + fail-fast: false + matrix: + config: + - { + name: 'Run Linux tests (gcc)', + image: 'bionic', + profile: 'qt-gcc_64', + script: './scripts/test-qbs.sh', + } + - { + name: 'Run Linux tests (clang)', + image: 'bionic', + profile: 'qt-clang_64', + script: './scripts/test-qbs.sh', + } + - { + name: 'Run Android tests (Qt 5.13)', + image: 'bionic-android-513', + profile: '', + script: './scripts/test-qt-for-android.sh', + } + - { + name: 'Run Android tests (Qt 5.14)', + image: 'bionic-android-514', + profile: '', + script: './scripts/test-qt-for-android.sh', + } + env: + QBS_TEST_SOURCE_ROOT: 'tests' + QBS_AUTOTEST_PROFILE: ${{ matrix.config.profile }} + QTEST_FUNCTION_TIMEOUT: 9000000 + steps: + - uses: actions/checkout@v1 + - name: Download artifact + uses: actions/download-artifact@v1 + with: + name: qbs-${{ runner.os }}-${{ github.run_id }}.tar.xz + path: ./ + - name: Unpack artifact + run: mkdir -p release/install-root/ && tar xf qbs-${{ runner.os }}-${{ github.run_id }}.tar.xz -C release/install-root/ + - name: Pull the Docker Image + run: docker-compose pull ${{ matrix.config.image }} + - name: Run tests + run: docker-compose run ${{ matrix.config.image }} ${{ matrix.config.script }} release/install-root/usr/local/bin + + test-baremetal: + name: Run Baremetal tests + runs-on: ubuntu-latest + timeout-minutes: 45 + needs: build-linux + env: + QBS_TEST_SOURCE_ROOT: 'tests' + steps: + - uses: actions/checkout@v1 + - name: Download artifact + uses: actions/download-artifact@v1 + with: + name: qbs-${{ runner.os }}-${{ github.run_id }}.tar.xz + path: ./ + - name: Unpack artifact + run: mkdir -p release/install-root/ && tar xf qbs-${{ runner.os }}-${{ github.run_id }}.tar.xz -C release/install-root/ + - name: Pull the Focal-Baremetal Image + run: docker-compose pull focal-baremetal + - name: arm-none-eabi-gcc-9_2 + run: QBS_AUTOTEST_PROFILE=arm-none-eabi-gcc-9_2 docker-compose run focal-baremetal scripts/test-baremetal.sh release/install-root/usr/local/bin + - name: avr-gcc-5_4 + run: QBS_AUTOTEST_PROFILE=avr-gcc-5_4 docker-compose run focal-baremetal scripts/test-baremetal.sh release/install-root/usr/local/bin + - name: msp430-gcc-4_6 + run: QBS_AUTOTEST_PROFILE=msp430-gcc-4_6 docker-compose run focal-baremetal scripts/test-baremetal.sh release/install-root/usr/local/bin + - name: sdcc-3_8_0-mcs51 + run: QBS_AUTOTEST_PROFILE=sdcc-3_8_0-mcs51 docker-compose run focal-baremetal scripts/test-baremetal.sh release/install-root/usr/local/bin + - name: sdcc-3_8_0-stm8 + run: QBS_AUTOTEST_PROFILE=sdcc-3_8_0-stm8 docker-compose run focal-baremetal scripts/test-baremetal.sh release/install-root/usr/local/bin + + test-macos: + name: ${{ matrix.config.name }} + runs-on: macos-latest + timeout-minutes: 45 + needs: build-macos + env: + QTEST_FUNCTION_TIMEOUT: 9000000 + QBS_AUTOTEST_PROFILE: 'qt' + QBS_TEST_SOURCE_ROOT: 'tests' + strategy: + fail-fast: false + matrix: + config: + - { + name: 'Run macOS tests (Xcode 11.6)', + target: 'desktop', + toolchain: 'clang_64', + testProfile: 'xcode_11_6-macosx-x86_64', + } + - { + name: 'Run macOS tests (Xcode 10.3)', + target: 'desktop', + toolchain: 'clang_64', + testProfile: 'xcode_10_3-macosx-x86_64', + } + - { + name: 'Run iOS tests (Xcode 11.6)', + target: 'ios', + toolchain: 'ios', + testProfile: 'xcode_11_6-iphoneos-arm64', + } + steps: + - uses: actions/checkout@v1 + - name: Download artifact + uses: actions/download-artifact@v1 + with: + name: qbs-${{ runner.os }}-${{ github.run_id }}.tar.xz + path: ./ + - name: Unpack artifact + run: mkdir -p release/install-root/ && tar xf qbs-${{ runner.os }}-${{ github.run_id }}.tar.xz -C release/install-root/ + - name: Update PATH + run: echo ::add-path::./release/install-root/usr/local/bin + - name: Install required packages + run: brew install capnp ccache grpc icoutils makensis protobuf p7zip + - name: Install Qt + uses: ./.github/actions/download-qt + with: + target: ${{ matrix.config.target }} + toolchain: ${{ matrix.config.toolchain }} + - name: Setup Qbs + run: | + qbs setup-toolchains --detect + qbs setup-qt --detect + qbs config profiles.qt.baseProfile ${{ matrix.config.testProfile }} + qbs config defaultProfile qt + qbs config --list + - name: Run Tests + run: ./scripts/test-qbs.sh ./release/install-root/usr/local/bin + + test-windows: + name: ${{ matrix.config.name }} + runs-on: windows-latest + timeout-minutes: 45 + needs: build-windows + strategy: + fail-fast: false + matrix: + config: + - { + name: 'Run Windows tests (MSVC 2019)', + target: 'desktop', + toolchain: 'win64_msvc2019_64', + testProfile: 'MSVC2019-x64', + } + - { + name: 'Run Windows tests (clang-cl)', + target: 'desktop', + toolchain: 'win64_msvc2019_64', + testProfile: 'clang-cl-x86_64', + } + env: + QTEST_FUNCTION_TIMEOUT: 9000000 + QBS_AUTOTEST_PROFILE: 'qt' + QBS_TEST_SOURCE_ROOT: 'tests' + steps: + - uses: actions/checkout@v1 + - name: Download artifact + uses: actions/download-artifact@v1 + with: + name: qbs-${{ runner.os }}-${{ github.run_id }}.7z + path: ./ + - name: Unpack artifact + run: 7z x qbs-${{ runner.os }}-${{ github.run_id }}.7z + shell: bash + - name: Update PATH + run: echo ::add-path::./release/install-root/bin + shell: bash + - name: Install Qt + uses: ./.github/actions/download-qt + with: + toolchain: ${{ matrix.config.toolchain }} + - name: Setup Qbs + run: | + qbs setup-toolchains --detect + qbs setup-qt $(which qmake).exe qt + qbs config profiles.qt.baseProfile ${{ matrix.config.testProfile }} + qbs config defaultProfile qt + qbs config --list + shell: bash + - name: Run Tests + run: ./scripts/test-qbs.sh ./release/install-root/bin + shell: bash diff --git a/docker-compose.yml b/docker-compose.yml index 3bdd5ceb1..5af210210 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,8 @@ x-default-service: &linux - BUILD_OPTIONS - QTEST_FUNCTION_TIMEOUT - QBS_AUTOTEST_PROFILE + - QBS_TEST_SOURCE_ROOT + - WITH_TESTS volumes: - .:/qbs - ~/.ccache:/home/devel/.ccache diff --git a/examples/cocoa-application/dmg.qbs b/examples/cocoa-application/dmg.qbs index 610c5d2a3..0f5d3587b 100644 --- a/examples/cocoa-application/dmg.qbs +++ b/examples/cocoa-application/dmg.qbs @@ -55,6 +55,7 @@ AppleApplicationDiskImage { name: "Cocoa Application DMG" targetName: "cocoa-application-" + version version: "1.0" + builtByDefault: false Depends { name: "Cocoa Application" } Depends { name: "ib" } diff --git a/qbs.qbs b/qbs.qbs index c01b4b096..36b5e2277 100644 --- a/qbs.qbs +++ b/qbs.qbs @@ -65,6 +65,7 @@ Project { ".travis.yml", ".clang-tidy", "docker-compose.yml", + ".github/**/*.yml", ] } } diff --git a/scripts/build-qbs-with-qbs.sh b/scripts/build-qbs-with-qbs.sh index d1c1916f2..68832036a 100755 --- a/scripts/build-qbs-with-qbs.sh +++ b/scripts/build-qbs-with-qbs.sh @@ -78,6 +78,16 @@ if [ "$WITH_DOCS" -ne 0 ]; then qbs build -p "qbs documentation" ${BUILD_OPTIONS} fi +WITH_ARCHIVE=${WITH_ARCHIVE:-0} +if [ "$WITH_ARCHIVE" -ne 0 ]; then + qbs build -p dist ${BUILD_OPTIONS} "products.qbs archive.includeTopLevelDir:true" +fi + +WITH_TESTS=${WITH_TESTS:-1} +if [ "$WITH_TESTS" -eq 0 ]; then + exit 0 +fi + QMAKE_PATH=${QMAKE_PATH:-$(which qmake)} # diff --git a/scripts/cpu-count.sh b/scripts/cpu-count.sh new file mode 100755 index 000000000..ce6b1c82f --- /dev/null +++ b/scripts/cpu-count.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +############################################################################# +## +## Copyright (C) 2020 Ivan Komissarov +## Contact: https://www.qt.io/licensing/ +## +## This file is part of Qbs. +## +## $QT_BEGIN_LICENSE:LGPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU Lesser General Public License Usage +## Alternatively, this file may be used under the terms of the GNU Lesser +## General Public License version 3 as published by the Free Software +## Foundation and appearing in the file LICENSE.LGPL3 included in the +## packaging of this file. Please review the following information to +## ensure the GNU Lesser General Public License version 3 requirements +## will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 2.0 or (at your option) the GNU General +## Public license version 3 or any later version approved by the KDE Free +## Qt Foundation. The licenses are as published by the Free Software +## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-2.0.html and +## https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +NPROC=`which nproc` +SYSCTL=`which sysctl` +CPU_COUNT=2 +if [ ! -z "$NPROC" ]; then # Linux + CPU_COUNT=`$NPROC --all` +elif [ ! -z "$SYSCTL" ]; then # macOS + CPU_COUNT=`$SYSCTL -n hw.physicalcpu_max` +fi + +echo $CPU_COUNT diff --git a/scripts/install-qt.sh b/scripts/install-qt.sh index be953e77d..a73300ae4 100755 --- a/scripts/install-qt.sh +++ b/scripts/install-qt.sh @@ -218,7 +218,7 @@ if ! ${FORCE_DOWNLOAD} && [ -f "${HASH_FILEPATH}" ]; then fi if ${INSTALLATION_IS_VALID}; then - echo "Already installed. Skipping download." + echo "Already installed. Skipping download." >&2 exit 0 fi @@ -313,7 +313,11 @@ for COMPONENT in ${COMPONENTS}; do # adjust the PATH variable. echo $(dirname "${CONF_FILE}") elif [[ "${COMPONENT}" =~ "qtcreator" ]]; then - echo "${INSTALL_DIR}/Tools/QtCreator/bin" + if [ "${HOST_OS}" == "mac_x64" ]; then + echo "${INSTALL_DIR}/Qt Creator.app/Contents/MacOS" + else + echo "${INSTALL_DIR}/Tools/QtCreator/bin" + fi fi done diff --git a/scripts/run-analyzer.sh b/scripts/run-analyzer.sh index a60bcc02e..d98fe2ab1 100755 --- a/scripts/run-analyzer.sh +++ b/scripts/run-analyzer.sh @@ -57,14 +57,7 @@ if [ -z "$RUN_CLANG_TIDY" ] || [ -z "$CLANG_TIDY" ]; then fi fi -NPROC=`which nproc` -SYSCTL=`which sysctl` -CPU_COUNT=2 -if [ ! -z "$NPROC" ]; then # Linux - CPU_COUNT=`$NPROC --all` -elif [ ! -z "$SYSCTL" ]; then # macOS - CPU_COUNT=`$SYSCTL -n hw.ncpu` -fi +CPU_COUNT=$("$(dirname "$0")"/cpu-count.sh) BUILD_OPTIONS="\ ${QBS_BUILD_PROFILE:+profile:${QBS_BUILD_PROFILE}} \ diff --git a/scripts/test-baremetal.sh b/scripts/test-baremetal.sh index 5273d4ba9..985a5eac4 100755 --- a/scripts/test-baremetal.sh +++ b/scripts/test-baremetal.sh @@ -40,6 +40,8 @@ set -eu ## ############################################################################# +export LSAN_OPTIONS="suppressions=$( cd "$(dirname "$0")" ; pwd -P )/address-sanitizer-suppressions.txt:print_suppressions=0" + export PATH="$1:$PATH" export QBS_AUTOTEST_ALWAYS_LOG_STDERR=true diff --git a/scripts/test-qbs.sh b/scripts/test-qbs.sh new file mode 100755 index 000000000..608499f43 --- /dev/null +++ b/scripts/test-qbs.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +############################################################################# +## +## Copyright (C) 2020 Ivan Komissarov +## Contact: https://www.qt.io/licensing/ +## +## This file is part of Qbs. +## +## $QT_BEGIN_LICENSE:LGPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU Lesser General Public License Usage +## Alternatively, this file may be used under the terms of the GNU Lesser +## General Public License version 3 as published by the Free Software +## Foundation and appearing in the file LICENSE.LGPL3 included in the +## packaging of this file. Please review the following information to +## ensure the GNU Lesser General Public License version 3 requirements +## will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 2.0 or (at your option) the GNU General +## Public license version 3 or any later version approved by the KDE Free +## Qt Foundation. The licenses are as published by the Free Software +## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-2.0.html and +## https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +set -eu + +# +# Qbs is built with the address sanitizer enabled. +# Suppress findings in some parts of Qbs / dependencies. +# +export LSAN_OPTIONS="suppressions=$( cd "$(dirname "$0")" ; pwd -P )/address-sanitizer-suppressions.txt:print_suppressions=0" + +export PATH="$1:$PATH" + +qbs-config --list profiles + +CPUS=$("$(dirname "$0")"/cpu-count.sh) + +export QBS_AUTOTEST_PROFILE=${QBS_AUTOTEST_PROFILE:-qt} +echo "Running Qbs tests (${CPUS} jobs in parallel)." +find $1 -name "tst_*" | xargs -I{} -n1 -P${CPUS} bash -c 'export LOG=$(mktemp) ; $({} > ${LOG} 2>&1) ; export RESULT=$? ; cat ${LOG} ; exit ${RESULT}' diff --git a/scripts/test-qt-for-android.sh b/scripts/test-qt-for-android.sh index 44a64db21..06d89cedf 100755 --- a/scripts/test-qt-for-android.sh +++ b/scripts/test-qt-for-android.sh @@ -42,6 +42,8 @@ set -eu export PATH="$1:$PATH" +export LSAN_OPTIONS="suppressions=$( cd "$(dirname "$0")" ; pwd -P )/address-sanitizer-suppressions.txt:print_suppressions=0" + # # These are set outside of this script, for instance in the Docker image # diff --git a/tests/auto/blackbox/testdata-java/java/vehicles.qbs b/tests/auto/blackbox/testdata-java/java/vehicles.qbs index fa632b7b3..633ee5abd 100644 --- a/tests/auto/blackbox/testdata-java/java/vehicles.qbs +++ b/tests/auto/blackbox/testdata-java/java/vehicles.qbs @@ -10,6 +10,13 @@ Project { bundle.isBundle: false } + property bool _testPlatform: { + var result = qbs.targetPlatform === qbs.hostPlatform; + if (!result) + console.info("targetPlatform differs from hostPlatform"); + return result; + } + name: "native" files: ["engine.c"] diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index 335934882..59240642c 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -1392,6 +1392,9 @@ void TestBlackbox::vcsSubversion() if (svnFilePath.isEmpty()) QSKIP("svn not found"); + if (HostOsInfo::isWindowsHost() && qEnvironmentVariableIsSet("GITHUB_ACTIONS")) + QSKIP("Skip this test when running on GitHub"); + // Set up repo. QTemporaryDir repoDir; QVERIFY(repoDir.isValid()); @@ -7408,6 +7411,9 @@ void TestBlackbox::nodejs() void TestBlackbox::typescript() { + if (qEnvironmentVariableIsSet("GITHUB_ACTIONS")) + QSKIP("Skip this test when running on GitHub"); + const SettingsPtr s = settings(); Profile p(profileName(), s.get()); @@ -7525,6 +7531,9 @@ void TestBlackbox::innoSetup() return; } + if (HostOsInfo::isWindowsHost() && qEnvironmentVariableIsSet("GITHUB_ACTIONS")) + QSKIP("Skip this test when running on GitHub"); + QDir::setCurrent(testDataDir + "/innosetup"); QCOMPARE(runQbs(), 0); QVERIFY(m_qbsStdout.contains("compiling test.iss")); @@ -7535,6 +7544,9 @@ void TestBlackbox::innoSetup() void TestBlackbox::innoSetupDependencies() { + if (HostOsInfo::isWindowsHost() && qEnvironmentVariableIsSet("GITHUB_ACTIONS")) + QSKIP("Skip this test when running on GitHub"); + const SettingsPtr s = settings(); Profile profile(profileName(), s.get()); @@ -7813,6 +7825,10 @@ void TestBlackbox::fallbackModuleProvider() QFETCH(bool, fallbacksEnabledGlobally); QFETCH(QStringList, pkgConfigLibDirs); QFETCH(bool, successExpected); + + if (HostOsInfo::isWindowsHost() && qEnvironmentVariableIsSet("GITHUB_ACTIONS")) + QSKIP("Skip this test when running on GitHub"); + QDir::setCurrent(testDataDir + "/fallback-module-provider"); static const auto b2s = [](bool b) { return QString(b ? "true" : "false"); }; QbsRunParameters resolveParams("resolve", diff --git a/tests/auto/blackbox/tst_blackboxandroid.cpp b/tests/auto/blackbox/tst_blackboxandroid.cpp index 5e850874e..15b84a13b 100644 --- a/tests/auto/blackbox/tst_blackboxandroid.cpp +++ b/tests/auto/blackbox/tst_blackboxandroid.cpp @@ -84,6 +84,10 @@ void TestBlackboxAndroid::android() QFETCH(bool, generateAab); QFETCH(bool, isIncrementalBuild); + // skip tests on github except when run in docker - this var is not propagated into the image + if (qEnvironmentVariableIsSet("GITHUB_ACTIONS")) + QSKIP("Skip Android tests when running on GitHub"); + const SettingsPtr s = settings(); Profile p(theProfileName(projectDir == "qml-app"), s.get()); if (!p.exists()) diff --git a/tests/auto/blackbox/tst_blackboxapple.cpp b/tests/auto/blackbox/tst_blackboxapple.cpp index d76aaf897..ea0d2ac58 100644 --- a/tests/auto/blackbox/tst_blackboxapple.cpp +++ b/tests/auto/blackbox/tst_blackboxapple.cpp @@ -759,6 +759,8 @@ void TestBlackboxApple::deploymentTarget_data() void TestBlackboxApple::dmg() { + if (qEnvironmentVariableIsSet("GITHUB_ACTIONS")) + QSKIP("Skip this test when running on GitHub"); QDir::setCurrent(testDataDir + "/apple-dmg"); QCOMPARE(runQbs(), 0); } diff --git a/tests/auto/blackbox/tst_blackboxjava.cpp b/tests/auto/blackbox/tst_blackboxjava.cpp index a815a84ff..4400e1a35 100644 --- a/tests/auto/blackbox/tst_blackboxjava.cpp +++ b/tests/auto/blackbox/tst_blackboxjava.cpp @@ -73,6 +73,9 @@ void TestBlackboxJava::java() QSKIP("java.jdkPath not set and automatic detection failed"); } + if (m_qbsStdout.contains("targetPlatform differs from hostPlatform")) + QSKIP("Skip test in cross-compiled build"); + QCOMPARE(status, 0); const QStringList classFiles = -- cgit v1.2.3