Analyze code with Sonar cloud.

This commit is contained in:
Roman Telezhynskyi 2024-02-05 14:46:30 +02:00
parent e493773805
commit b9f3e7c601
7 changed files with 92 additions and 20 deletions

View File

@ -37,10 +37,33 @@ linux_qt6_task_template: &LINUX_QT6_TASK_TEMPLATE
- qbs setup-toolchains /usr/bin/${COMPILER} ${COMPILER} - qbs setup-toolchains /usr/bin/${COMPILER} ${COMPILER}
- qbs setup-qt /usr/bin/qmake6 qt6 - qbs setup-qt /usr/bin/qmake6 qt6
- qbs config profiles.qt6.baseProfile ${COMPILER} - qbs config profiles.qt6.baseProfile ${COMPILER}
- qbs-config defaultProfile qt6 - qbs config defaultProfile qt6
- qbs build -f valentina.qbs -d build --jobs $(nproc) profile:qt6 config:release modules.buildconfig.enableCcache:${ENABLE_CCACHE} modules.cpp.linkerVariant:mold --force-probe-execution - qbs build -f valentina.qbs -d build --jobs $(nproc) profile:qt6 config:release modules.buildconfig.enableCcache:${ENABLE_CCACHE} modules.cpp.linkerVariant:mold --force-probe-execution
- qbs -p autotest-runner -d build profile:qt6 config:release - qbs -p autotest-runner -d build profile:qt6 config:release
- ccache -s - ccache -s
linux_qt6_sonar_task_template: &LINUX_QT6_TASK_SONAR_TEMPLATE
install_script:
- bash -c "$PACKAGE_MANAGER_INSTALL -y qt6-base-dev qt6-l10n-tools libqt6svg6-dev qt6-base-dev-tools qmake6 libxerces-c-dev poppler-utils libgl1-mesa-dev"
build_script:
- uname -a
- mkdir -pm 0700 $XDG_RUNTIME_DIR
- Xvfb $DISPLAY -ac -screen 0 1600x1200x24+32 -nolisten tcp -nolisten unix &
- sleep 1
- echo $PATH
- which qmake6
- which qbs
- pwd
- ls -l /usr/bin/ | grep -E "${COMPILER_REGEX}"
- ${COMPILER} --version
- qmake6 --version
- qbs --version
- qbs setup-toolchains /usr/bin/${COMPILER} ${COMPILER}
- qbs setup-qt /usr/bin/qmake6 qt6
- qbs config profiles.qt6.baseProfile ${COMPILER}
- qbs config defaultProfile qt6
- build-wrapper-linux-x86-64 --out-dir bw-output qbs build --no-install -f valentina.qbs -d build --jobs $(nproc) profile:qt6 config:release modules.buildconfig.enableCcache:false modules.cpp.linkerVariant:mold
- sonar-scanner -Dsonar.cfamily.threads=$(nproc) -Dsonar.scm.revision=${CIRRUS_CHANGE_IN_REPO} -Dsonar.links.ci=https://cirrus-ci.com/task/${CIRRUS_TASK_ID} -Dsonar.branch.name=${CIRRUS_BRANCH}
linux_qt5_qmake_task_template: &LINUX_QT5_QMAKE_TASK_TEMPLATE linux_qt5_qmake_task_template: &LINUX_QT5_QMAKE_TASK_TEMPLATE
install_script: install_script:
@ -82,7 +105,7 @@ linux_qt5_qbs_task_template: &LINUX_QT5_QBS_TASK_TEMPLATE
- qbs --version - qbs --version
- qbs setup-toolchains /usr/bin/${COMPILER} ${COMPILER} - qbs setup-toolchains /usr/bin/${COMPILER} ${COMPILER}
- qbs setup-qt /usr/bin/qmake qt5 - qbs setup-qt /usr/bin/qmake qt5
- qbs-config defaultProfile qt5 - qbs config defaultProfile qt5
- qbs config profiles.qt5.baseProfile ${COMPILER} - qbs config profiles.qt5.baseProfile ${COMPILER}
- qbs build -f valentina.qbs -d build --jobs $(nproc) profile:qt5 config:release modules.buildconfig.enableCcache:${ENABLE_CCACHE} modules.cpp.linkerVariant:mold --force-probe-execution - qbs build -f valentina.qbs -d build --jobs $(nproc) profile:qt5 config:release modules.buildconfig.enableCcache:${ENABLE_CCACHE} modules.cpp.linkerVariant:mold --force-probe-execution
- qbs -p autotest-runner -d build profile:qt5 config:release - qbs -p autotest-runner -d build profile:qt5 config:release
@ -126,6 +149,16 @@ linux_task:
container: container:
cpu: 8 cpu: 8
memory: 8G # Set to 8GB to avoid OOM. https://cirrus-ci.org/guide/linux/#linux-container memory: 8G # Set to 8GB to avoid OOM. https://cirrus-ci.org/guide/linux/#linux-container
- name: 'Sonar, latest Clang [Qt6]'
<< : *LINUX_QT6_TASK_SONAR_TEMPLATE
env:
QT_SELECT: "qt6"
SONAR_TOKEN: ENCRYPTED[!715ab983713a5035d505d2c601c9bb78a9475b9a04db62cdda9c674affd58ac956e563ce6d38228b48e05c4dbea2f52d!]
container:
cpu: 8
memory: 8G # Set to 8GB to avoid OOM. https://cirrus-ci.org/guide/linux/#linux-container
sonar_cache:
folder: "${HOME}/.sonar/cache"
- container: - container:
image: dismine/gcc-ubuntu:13 image: dismine/gcc-ubuntu:13
env: env:
@ -276,7 +309,7 @@ macos_task_template: &MACOS_TASK_TEMPLATE
- qbs setup-toolchains --detect - qbs setup-toolchains --detect
- qbs config --list profiles - qbs config --list profiles
- qbs setup-qt /opt/homebrew/opt/qt6/bin/qmake qt6 - qbs setup-qt /opt/homebrew/opt/qt6/bin/qmake qt6
- qbs-config defaultProfile qt6 - qbs config defaultProfile qt6
- qbs config profiles.qt6.baseProfile clang - qbs config profiles.qt6.baseProfile clang
- qbs build -f valentina.qbs -d $CIRRUS_WORKING_DIR/build --jobs $(nproc) config:release modules.buildconfig.enableUnitTests:false modules.buildconfig.enableMultiBundle:${MULTI_BUNDLE} qbs.installRoot:$CIRRUS_WORKING_DIR/build/install-root profile:qt6 project.minimumMacosVersion:${MACOS_DEPLOYMENT_TARGET} modules.buildconfig.enableCcache:${ENABLE_CCACHE} moduleProviders.qbspkgconfig.extraPaths:$(brew --prefix xerces-c)/lib/pkgconfig,$(brew --prefix qt6)/lib/pkgconfig,$(brew --prefix openssl@1.1)/lib/pkgconfig "modules.buildconfig.signingIdentity:$MACOS_CERTIFICATE_NAME" modules.macdeployqt.libpath:$(brew --prefix qt6)/lib,$(brew --prefix poppler)/lib modules.macdeployqt.macdeployqtProgramBinPath:${HOME}/macdeployqt-install-dir - qbs build -f valentina.qbs -d $CIRRUS_WORKING_DIR/build --jobs $(nproc) config:release modules.buildconfig.enableUnitTests:false modules.buildconfig.enableMultiBundle:${MULTI_BUNDLE} qbs.installRoot:$CIRRUS_WORKING_DIR/build/install-root profile:qt6 project.minimumMacosVersion:${MACOS_DEPLOYMENT_TARGET} modules.buildconfig.enableCcache:${ENABLE_CCACHE} moduleProviders.qbspkgconfig.extraPaths:$(brew --prefix xerces-c)/lib/pkgconfig,$(brew --prefix qt6)/lib/pkgconfig,$(brew --prefix openssl@1.1)/lib/pkgconfig "modules.buildconfig.signingIdentity:$MACOS_CERTIFICATE_NAME" modules.macdeployqt.libpath:$(brew --prefix qt6)/lib,$(brew --prefix poppler)/lib modules.macdeployqt.macdeployqtProgramBinPath:${HOME}/macdeployqt-install-dir
- qbs build -f valentina.qbs -d $CIRRUS_WORKING_DIR/build -p 'Valentina DMG' --force-probe-execution --jobs $(nproc) config:release modules.buildconfig.enableUnitTests:false modules.buildconfig.enableMultiBundle:${MULTI_BUNDLE} qbs.installRoot:$CIRRUS_WORKING_DIR/build/install-root profile:qt6 project.minimumMacosVersion:${MACOS_DEPLOYMENT_TARGET} modules.buildconfig.enableCcache:${ENABLE_CCACHE} moduleProviders.qbspkgconfig.extraPaths:$(brew --prefix xerces-c)/lib/pkgconfig,$(brew --prefix qt6)/lib/pkgconfig,$(brew --prefix openssl@1.1)/lib/pkgconfig "modules.buildconfig.signingIdentity:$MACOS_CERTIFICATE_NAME" modules.macdeployqt.libpath:$(brew --prefix qt6)/lib,$(brew --prefix poppler)/lib modules.macdeployqt.macdeployqtProgramBinPath:${HOME}/macdeployqt-install-dir - qbs build -f valentina.qbs -d $CIRRUS_WORKING_DIR/build -p 'Valentina DMG' --force-probe-execution --jobs $(nproc) config:release modules.buildconfig.enableUnitTests:false modules.buildconfig.enableMultiBundle:${MULTI_BUNDLE} qbs.installRoot:$CIRRUS_WORKING_DIR/build/install-root profile:qt6 project.minimumMacosVersion:${MACOS_DEPLOYMENT_TARGET} modules.buildconfig.enableCcache:${ENABLE_CCACHE} moduleProviders.qbspkgconfig.extraPaths:$(brew --prefix xerces-c)/lib/pkgconfig,$(brew --prefix qt6)/lib/pkgconfig,$(brew --prefix openssl@1.1)/lib/pkgconfig "modules.buildconfig.signingIdentity:$MACOS_CERTIFICATE_NAME" modules.macdeployqt.libpath:$(brew --prefix qt6)/lib,$(brew --prefix poppler)/lib modules.macdeployqt.macdeployqtProgramBinPath:${HOME}/macdeployqt-install-dir

4
.gitignore vendored
View File

@ -169,3 +169,7 @@ __pycache__
# Temporary svg cursor files # Temporary svg cursor files
/src/app/valentina/share/resources/cursor/svg/light/ /src/app/valentina/share/resources/cursor/svg/light/
/src/app/valentina/share/resources/cursor/svg/dark/ /src/app/valentina/share/resources/cursor/svg/dark/
# Sonar Cloud
.scannerwork
bw-output

View File

@ -7,6 +7,7 @@
[![Dev version](https://img.shields.io/badge/Dev-v0.7.52-yellow)](https://smart-pattern.com.ua/valentina/version/0.7.52/) [![Dev version](https://img.shields.io/badge/Dev-v0.7.52-yellow)](https://smart-pattern.com.ua/valentina/version/0.7.52/)
[![Build Status](https://api.cirrus-ci.com/github/dismine/valentina.svg)](https://cirrus-ci.com/github/dismine/valentina) [![Build Status](https://api.cirrus-ci.com/github/dismine/valentina.svg)](https://cirrus-ci.com/github/dismine/valentina)
[![Build status](https://ci.appveyor.com/api/projects/status/m505f1pfs19j81nt/branch/develop?svg=true)](https://ci.appveyor.com/project/dismi_/valentina) [![Build status](https://ci.appveyor.com/api/projects/status/m505f1pfs19j81nt/branch/develop?svg=true)](https://ci.appveyor.com/project/dismi_/valentina)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=dismine_valentina&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=dismine_valentina)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
Welcome to [Valentina](https://smart-pattern.com.ua/), a versatile cross-platform patternmaking program designed for creating and modeling clothing patterns. Whether you prefer using standard sizing tables or individual measurements, this software provides a flexible environment for pattern creation. Valentina seamlessly integrates modern technologies with traditional methods to offer a comprehensive patternmaking tool. Welcome to [Valentina](https://smart-pattern.com.ua/), a versatile cross-platform patternmaking program designed for creating and modeling clothing patterns. Whether you prefer using standard sizing tables or individual measurements, this software provides a flexible environment for pattern creation. Valentina seamlessly integrates modern technologies with traditional methods to offer a comprehensive patternmaking tool.

View File

@ -22,7 +22,7 @@ rm -r ./share
# Resolve any changes to config # Resolve any changes to config
qbs resolve -d ../../build_translations modules.i18n.update:true moduleProviders.Qt.qmakeFilePaths:$HOME/Qt6.5/6.5.0/gcc_64/bin/qmake qbs resolve -d ../../build_translations modules.i18n.update:true moduleProviders.Qt.qmakeFilePaths:$HOME/Qt6.5/6.5.0/gcc_64/bin/qmake
# Update local strings # Update local strings
qbs -d ../../build_translations -f ../valentina.qbs -p 'Translations' modules.i18n.update:true moduleProviders.Qt.qmakeFilePaths:$HOME/Qt6.5/6.5.0/gcc_64/bin/qmake qbs -d ../../build_translations -f ../valentina.qbs -p 'Translations' modules.i18n.update:true moduleProviders.Qt.qmakeFilePaths:$HOME/Qt6.6/6.6.0/gcc_64/bin/qmake
end=$(date +%s) end=$(date +%s)
runtime=$(python3 -c "print('Time passed %u:%02u seconds' % ((${end} - ${start})/60, (${end} - ${start})%60))") runtime=$(python3 -c "print('Time passed %u:%02u seconds' % ((${end} - ${start})/60, (${end} - ${start})%60))")

View File

@ -1,9 +0,0 @@
#!/bin/sh
# Helps to run Clang Static Analyzer.
# Please, run this script from folder <root_folder>/scripts.
cd ..
rm -rfv build
mkdir build
cd build
qmake ../Valentina.pro -r -spec linux-clang CONFIG+=debug
scan-build --use-cc clang --use-c++ clang++ make -j$(nproc)

42
scripts/sonar-scanner.sh Executable file
View File

@ -0,0 +1,42 @@
#!/bin/sh
# Analyze project with Sonar cloud on Linux.
# Please, run this script from folder <root_folder>/scripts.
set -x
BUILD_FOLDER=build_sonar
cd ..
rm -rf ../${BUILD_FOLDER}
mkdir ../${BUILD_FOLDER}
QMAKE_PATH=${HOME}/Qt6.6/6.6.0/gcc_64/bin/qmake
PROFILE=qt6Sonar
COMPILER=clang
qbs setup-toolchains /usr/bin/${COMPILER} ${COMPILER}
qbs setup-qt ${QMAKE_PATH} ${PROFILE}
qbs config profiles.${PROFILE}.baseProfile ${COMPILER}
qbs config defaultProfile ${PROFILE}
qbs config --list profiles
build-wrapper-linux-x86-64 \
--out-dir bw-output \
qbs build \
--no-install \
-d ../${BUILD_FOLDER} \
-f valentina.qbs \
--jobs $(nproc) \
profile:${PROFILE} \
config:release \
modules.buildconfig.enableCcache:false
# modules.cpp.linkerVariant:mold
current_branch=$(git rev-parse --abbrev-ref HEAD)
current_revision=$(git rev-parse HEAD)
sonar-scanner \
-Dsonar.cfamily.threads=$(nproc) \
-Dsonar.branch.name=$current_branch \
-Dsonar.scm.revision=$current_revision

View File

@ -1,15 +1,15 @@
sonar.organization=dismine
# must be unique in a given SonarQube instance # must be unique in a given SonarQube instance
sonar.projectKey=dismine_valentina sonar.projectKey=dismine_valentina
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=Valentina sonar.projectName=Valentina
sonar.projectVersion=0.7a sonar.projectVersion=0.7.52
sonar.projectDescription= sonar.projectDescription=
Valentina is a cross-platform patternmaking program which allows designers Valentina is a cross-platform patternmaking program which allows designers
to create and model patterns of clothing. This software allows pattern to create and model patterns of clothing. This software allows pattern
creation, using either standard sizing tables or an individuals set of creation, using either standard sizing tables or an individuals set of
measurements. It blends new technologies with traditional methods to create measurements. It blends new technologies with traditional methods to create
a unique pattern making tool. a unique pattern making tool.
# Encoding of the source code. Default is default system encoding # Encoding of the source code. Default is default system encoding
sonar.sourceEncoding=UTF-8 sonar.sourceEncoding=UTF-8
@ -19,10 +19,11 @@ sonar.exclusions=**/ui_*.h, **/qrc_*.cpp, **/moc_*.cpp
sonar.test.exclusions=src/test/**/* sonar.test.exclusions=src/test/**/*
# The build-wrapper output dir # The build-wrapper output dir
sonar.cfamily.build-wrapper-output=bw-outputs sonar.cfamily.build-wrapper-output=bw-output
sonar.sources=src sonar.sources=src
sonar.cfamily.threads=2 sonar.host.url=https://sonarcloud.io
sonar.links.homepage=https://smart-pattern.com.ua/
sonar.organization=dismine sonar.links.scm=https://gitlab.com/smart-pattern/valentina
sonar.links.issue=https://gitlab.com/smart-pattern/valentina/-/issues