From 12323a3794a73d859777afd7d916ded4736d0e53 Mon Sep 17 00:00:00 2001 From: Marcos Rivereto Date: Mon, 16 Dec 2024 09:30:20 -0300 Subject: [PATCH 01/61] Create sonar-project file --- Example/sonar-project.properties | 116 +++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 Example/sonar-project.properties diff --git a/Example/sonar-project.properties b/Example/sonar-project.properties new file mode 100644 index 0000000..7cfcf60 --- /dev/null +++ b/Example/sonar-project.properties @@ -0,0 +1,116 @@ +# +# Swift SonarQube Plugin - Enables analysis of Swift and Objective-C projects into SonarQube. +# Copyright © 2015 Backelite (${email}) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program. If not, see . +# + +# Sonar Server details +sonar.host.url=http://localhost:9000 +sonar.login=admin +sonar.password=Trustly$Sonar2024 + +# Project Details +sonar.projectKey=org.cocoapods.TrustlySDK-Example +sonar.projectName=TrustlySDKIOS +sonar.projectDescription=This is the Sonar demo application for the code quality check + +# Comment if you have a project with mixed ObjC / Swift +sonar.language=swift + +# Path to source directories +# sonar.sources=SonarDemo,SonarDemoTests,SonarDemoUITests +sonar.sources=. + +# Exclude directories +sonar.test.inclusions=**/*Test*/** +sonar.test.inclusions=*.swift +sonar.exclusions=**/*.xml,Pods/**/*,Reports/**/* +# sonar.inclusions=*.swift + +# Path to test directories (comment if no test) +sonar.tests=Tests + +# Destination Simulator to run surefire +# As string expected in destination argument of xcodebuild command +# Example = sonar.swift.simulator=platform=iOS Simulator,name=iPhone 6,OS=9.2 +# sonar.swift.simulator=platform=iOS Simulator,name=iPhone 7,OS=12.0 +sonar.swift.simulator=platform=iOS Simulator,name=iPhone 16 Pro Max,OS=18.0 + +# Xcode project configuration (.xcodeproj) +# and use the later to specify which project(s) to include in the analysis (comma separated list) +# Specify either xcodeproj or xcodeproj + xcworkspace +sonar.swift.project=TrustlySDK.xcodeproj +sonar.swift.workspace=TrustlySDK.xcworkspace + +# Specify your appname. +# This will be something like "myApp" +# Use when basename is different from targeted scheme. +# Or when slather fails with 'No product binary found' +sonar.swift.appName=TrustlySDK_Example + +# Scheme to build your application +sonar.swift.appScheme=TrustlySDK-Example + +# Configuration to use for your scheme. if you do not specify that the default will be Debug +sonar.swift.appConfiguration=Debug + +########################## +# Optional configuration # +########################## + +# Encoding of the source code +sonar.sourceEncoding=UTF-8 + +# SCM +# sonar.scm.enabled=true +# sonar.scm.url=scm:git:http://xxx + +# JUnit report generated by run-sonar.sh is stored in sonar-reports/TEST-report.xml +# Change it only if you generate the file on your own +# The XML files have to be prefixed by TEST- otherwise they are not processed +sonar.junit.reportsPath=sonar-reports/TEST-report.xml + +# Cobertura report generated by run-sonar.sh is stored in sonar-reports/coverage-swift.xml +# Change it only if you generate the file on your own +sonar.swift.coverage.reportPattern=sonar-reports/coverage-swift*.xml +#sonar.swift.coverage.reportPattern=sonar-reports/cobertura.xml + +# OCLint report generated by run-sonar.sh is stored in sonar-reports/oclint.xml +# Change it only if you generate the file on your own +sonar.swift.swiftlint.report=sonar-reports/*swiftlint.txt + +# Change it only if you generate the file on your own +sonar.swift.tailor.report=sonar-reports/*tailor.txt + +# Paths to exclude from coverage report (surefire, 3rd party libraries etc.) +# sonar.swift.excludedPathsFromCoverage=pattern1,pattern2 +# sonar.swift.excludedPathsFromCoverage=.*Tests.*, + +########################## +# Tailor configuration # +########################## +# Tailor configuration +# -l,--max-line-length=<0-999> maximum Line length (in characters) +# --list-files display Swift source files to be analyzed +# --max-class-length=<0-999> maximum Class length (in lines) +# --max-closure-length=<0-999> maximum Closure length (in lines) +# --max-file-length=<0-999> maximum File length (in lines) +# --max-function-length=<0-999> maximum Function length (in lines) +# --max-name-length=<0-999> maximum Identifier name length (in characters) +# --max-severity= maximum severity +# --max-struct-length=<0-999> maximum Struct length (in lines) +# --min-name-length=<1-999> minimum Identifier name length (in characters) + +sonar.swift.tailor.config=--no-color --max-line-length=100 --max-file-length=500 --max-name-length=40 --max-name-length=40 --min-name-length=4 From 2d82de350158d6ec7bb923293ffc2d63cadbe893 Mon Sep 17 00:00:00 2001 From: Marcos Rivereto Date: Tue, 17 Dec 2024 14:08:32 -0300 Subject: [PATCH 02/61] Create script to create coverage report --- .gitignore | 7 + Dockerfile | 2 + Example/TrustlySDK/ViewController.swift | 31 +- .../TrustlySDK/Session/SessionManager.swift | 2 + run-sonar-swift.sh | 528 ++++++++++++++++++ ...ect.properties => sonar-project.properties | 18 +- xccov-to-sonarqube-generic.sh | 45 ++ 7 files changed, 611 insertions(+), 22 deletions(-) create mode 100644 Dockerfile create mode 100755 run-sonar-swift.sh rename Example/sonar-project.properties => sonar-project.properties (89%) create mode 100644 xccov-to-sonarqube-generic.sh diff --git a/.gitignore b/.gitignore index 9399111..ad3e642 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,10 @@ Carthage/Build # */Podfile.lock */Pods/ + +# Sonar +sonar-reports/* +.scannerwork +compile_commands.json +Coverage.xml +*.log diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ea67406 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,2 @@ +FROM sonarqube:community +COPY sonar-custom-plugin-*.jar /opt/sonarqube/extensions/ \ No newline at end of file diff --git a/Example/TrustlySDK/ViewController.swift b/Example/TrustlySDK/ViewController.swift index 8782b6e..d20d19b 100644 --- a/Example/TrustlySDK/ViewController.swift +++ b/Example/TrustlySDK/ViewController.swift @@ -18,21 +18,22 @@ class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - self.establishData = ["accessId": "", - "merchantId" : "", - "currency" : "USD", - "amount" : "1.00", - "merchantReference" : "", - "paymentType" : "Retrieval", - "returnUrl": "/returnUrl", - "cancelUrl": "/cancelUrl", - "requestSignature": "", - "customer.name": "John", - "customer.address.country": "US", - "metadata.urlScheme": "demoapp://", - "description": "First Data Mobile Test", - "env": "<[int, sandbox, local]>", - "envHost": ""] + self.establishData = [ + "accessId": "A48B73F694C4C8EE6306", + "merchantId" : "110005514", + "currency" : "USD", + "amount" : "1.00", + "merchantReference" : "cac73df7-52b4-47d7-89d3-9628d2cfb65e", + "paymentType" : "Retrieval", + "returnUrl": "/returnUrl", + "cancelUrl": "/cancelUrl", + "requestSignature": "HT5mVOqBXa8ZlvgX2USmPeLns5o=", + "customer.name": "John", + "customer.address.country": "US", + "metadata.urlScheme": "demoapp://", + "description": "First Data Mobile Test", + "env": "int", + "localUrl": "192.168.0.13"] self.trustlyView.onChangeListener { (eventName, attributes) in diff --git a/Sources/TrustlySDK/Session/SessionManager.swift b/Sources/TrustlySDK/Session/SessionManager.swift index 4b3c3ff..a22af2f 100644 --- a/Sources/TrustlySDK/Session/SessionManager.swift +++ b/Sources/TrustlySDK/Session/SessionManager.swift @@ -16,8 +16,10 @@ struct SessionCid: Codable { func isValid(expirationTimeLimit: Int) -> Bool { let dateNow = Date() + let diffs = Calendar.current.dateComponents([.hour], from: expirationTime, to: dateNow) + if let hours = diffs.hour { return hours < expirationTimeLimit } diff --git a/run-sonar-swift.sh b/run-sonar-swift.sh new file mode 100755 index 0000000..89e1c5d --- /dev/null +++ b/run-sonar-swift.sh @@ -0,0 +1,528 @@ +#!/bin/bash +# +# backelite-sonar-swift-plugin - Enables analysis of Swift and Objective-C projects into SonarQube. +# Copyright © 2015 Backelite (${email}) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program. If not, see . +# + +## INSTALLATION: Copy this script somewhere in your PATH +## USAGE: ./run-sonar-swift.sh +## DEBUG: ./run-sonar-swift.sh -v +## WARNING: edit your project parameters in sonar-project.properties rather than modifying this script +# + +# Global parameters +SLATHER_CMD=slather +SWIFTLINT_CMD=swiftlint +TAILOR_CMD=tailor +XCPRETTY_CMD=xcpretty +LIZARD_CMD=lizard +XCODEBUILD_CMD=xcodebuild + + +trap "echo 'Script interrupted by Ctrl+C'; stopProgress; exit 1" SIGHUP SIGINT SIGTERM + +function startProgress() { + while true + do + echo -n "." + sleep 5 + done +} + +function stopProgress() { + if [ "$vflag" = "" -a "$nflag" = "" ]; then + kill $PROGRESS_PID &>/dev/null + fi +} + +function testIsInstalled() { + + hash $1 2>/dev/null + if [ $? -eq 1 ]; then + echo >&2 "ERROR - $1 is not installed or not in your PATH"; exit 1; + fi +} + +function readParameter() { + + variable=$1 + shift + parameter=$1 + shift + + eval $variable="\"$(sed '/^\#/d' sonar-project.properties | grep $parameter | tail -n 1 | cut -d '=' -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')\"" +} + +# Run a set of commands with logging and error handling +function runCommand() { + + # 1st arg: redirect stdout + # 2nd arg: command to run + # 3rd..nth arg: args + redirect=$1 + shift + + command=$1 + shift + + if [ "$nflag" = "on" ]; then + # don't execute command, just echo it + echo + if [ "$redirect" = "/dev/stdout" ]; then + if [ "$vflag" = "on" ]; then + echo "+" $command "$@" + else + echo "+" $command "$@" "> /dev/null" + fi + elif [ "$redirect" != "no" ]; then + echo "+" $command "$@" "> $redirect" + else + echo "+" $command "$@" + fi + + elif [ "$vflag" = "on" ]; then + echo + + if [ "$redirect" = "/dev/stdout" ]; then + set -x #echo on + $command "$@" + returnValue=$? + set +x #echo off + elif [ "$redirect" != "no" ]; then + set -x #echo on + $command "$@" > $redirect + returnValue=$? + set +x #echo off + else + set -x #echo on + $command "$@" + returnValue=$? + set +x #echo off + fi + + if [[ $returnValue != 0 && $returnValue != 5 ]] ; then + stopProgress + echo "ERROR - Command '$command $@' failed with error code: $returnValue" + exit $returnValue + fi + else + + if [ "$redirect" = "/dev/stdout" ]; then + $command "$@" > /dev/null + elif [ "$redirect" != "no" ]; then + $command "$@" > $redirect + else + $command "$@" + fi + + returnValue=$? + if [[ $returnValue != 0 && $returnValue != 5 ]] ; then + stopProgress + echo "ERROR - Command '$command $@' failed with error code: $returnValue" + exit $returnValue + fi + + + echo + fi +} + +## COMMAND LINE OPTIONS +vflag="" +nflag="" +unittests="on" +swiftlint="off" +tailor="off" +lizard="off" +oclint="off" +fauxpas="off" +sonarscanner="" + +while [ $# -gt 0 ] +do + case "$1" in + -v) vflag=on;; + -n) nflag=on;; + -nounittests) unittests="";; + -noswiftlint) swiftlint="";; + -notailor) tailor="";; + -usesonarscanner) sonarscanner="on";; + --) shift; break;; + -*) + echo >&2 "Usage: $0 [-v]" + exit 1;; + *) break;; # terminate while loop + esac + shift +done + +# Usage OK +echo "Running run-sonar-swift.sh..." + +## CHECK PREREQUISITES + +# sonar-project.properties in current directory +if [ ! -f sonar-project.properties ]; then + echo >&2 "ERROR - No sonar-project.properties in current directory"; exit 1; +fi + +## READ PARAMETERS from sonar-project.properties + +#.xcodeproj filename +projectFile=''; readParameter projectFile 'sonar.swift.project' +workspaceFile=''; readParameter workspaceFile 'sonar.swift.workspace' + +# Count projects +if [[ ! -z "$projectFile" ]]; then + projectCount=$(echo $projectFile | sed -n 1'p' | tr ',' '\n' | wc -l | tr -d '[[:space:]]') + if [ "$vflag" = "on" ]; then + echo "Project count is [$projectCount]" + fi +fi + +# Source directories for .swift files +srcDirs=''; readParameter srcDirs 'sonar.sources' +# The name of your application scheme in Xcode +appScheme=''; readParameter appScheme 'sonar.swift.appScheme' +# The app configuration to use for the build +appConfiguration=''; readParameter appConfiguration 'sonar.swift.appConfiguration' +# The name of your test scheme in Xcode +testScheme=''; readParameter testScheme 'sonar.swift.testScheme' +# The name of your binary file (application) +binaryName=''; readParameter binaryName 'sonar.swift.appName' +# Get the path of plist file +plistFile=`xcodebuild -showBuildSettings -project "${projectFile}" | grep -i 'PRODUCT_SETTINGS_PATH' -m 1 | sed 's/[ ]*PRODUCT_SETTINGS_PATH = //'` +# Number version from plist if no sonar.projectVersion +numVerionFromPlist=`defaults read ${plistFile} CFBundleShortVersionString` + +# Read destination simulator +destinationSimulator=''; readParameter destinationSimulator 'sonar.swift.simulator' + +# Read tailor configuration +tailorConfiguration=''; readParameter tailorConfiguration 'sonar.swift.tailor.config' + +# The file patterns to exclude from coverage report +excludedPathsFromCoverage=''; readParameter excludedPathsFromCoverage 'sonar.swift.excludedPathsFromCoverage' + +# Check for mandatory parameters +if [ -z "$projectFile" -o "$projectFile" = " " ] && [ -z "$workspaceFile" -o "$workspaceFile" = " " ]; then + echo >&2 "ERROR - sonar.swift.project or/and sonar.swift.workspace parameter is missing in sonar-project.properties. You must specify which projects (comma-separated list) are application code or which workspace and project to use." + exit 1 +elif [ ! -z "$workspaceFile" ] && [ -z "$projectFile" ]; then + echo >&2 "ERROR - sonar.swift.workspace parameter is present in sonar-project.properties but sonar.swift.project and is not. You must specify which projects (comma-separated list) are application code or which workspace and project to use." + exit 1 +fi +if [ -z "$srcDirs" -o "$srcDirs" = " " ]; then + echo >&2 "ERROR - sonar.sources parameter is missing in sonar-project.properties. You must specify which directories contain your .swift source files (comma-separated list)." + exit 1 +fi +if [ -z "$appScheme" -o "$appScheme" = " " ]; then + echo >&2 "ERROR - sonar.swift.appScheme parameter is missing in sonar-project.properties. You must specify which scheme is used to build your application." + exit 1 +fi +if [ "$unittests" = "on" ]; then + if [ -z "$destinationSimulator" -o "$destinationSimulator" = " " ]; then + echo >&2 "ERROR - sonar.swift.simulator parameter is missing in sonar-project.properties. You must specify which simulator to use." + exit 1 + fi +fi + +# if the appConfiguration is not specified then set to Debug +if [ -z "$appConfiguration" -o "$appConfiguration" = " " ]; then + appConfiguration="Debug" +fi + + + +if [ "$vflag" = "on" ]; then + echo "Xcode project file is: $projectFile" + echo "Xcode workspace file is: $workspaceFile" + echo "Xcode application scheme is: $appScheme" + echo "Number version from plist is: $numVerionFromPlist" + if [ -n "$unittests" ]; then + echo "Destination simulator is: $destinationSimulator" + echo "Excluded paths from coverage are: $excludedPathsFromCoverage" + else + echo "Unit surefire are disabled" + fi +fi + +## SCRIPT + +# Start progress indicator in the background +if [ "$vflag" = "" -a "$nflag" = "" ]; then + startProgress & + # Save PID + PROGRESS_PID=$! +fi + +# Create sonar-reports/ for reports output +if [ "$vflag" = "on" ]; then + echo 'Creating directory sonar-reports/' +fi +rm -rf sonar-reports +mkdir sonar-reports + +# Extracting project information needed later +echo -n 'Extracting Xcode project information' +if [[ "$workspaceFile" != "" ]] ; then + buildCmdPrefix="-workspace $workspaceFile" +else + buildCmdPrefix="-project $projectFile" +fi +buildCmd=($XCODEBUILD_CMD clean build $buildCmdPrefix -scheme $appScheme) +if [[ ! -z "$destinationSimulator" ]]; then + buildCmd+=(-destination "$destinationSimulator" -destination-timeout 360 COMPILER_INDEX_STORE_ENABLE=NO) +fi +runCommand xcodebuild.log "${buildCmd[@]}" +#oclint-xcodebuild # Transform the xcodebuild.log file into a compile_command.json file +cat xcodebuild.log | $XCPRETTY_CMD -r json-compilation-database -o compile_commands.json + +# Objective-C code detection +hasObjC="no" +compileCmdFile=compile_commands.json +minimumSize=3 +actualSize=$(stat -f%z "$compileCmdFile") +echo "actual = $actualSize, min = $minimumSize" +if [ $actualSize -ge $minimumSize ]; then + hasObjC="yes" +fi + +# Unit surefire and coverage +if [ "$unittests" = "on" ]; then + + # Put default xml files with no surefire and no coverage... + echo "" > sonar-reports/TEST-report.xml + + echo -n 'Running surefire' + buildCmd=($XCODEBUILD_CMD clean build test) + if [[ ! -z "$workspaceFile" ]]; then + buildCmd+=(-workspace "$workspaceFile") + elif [[ ! -z "$projectFile" ]]; then + buildCmd+=(-project "$projectFile") + fi + buildCmd+=( -scheme "$appScheme" -configuration "$appConfiguration" -enableCodeCoverage YES -derivedDataPath sonar-reports/) + if [[ ! -z "$destinationSimulator" ]]; then + buildCmd+=(-destination "$destinationSimulator" -destination-timeout 60) + fi + + runCommand sonar-reports/xcodebuild.log "${buildCmd[@]}" + cat sonar-reports/xcodebuild.log | $XCPRETTY_CMD -t --report junit + mv build/reports/junit.xml sonar-reports/TEST-report.xml + + + echo '\nComputing coverage report\n' + + # Build the --exclude flags + excludedCommandLineFlags="" + if [ ! -z "$excludedPathsFromCoverage" -a "$excludedPathsFromCoverage" != " " ]; then + echo $excludedPathsFromCoverage | sed -n 1'p' | tr ',' '\n' > tmpFileRunSonarSh2 + while read word; do + excludedCommandLineFlags+=" -i $word" + done < tmpFileRunSonarSh2 + rm -rf tmpFileRunSonarSh2 + fi + if [ "$vflag" = "on" ]; then + echo "Command line exclusion flags for slather is:$excludedCommandLineFlags" + fi + + firstProject=$(echo $projectFile | sed -n 1'p' | tr ',' '\n' | head -n 1) + + bash xccov-to-sonarqube-generic.sh sonar-reports/Logs/Test/Run-TrustlySDK-Example-*.xcresult/ > sonar-reports/generic-coverage.xml + # slatherCmd=($SLATHER_CMD coverage) + # if [[ ! -z "$binaryName" ]]; then + # slatherCmd+=( --binary-basename "$binaryName") + # fi + + # slatherCmd+=( --input-format profdata $excludedCommandLineFlags --cobertura-xml --output-directory sonar-reports) + + # if [[ ! -z "$workspaceFile" ]]; then + # slatherCmd+=( --workspace "$workspaceFile") + # fi + # slatherCmd+=( --scheme "$appScheme" "$firstProject") + + # echo "${slatherCmd[@]}" + + # runCommand /dev/stdout "${slatherCmd[@]}" + # mv sonar-reports/cobertura.xml sonar-reports/coverage-swift.xml +fi + +# SwiftLint +if [ "$swiftlint" = "on" ]; then + if hash $SWIFTLINT_CMD 2>/dev/null; then + echo -n 'Running SwiftLint...' + + # Build the --include flags + currentDirectory=${PWD##*/} + echo "$srcDirs" | sed -n 1'p' | tr ',' '\n' > tmpFileRunSonarSh + while read word; do + + # Run SwiftLint command + $SWIFTLINT_CMD lint --path "$word" > sonar-reports/"$appScheme"-swiftlint.txt + + done < tmpFileRunSonarSh + rm -rf tmpFileRunSonarSh + else + echo "Skipping SwiftLint (not installed!)" + fi + +else + echo 'Skipping SwiftLint (test purposes only!)' +fi + +# Tailor +if [ "$tailor" = "on" ]; then + if hash $TAILOR_CMD 2>/dev/null; then + echo -n 'Running Tailor...' + + # Build the --include flags + currentDirectory=${PWD##*/} + echo "$srcDirs" | sed -n 1'p' | tr ',' '\n' > tmpFileRunSonarSh + while read word; do + + # Run tailor command + $TAILOR_CMD $tailorConfiguration "$word" > sonar-reports/"$appScheme"-tailor.txt + + done < tmpFileRunSonarSh + rm -rf tmpFileRunSonarSh + else + echo "Skipping Tailor (not installed!)" + fi + +else + echo 'Skipping Tailor!' +fi + +if [ "$oclint" = "on" ] && [ "$hasObjC" = "yes" ]; then + + echo -n 'Running OCLint...' + + # Options + maxPriority=10000 + longLineThreshold=250 + + # Build the --include flags + currentDirectory=${PWD##*/} + echo "$srcDirs" | sed -n 1'p' | tr ',' '\n' > tmpFileRunSonarSh + while read word; do + + includedCommandLineFlags=" --include .*/${currentDirectory}/${word}/*" + if [ "$vflag" = "on" ]; then + echo + echo -n "Path included in oclint analysis is:$includedCommandLineFlags" + fi + # Run OCLint with the right set of compiler options + runCommand no oclint-json-compilation-database -v $includedCommandLineFlags -- -rc LONG_LINE=$longLineThreshold -max-priority-1 $maxPriority -max-priority-2 $maxPriority -max-priority-3 $maxPriority -report-type pmd -o sonar-reports/$appScheme-oclint.xml + + done < tmpFileRunSonarSh + rm -rf tmpFileRunSonarSh + + +else + echo 'Skipping OCLint (test purposes only!)' +fi + +#FauxPas +if [ "$fauxpas" = "on" ] && [ "$hasObjC" = "yes" ]; then + hash fauxpas 2>/dev/null + if [ $? -eq 0 ]; then + + echo -n 'Running FauxPas...' + + if [ "$projectCount" = "1" ] + then + + fauxpas -o json check $projectFile --workspace $workspaceFile --scheme $appScheme > sonar-reports/fauxpas.json + + + else + + echo $projectFile | sed -n 1'p' | tr ',' '\n' > tmpFileRunSonarSh + while read projectName; do + + $XCODEBUILD_CMD -list -project $projectName | sed -n '/Schemes/,$p' | while read scheme + do + + if [ "$scheme" = "" ] + then + exit + fi + + if [ "$scheme" == "${scheme/Schemes/}" ] + then + if [ "$scheme" != "$testScheme" ] + then + projectBaseDir=$(dirname $projectName) + workspaceRelativePath=$(python -c "import os.path; print os.path.relpath('$workspaceFile', '$projectBaseDir')") + fauxpas -o json check $projectName --workspace $workspaceRelativePath --scheme $scheme > sonar-reports/$(basename $projectName .xcodeproj)-$scheme-fauxpas.json + fi + fi + + done + + done < tmpFileRunSonarSh + rm -rf tmpFileRunSonarSh + + fi + + else + echo 'Skipping FauxPas (not installed)' + fi +else + echo 'Skipping FauxPas' +fi + +# Lizard Complexity +if [ "$lizard" = "on" ]; then + if hash $LIZARD_CMD 2>/dev/null; then + echo -n 'Running Lizard...' + $LIZARD_CMD --xml "$srcDirs" > sonar-reports/lizard-report.xml + else + echo 'Skipping Lizard (not installed!)' + fi +else + echo 'Skipping Lizard (test purposes only!)' +fi + +# The project version from properties file +numVersionSonarRunner=''; readParameter numVersionSonarRunner 'sonar.projectVersion' +if [ -z "$numVersionSonarRunner" -o "$numVersionSonarRunner" = " " ]; then + numVersionSonarRunner=" --define sonar.projectVersion=$numVerionFromPlist" +else + #if we have version number in properties file, we don't overide numVersion for sonar-runner/sonar-scanner command + numVersionSonarRunner=''; +fi +# SonarQube +if [ "$sonarscanner" = "on" ]; then + echo -n 'Running SonarQube using SonarQube Scanner' + if hash /dev/stdout sonar-scanner 2>/dev/null; then + runCommand /dev/stdout sonar-scanner $numVersionSonarRunner + else + echo 'Skipping sonar-scanner (not installed!)' + fi +else + echo -n 'Running SonarQube using SonarQube Runner' + if hash /dev/stdout sonar-runner 2>/dev/null; then + runCommand /dev/stdout sonar-runner $numVersionSonarRunner + else + runCommand /dev/stdout sonar-scanner $numVersionSonarRunner + fi +fi + +# Kill progress indicator +stopProgress + +exit 0 \ No newline at end of file diff --git a/Example/sonar-project.properties b/sonar-project.properties similarity index 89% rename from Example/sonar-project.properties rename to sonar-project.properties index 7cfcf60..bdf402d 100644 --- a/Example/sonar-project.properties +++ b/sonar-project.properties @@ -19,7 +19,8 @@ # Sonar Server details sonar.host.url=http://localhost:9000 sonar.login=admin -sonar.password=Trustly$Sonar2024 +sonar.password=Sonarqube$24 +# sonar.token=sqp_8cba87ecfe9b5459a833660cabcdc5e8a138deb8 # Project Details sonar.projectKey=org.cocoapods.TrustlySDK-Example @@ -40,7 +41,7 @@ sonar.exclusions=**/*.xml,Pods/**/*,Reports/**/* # sonar.inclusions=*.swift # Path to test directories (comment if no test) -sonar.tests=Tests +sonar.tests=Example/Tests # Destination Simulator to run surefire # As string expected in destination argument of xcodebuild command @@ -51,8 +52,8 @@ sonar.swift.simulator=platform=iOS Simulator,name=iPhone 16 Pro Max,OS=18.0 # Xcode project configuration (.xcodeproj) # and use the later to specify which project(s) to include in the analysis (comma separated list) # Specify either xcodeproj or xcodeproj + xcworkspace -sonar.swift.project=TrustlySDK.xcodeproj -sonar.swift.workspace=TrustlySDK.xcworkspace +sonar.swift.project=Example/TrustlySDK.xcodeproj +sonar.swift.workspace=Example/TrustlySDK.xcworkspace # Specify your appname. # This will be something like "myApp" @@ -84,8 +85,11 @@ sonar.junit.reportsPath=sonar-reports/TEST-report.xml # Cobertura report generated by run-sonar.sh is stored in sonar-reports/coverage-swift.xml # Change it only if you generate the file on your own -sonar.swift.coverage.reportPattern=sonar-reports/coverage-swift*.xml -#sonar.swift.coverage.reportPattern=sonar-reports/cobertura.xml +# sonar.swift.coverage.reportPattern=sonar-reports/coverage-swift*.xml +# sonar.swift.coverage.reportPaths=sonar-reports/coverage-swift.xml +sonar.coverageReportPaths=sonar-reports/generic-coverage.xml +# sonar.cobertura.reportPath=sonar-reports/coverage-swift.xml +# sonar.swift.coverage.reportPattern=sonar-reports/cobertura.xml # OCLint report generated by run-sonar.sh is stored in sonar-reports/oclint.xml # Change it only if you generate the file on your own @@ -112,5 +116,5 @@ sonar.swift.tailor.report=sonar-reports/*tailor.txt # --max-severity= maximum severity # --max-struct-length=<0-999> maximum Struct length (in lines) # --min-name-length=<1-999> minimum Identifier name length (in characters) - +sonar.verbose=true sonar.swift.tailor.config=--no-color --max-line-length=100 --max-file-length=500 --max-name-length=40 --max-name-length=40 --min-name-length=4 diff --git a/xccov-to-sonarqube-generic.sh b/xccov-to-sonarqube-generic.sh new file mode 100644 index 0000000..d069e04 --- /dev/null +++ b/xccov-to-sonarqube-generic.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +set -euo pipefail + +function convert_xccov_to_xml { + sed -n \ + -e '/:$/s/&/\&/g;s/^\(.*\):$/ /p' \ + -e 's/^ *\([0-9][0-9]*\): 0.*$/ /p' \ + -e 's/^ *\([0-9][0-9]*\): [1-9].*$/ /p' \ + -e 's/^$/ <\/file>/p' +} + +function xccov_to_generic { + local xcresult="$1" + + echo '' + xcrun xccov view --archive "$xcresult" | convert_xccov_to_xml + echo '' +} + +function check_xcode_version() { + local major=${1:-0} minor=${2:-0} + return $(( (major >= 14) || (major == 13 && minor >= 3) )) +} + +if ! xcode_version="$(xcodebuild -version | sed -n '1s/^Xcode \([0-9.]*\)$/\1/p')"; then + echo 'Failed to get Xcode version' 1>&2 + exit 1 +elif check_xcode_version ${xcode_version//./ }; then + echo "Xcode version '$xcode_version' not supported, version 13.3 or above is required" 1>&2; + exit 1 +fi + +xcresult="$1" +if [[ $# -ne 1 ]]; then + echo "Invalid number of arguments. Expecting 1 path matching '*.xcresult'" + exit 1 +elif [[ ! -d $xcresult ]]; then + echo "Path not found: $xcresult" 1>&2; + exit 1 +elif [[ $xcresult != *".xcresult"* ]]; then + echo "Expecting input to match '*.xcresult', got: $xcresult" 1>&2; + exit 1 +fi + +xccov_to_generic "$xcresult" \ No newline at end of file From 941e70fdf042641638bb9d31c1028b1bd9ceb363 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 12:05:59 -0300 Subject: [PATCH 03/61] Add to test --- .github/workflows/check_sonar_tests.yml | 67 +++++++++++++++++++++++++ .github/workflows/trigger_sonar.yml | 42 ---------------- 2 files changed, 67 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/check_sonar_tests.yml delete mode 100644 .github/workflows/trigger_sonar.yml diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml new file mode 100644 index 0000000..34e03d7 --- /dev/null +++ b/.github/workflows/check_sonar_tests.yml @@ -0,0 +1,67 @@ +name: CI - iOS + +on: + pull_request: + types: [opened, edited, reopened, synchronize] + workflow_dispatch: + +env: + GH_TOKEN: ${{ secrets.GIT_TOKEN_SECRET }} + OWNER: ${{ github.repository_owner }} + REPO: ${{ github.event.repository.name }} + PR_NUMBER: ${{ github.event.number }} + SONAR_HOST_URL: "https://sonarqube.trustly.one" + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_SECRET }} + SONAR_PROJECT_KEY: "trustly-ios" + SONAR_PROJECT_NAME: "trustly-ios" + +jobs: + SonarQube: + runs-on: macOS-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Install dependencies + run: | + # Install required tools + brew update + brew install cocoapods swiftlint oclint + sudo gem install -n /usr/local/bin xcpretty + + # Install project dependencies + pod install --project-directory=Example + + - name: Run Sonar-Swift Script + run: | + chmod +x ./run-sonar-swift.sh + ./run-sonar-swift.sh + + - name: Verify Coverage Report + run: | + if [ -f "sonar-reports/generic-coverage.xml" ]; then + echo "Coverage report generated successfully: sonar-reports/generic-coverage.xml" + else + echo "Coverage report not found!" && exit 1 + fi + + + - name: Run SonarQube Analysis + run: | + sonar-scanner -X \ + -Dsonar.host.url=${SONAR_HOST_URL} \ + -Dsonar.login=${SONAR_TOKEN} \ + -Dsonar.projectKey=${SONAR_PROJECT_KEY} \ + -Dsonar.projectName=${SONAR_PROJECT_NAME} \ + -Dsonar.pullrequest.base="${{ github.base_ref }}" \ + -Dsonar.pullrequest.branch="${{ github.head_ref }}" \ + -Dsonar.pullrequest.key="${{ github.event.pull_request.number }}" \ + -Dsonar.scm.revision="${{ github.event.pull_request.head.sha }}" \ + -Dsonar.coverageReportPaths=sonar-reports/generic-coverage.xml \ + -Dsonar.scm.disabled=true \ + -Dsonar.language=swift \ + -Dsonar.sources="." \ + -Dsonar.verbose=true \ No newline at end of file diff --git a/.github/workflows/trigger_sonar.yml b/.github/workflows/trigger_sonar.yml deleted file mode 100644 index 919260b..0000000 --- a/.github/workflows/trigger_sonar.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Trigger Sonar -on: - pull_request: - types: [opened, synchronize, reopened] -env: - GH_TOKEN: ${{ secrets.GIT_TOKEN_SECRET }} - BAMBOO_TOKEN_SECRET: ${{ secrets.BAMBOO_TOKEN_SECRET }} - GITHUB_TOKEN_SECRET: ${{ secrets.GIT_TOKEN_SECRET }} - GITHUB_REPO_OWNER: ${{ github.repository_owner }} - GITHUB_REPO: ${{ github.event.repository.name }} - GITHUB_PR_ID: ${{ github.event.number }} -jobs: - trigger_sonar: - if: | - github.repository == 'TrustlyInc/trustly-ios' && - github.event.pull_request.mergeable_status != 'dirty' - runs-on: ubuntu-latest - steps: - - name: Checkout source code - run: git clone -q https://${GITHUB_TOKEN_SECRET}@github.com/${GITHUB_REPO_OWNER}/${GITHUB_REPO}.git --depth=2 - - name: Trigger Bamboo Pipeline - SonarQube Pull Request Analysis - run: | - cd "${GITHUB_REPO}" || exit - - echo -e "Github PR ID : ${GITHUB_PR_ID}" - echo -e "Github repository: ${GITHUB_REPO}" - - echo -e "Trigger Bamboo Pipeline" - response=$(curl --request POST \ - "https://bamboo.paywithmybank.com/rest/api/latest/queue/CAS-SATAPR?bamboo.GITHUB_PR_ID=${GITHUB_PR_ID}" \ - --data "stage&executeAllStages" \ - --header "Authorization: Bearer ${BAMBOO_TOKEN_SECRET}" \ - --write-out "%{http_code}" \ - --silent \ - --output /dev/null) - - if [ "${response}" -eq 200 ]; then - echo "Pipeline triggered successfully." - else - echo "Failed to trigger pipeline. HTTP status code: ${response}" - fi - shell: bash \ No newline at end of file From 1ba9803a3e43e2a8e4c0b8dc7a578beff141f3d8 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 12:13:15 -0300 Subject: [PATCH 04/61] Add to test --- .github/workflows/check_sonar_tests.yml | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index 34e03d7..1ee6454 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -27,14 +27,24 @@ jobs: - name: Install dependencies run: | - # Install required tools - brew update - brew install cocoapods swiftlint oclint - sudo gem install -n /usr/local/bin xcpretty + # Update Homebrew + brew update - # Install project dependencies - pod install --project-directory=Example + # Install SwiftLint + brew install swiftlint + # Install Tailor + brew install tailor + + # Install xcpretty + sudo gem install -n /usr/local/bin xcpretty + + # Install Lizard + brew install lizard + + # Install xcodebuild (part of Xcode Command Line Tools) + xcode-select --install || echo "Xcode Command Line Tools already installed" + - name: Run Sonar-Swift Script run: | chmod +x ./run-sonar-swift.sh From e74abcc3593cd3eff6305c1eb8acce54df6a14d3 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 12:18:47 -0300 Subject: [PATCH 05/61] Add to test --- .github/workflows/check_sonar_tests.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index 1ee6454..6798644 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -44,7 +44,18 @@ jobs: # Install xcodebuild (part of Xcode Command Line Tools) xcode-select --install || echo "Xcode Command Line Tools already installed" - + + - name: Clean Derived Data + run: | + rm -rf ~/Library/Developer/Xcode/DerivedData + + - name: Run Build and Tests + run: | + xcodebuild -workspace Example/TrustlySDK.xcworkspace \ + -scheme TrustlySDK-Example \ + -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.4' \ + test -quiet | xcpretty + - name: Run Sonar-Swift Script run: | chmod +x ./run-sonar-swift.sh From 166b236f13234ad2a36357d9d8b78d1fca3973de Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 12:27:39 -0300 Subject: [PATCH 06/61] Add to test --- .github/workflows/check_sonar_tests.yml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index 6798644..b2a9904 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -45,10 +45,23 @@ jobs: # Install xcodebuild (part of Xcode Command Line Tools) xcode-select --install || echo "Xcode Command Line Tools already installed" - - name: Clean Derived Data + - name: Clean Xcode Caches run: | - rm -rf ~/Library/Developer/Xcode/DerivedData - + # Remover caches do Xcode + rm -rf ~/Library/Caches/com.apple.dt.Xcode + + # Remover arquivos temporários do Xcode + rm -rf ~/Library/Developer/Xcode/DerivedData + + # Remover caches de compilação específicos + rm -rf ~/Library/Developer/Xcode/Archives + rm -rf ~/Library/Developer/Xcode/iOS\ Device\ Logs + + # Opcional: Remover preferências do Xcode + rm -rf ~/Library/Preferences/com.apple.dt.Xcode.plist + + echo "Xcode caches and temporary files cleared!" + - name: Run Build and Tests run: | xcodebuild -workspace Example/TrustlySDK.xcworkspace \ From 0800d489e35e28923c84cbf1251e4804758b62e8 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 12:30:06 -0300 Subject: [PATCH 07/61] Add to test --- .github/workflows/check_sonar_tests.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index b2a9904..8baf190 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -61,13 +61,6 @@ jobs: rm -rf ~/Library/Preferences/com.apple.dt.Xcode.plist echo "Xcode caches and temporary files cleared!" - - - name: Run Build and Tests - run: | - xcodebuild -workspace Example/TrustlySDK.xcworkspace \ - -scheme TrustlySDK-Example \ - -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.4' \ - test -quiet | xcpretty - name: Run Sonar-Swift Script run: | From bdc96c1a7b2930423be5853c758dc2d1cff6fc6d Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 12:40:55 -0300 Subject: [PATCH 08/61] Add to test --- .github/workflows/check_sonar_tests.yml | 36 ++++++++++++++++++------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index 8baf190..6394aa1 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -42,24 +42,41 @@ jobs: # Install Lizard brew install lizard - # Install xcodebuild (part of Xcode Command Line Tools) + # Ensure xcodebuild is available (part of Xcode Command Line Tools) xcode-select --install || echo "Xcode Command Line Tools already installed" + # Install NVM (Node Version Manager) + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash + + # Source nvm to make it available in the current session + source ~/.bash_profile || source ~/.zshrc + + # Install a specific version of Node.js (example: v16) + nvm install 16 + nvm use 16 + + # Optionally, you can set a default version + nvm alias default 16 + + # Verify Node and NVM installation + node -v + npm -v + - name: Clean Xcode Caches run: | - # Remover caches do Xcode + # Remove Xcode caches rm -rf ~/Library/Caches/com.apple.dt.Xcode - - # Remover arquivos temporários do Xcode + + # Remove Xcode derived data rm -rf ~/Library/Developer/Xcode/DerivedData - - # Remover caches de compilação específicos + + # Remove Xcode build caches rm -rf ~/Library/Developer/Xcode/Archives rm -rf ~/Library/Developer/Xcode/iOS\ Device\ Logs - - # Opcional: Remover preferências do Xcode + + # Optionally: Remove Xcode preferences rm -rf ~/Library/Preferences/com.apple.dt.Xcode.plist - + echo "Xcode caches and temporary files cleared!" - name: Run Sonar-Swift Script @@ -75,7 +92,6 @@ jobs: echo "Coverage report not found!" && exit 1 fi - - name: Run SonarQube Analysis run: | sonar-scanner -X \ From 45a7b13dd7db1053f76d0852e8b0ed9d415496c1 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 13:49:22 -0300 Subject: [PATCH 09/61] Add to test --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index bdf402d..539bbdb 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -47,7 +47,7 @@ sonar.tests=Example/Tests # As string expected in destination argument of xcodebuild command # Example = sonar.swift.simulator=platform=iOS Simulator,name=iPhone 6,OS=9.2 # sonar.swift.simulator=platform=iOS Simulator,name=iPhone 7,OS=12.0 -sonar.swift.simulator=platform=iOS Simulator,name=iPhone 16 Pro Max,OS=18.0 +sonar.swift.simulator=platform:iOS Simulator, id:9A44F4CC-2BAF-4124-B4EF-BD021854DF9E, OS:17.4, name:iPhone 15 Pro Max # Xcode project configuration (.xcodeproj) # and use the later to specify which project(s) to include in the analysis (comma separated list) From 8185f29913dcaf49af373dcf236b2f83bc8ad061 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 13:51:56 -0300 Subject: [PATCH 10/61] Add to test --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 539bbdb..e5e7cc2 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -47,7 +47,7 @@ sonar.tests=Example/Tests # As string expected in destination argument of xcodebuild command # Example = sonar.swift.simulator=platform=iOS Simulator,name=iPhone 6,OS=9.2 # sonar.swift.simulator=platform=iOS Simulator,name=iPhone 7,OS=12.0 -sonar.swift.simulator=platform:iOS Simulator, id:9A44F4CC-2BAF-4124-B4EF-BD021854DF9E, OS:17.4, name:iPhone 15 Pro Max +sonar.swift.simulator=platform:iOS Simulator, OS:17.4, name:iPhone 15 Pro Max # Xcode project configuration (.xcodeproj) # and use the later to specify which project(s) to include in the analysis (comma separated list) From 6d3c58eea1970f2b6e7b215e1815ccf4f1cf6611 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 13:53:56 -0300 Subject: [PATCH 11/61] Add to test --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index e5e7cc2..a816066 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -47,7 +47,7 @@ sonar.tests=Example/Tests # As string expected in destination argument of xcodebuild command # Example = sonar.swift.simulator=platform=iOS Simulator,name=iPhone 6,OS=9.2 # sonar.swift.simulator=platform=iOS Simulator,name=iPhone 7,OS=12.0 -sonar.swift.simulator=platform:iOS Simulator, OS:17.4, name:iPhone 15 Pro Max +sonar.swift.simulator=platform=iOS Simulator,name=iPhone 15,OS=17.4' # Xcode project configuration (.xcodeproj) # and use the later to specify which project(s) to include in the analysis (comma separated list) From e0c2260e1c639868482e7fdbcee51e965984581d Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 13:57:34 -0300 Subject: [PATCH 12/61] Add to test --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index a816066..a39a58c 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -47,7 +47,7 @@ sonar.tests=Example/Tests # As string expected in destination argument of xcodebuild command # Example = sonar.swift.simulator=platform=iOS Simulator,name=iPhone 6,OS=9.2 # sonar.swift.simulator=platform=iOS Simulator,name=iPhone 7,OS=12.0 -sonar.swift.simulator=platform=iOS Simulator,name=iPhone 15,OS=17.4' +sonar.swift.simulator=platform:iOS Simulator, OS:17.4, name:iPhone 15 # Xcode project configuration (.xcodeproj) # and use the later to specify which project(s) to include in the analysis (comma separated list) From 95c78fb0004086cdb3b18e9b90c4fef68d02acff Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 14:00:22 -0300 Subject: [PATCH 13/61] Add to test --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index a39a58c..a816066 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -47,7 +47,7 @@ sonar.tests=Example/Tests # As string expected in destination argument of xcodebuild command # Example = sonar.swift.simulator=platform=iOS Simulator,name=iPhone 6,OS=9.2 # sonar.swift.simulator=platform=iOS Simulator,name=iPhone 7,OS=12.0 -sonar.swift.simulator=platform:iOS Simulator, OS:17.4, name:iPhone 15 +sonar.swift.simulator=platform=iOS Simulator,name=iPhone 15,OS=17.4' # Xcode project configuration (.xcodeproj) # and use the later to specify which project(s) to include in the analysis (comma separated list) From ad1b5c4e39e34fcc5d3cfa289aa5869c5872ae35 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 14:02:30 -0300 Subject: [PATCH 14/61] Add to test --- .github/workflows/check_sonar_tests.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index 6394aa1..d22c5e0 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -79,6 +79,13 @@ jobs: echo "Xcode caches and temporary files cleared!" + - name: Run Xcode Build + run: | + xcodebuild -workspace Example/TrustlySDK.xcworkspace \ + -scheme TrustlySDK-Example \ + -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.4' \ + test || true + - name: Run Sonar-Swift Script run: | chmod +x ./run-sonar-swift.sh From 4f28c0b8cb5ba674f8de64a91eb675823fa92a62 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 14:04:44 -0300 Subject: [PATCH 15/61] Add to test --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index a816066..481518f 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -47,7 +47,7 @@ sonar.tests=Example/Tests # As string expected in destination argument of xcodebuild command # Example = sonar.swift.simulator=platform=iOS Simulator,name=iPhone 6,OS=9.2 # sonar.swift.simulator=platform=iOS Simulator,name=iPhone 7,OS=12.0 -sonar.swift.simulator=platform=iOS Simulator,name=iPhone 15,OS=17.4' +# sonar.swift.simulator=platform=iOS Simulator,name=iPhone 15,OS=17.4' # Xcode project configuration (.xcodeproj) # and use the later to specify which project(s) to include in the analysis (comma separated list) From c4b50ba6bef90fb4dd174efef47c586bc09fe4ba Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 14:11:16 -0300 Subject: [PATCH 16/61] Add to test --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 481518f..04ad861 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -47,7 +47,7 @@ sonar.tests=Example/Tests # As string expected in destination argument of xcodebuild command # Example = sonar.swift.simulator=platform=iOS Simulator,name=iPhone 6,OS=9.2 # sonar.swift.simulator=platform=iOS Simulator,name=iPhone 7,OS=12.0 -# sonar.swift.simulator=platform=iOS Simulator,name=iPhone 15,OS=17.4' +sonar.swift.simulator=platform=iOS Simulator,name=iPhone 15,OS=17.4 # Xcode project configuration (.xcodeproj) # and use the later to specify which project(s) to include in the analysis (comma separated list) From 28ce4e2d22294b9cc2491484aaed715214a98a4b Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 14:14:55 -0300 Subject: [PATCH 17/61] Add to test --- .github/workflows/check_sonar_tests.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index d22c5e0..6394aa1 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -79,13 +79,6 @@ jobs: echo "Xcode caches and temporary files cleared!" - - name: Run Xcode Build - run: | - xcodebuild -workspace Example/TrustlySDK.xcworkspace \ - -scheme TrustlySDK-Example \ - -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.4' \ - test || true - - name: Run Sonar-Swift Script run: | chmod +x ./run-sonar-swift.sh From 5bfee67ee1b75c558b32c192fea7ca210970381f Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 14:17:09 -0300 Subject: [PATCH 18/61] Add to test --- .github/workflows/check_sonar_tests.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index 6394aa1..8caf3f0 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -79,6 +79,22 @@ jobs: echo "Xcode caches and temporary files cleared!" + - name: Run Xcode Build + run: | + echo "Cleaning build directories..." + rm -rf ~/Library/Developer/Xcode/DerivedData + + echo "Running xcodebuild..." + xcodebuild clean build \ + -workspace Example/TrustlySDK.xcworkspace \ + -scheme TrustlySDK-Example \ + -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.4' \ + -destination-timeout 360 \ + COMPILER_INDEX_STORE_ENABLE=NO \ + -verbose || exit 65 + + echo "Build completed successfully!" + - name: Run Sonar-Swift Script run: | chmod +x ./run-sonar-swift.sh From ee46f1c631a55b848ecbfb2d1471c6228916d2d7 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 14:19:48 -0300 Subject: [PATCH 19/61] Add to test --- .github/workflows/check_sonar_tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index 8caf3f0..64c5057 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -88,7 +88,6 @@ jobs: xcodebuild clean build \ -workspace Example/TrustlySDK.xcworkspace \ -scheme TrustlySDK-Example \ - -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.4' \ -destination-timeout 360 \ COMPILER_INDEX_STORE_ENABLE=NO \ -verbose || exit 65 From aae8f9a53988659b4b17fa80a1cc4988d997a384 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 14:25:41 -0300 Subject: [PATCH 20/61] Add to test --- .github/workflows/check_sonar_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index 64c5057..0363d52 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -89,7 +89,7 @@ jobs: -workspace Example/TrustlySDK.xcworkspace \ -scheme TrustlySDK-Example \ -destination-timeout 360 \ - COMPILER_INDEX_STORE_ENABLE=NO \ + COMPILER_INDEX_STORE_ENABLE=YES \ -verbose || exit 65 echo "Build completed successfully!" From b942331f81f7e4207faeab63e16ffef9b68cc085 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 14:28:11 -0300 Subject: [PATCH 21/61] Add to test --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 04ad861..3db8fed 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -59,7 +59,7 @@ sonar.swift.workspace=Example/TrustlySDK.xcworkspace # This will be something like "myApp" # Use when basename is different from targeted scheme. # Or when slather fails with 'No product binary found' -sonar.swift.appName=TrustlySDK_Example +sonar.swift.appName=TrustlySDK # Scheme to build your application sonar.swift.appScheme=TrustlySDK-Example From 17a3fd22731522d0595ff0d475751996188f3f9a Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 14:30:06 -0300 Subject: [PATCH 22/61] Add to test --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 3db8fed..04ad861 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -59,7 +59,7 @@ sonar.swift.workspace=Example/TrustlySDK.xcworkspace # This will be something like "myApp" # Use when basename is different from targeted scheme. # Or when slather fails with 'No product binary found' -sonar.swift.appName=TrustlySDK +sonar.swift.appName=TrustlySDK_Example # Scheme to build your application sonar.swift.appScheme=TrustlySDK-Example From ae0fd1bbe1f962e3ca6c2caaa81940dc73cc121b Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 14:31:44 -0300 Subject: [PATCH 23/61] Add to test --- .github/workflows/check_sonar_tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index 0363d52..7f7bde5 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -87,9 +87,9 @@ jobs: echo "Running xcodebuild..." xcodebuild clean build \ -workspace Example/TrustlySDK.xcworkspace \ - -scheme TrustlySDK-Example \ + -scheme TrustlySDK_Example \ -destination-timeout 360 \ - COMPILER_INDEX_STORE_ENABLE=YES \ + COMPILER_INDEX_STORE_ENABLE=NO \ -verbose || exit 65 echo "Build completed successfully!" From 5948548ce17cdad0a691fa1654341e8bfb1bfa43 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 14:32:53 -0300 Subject: [PATCH 24/61] Add to test --- .github/workflows/check_sonar_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index 7f7bde5..cf4f39d 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -89,7 +89,7 @@ jobs: -workspace Example/TrustlySDK.xcworkspace \ -scheme TrustlySDK_Example \ -destination-timeout 360 \ - COMPILER_INDEX_STORE_ENABLE=NO \ + COMPILER_INDEX_STORE_ENABLE=YES \ -verbose || exit 65 echo "Build completed successfully!" From c542071beaf7073c86781d3b2040ee354c4d92bd Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 14:34:15 -0300 Subject: [PATCH 25/61] Add to test --- .github/workflows/check_sonar_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index cf4f39d..6ea8735 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -87,7 +87,7 @@ jobs: echo "Running xcodebuild..." xcodebuild clean build \ -workspace Example/TrustlySDK.xcworkspace \ - -scheme TrustlySDK_Example \ + -scheme TrustlySDK \ -destination-timeout 360 \ COMPILER_INDEX_STORE_ENABLE=YES \ -verbose || exit 65 From 46aee94e173ef1b4320a638bfb4412ddf9e15327 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 14:35:46 -0300 Subject: [PATCH 26/61] Add to test --- .github/workflows/check_sonar_tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index 6ea8735..e1a5213 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -87,7 +87,6 @@ jobs: echo "Running xcodebuild..." xcodebuild clean build \ -workspace Example/TrustlySDK.xcworkspace \ - -scheme TrustlySDK \ -destination-timeout 360 \ COMPILER_INDEX_STORE_ENABLE=YES \ -verbose || exit 65 From 0f95ce98b8504ba3b266c13ca099f2c5b5c3ae62 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 14:37:36 -0300 Subject: [PATCH 27/61] Add to test --- .github/workflows/check_sonar_tests.yml | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index e1a5213..7e6f5d7 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -77,21 +77,7 @@ jobs: # Optionally: Remove Xcode preferences rm -rf ~/Library/Preferences/com.apple.dt.Xcode.plist - echo "Xcode caches and temporary files cleared!" - - - name: Run Xcode Build - run: | - echo "Cleaning build directories..." - rm -rf ~/Library/Developer/Xcode/DerivedData - - echo "Running xcodebuild..." - xcodebuild clean build \ - -workspace Example/TrustlySDK.xcworkspace \ - -destination-timeout 360 \ - COMPILER_INDEX_STORE_ENABLE=YES \ - -verbose || exit 65 - - echo "Build completed successfully!" + echo "Xcode caches and temporary files cleared!" - name: Run Sonar-Swift Script run: | From 25bec83d3c43daa2c06b7fc2bf891c6381645aaf Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 14:41:48 -0300 Subject: [PATCH 28/61] Add to test --- run-sonar-swift.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run-sonar-swift.sh b/run-sonar-swift.sh index 89e1c5d..6cf83b4 100755 --- a/run-sonar-swift.sh +++ b/run-sonar-swift.sh @@ -204,9 +204,9 @@ testScheme=''; readParameter testScheme 'sonar.swift.testScheme' # The name of your binary file (application) binaryName=''; readParameter binaryName 'sonar.swift.appName' # Get the path of plist file -plistFile=`xcodebuild -showBuildSettings -project "${projectFile}" | grep -i 'PRODUCT_SETTINGS_PATH' -m 1 | sed 's/[ ]*PRODUCT_SETTINGS_PATH = //'` +plistFile=$(xcodebuild -showBuildSettings -project "${projectFile}" | grep -i 'PRODUCT_SETTINGS_PATH' -m 1 | sed 's/[ ]*PRODUCT_SETTINGS_PATH = //') # Number version from plist if no sonar.projectVersion -numVerionFromPlist=`defaults read ${plistFile} CFBundleShortVersionString` +numVerionFromPlist=$(defaults read ${plistFile} CFBundleShortVersionString)s # Read destination simulator destinationSimulator=''; readParameter destinationSimulator 'sonar.swift.simulator' From 26c2706b5063d7c387c265f824233f84e7a6cfe6 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 14:48:40 -0300 Subject: [PATCH 29/61] Add to test --- .github/workflows/check_sonar_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index 7e6f5d7..1f133a5 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -82,7 +82,7 @@ jobs: - name: Run Sonar-Swift Script run: | chmod +x ./run-sonar-swift.sh - ./run-sonar-swift.sh + ./run-sonar-swift.sh -v - name: Verify Coverage Report run: | From 9d43407f01f8b98f3b3a5109b460803c9fd547f6 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 14:50:32 -0300 Subject: [PATCH 30/61] Add to test --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 04ad861..960f019 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -47,7 +47,7 @@ sonar.tests=Example/Tests # As string expected in destination argument of xcodebuild command # Example = sonar.swift.simulator=platform=iOS Simulator,name=iPhone 6,OS=9.2 # sonar.swift.simulator=platform=iOS Simulator,name=iPhone 7,OS=12.0 -sonar.swift.simulator=platform=iOS Simulator,name=iPhone 15,OS=17.4 +# sonar.swift.simulator=platform=iOS Simulator,name=iPhone 15,OS=17.4 # Xcode project configuration (.xcodeproj) # and use the later to specify which project(s) to include in the analysis (comma separated list) From 9893c1810c83868d9fec8c6ba853eb497a4fa037 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 14:57:46 -0300 Subject: [PATCH 31/61] Add to test --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 960f019..04ad861 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -47,7 +47,7 @@ sonar.tests=Example/Tests # As string expected in destination argument of xcodebuild command # Example = sonar.swift.simulator=platform=iOS Simulator,name=iPhone 6,OS=9.2 # sonar.swift.simulator=platform=iOS Simulator,name=iPhone 7,OS=12.0 -# sonar.swift.simulator=platform=iOS Simulator,name=iPhone 15,OS=17.4 +sonar.swift.simulator=platform=iOS Simulator,name=iPhone 15,OS=17.4 # Xcode project configuration (.xcodeproj) # and use the later to specify which project(s) to include in the analysis (comma separated list) From adfc3ab6bd65ccc96f0b72adc51cab5b8f238ba1 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 15:01:08 -0300 Subject: [PATCH 32/61] Add to test --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 04ad861..1736b93 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -47,7 +47,7 @@ sonar.tests=Example/Tests # As string expected in destination argument of xcodebuild command # Example = sonar.swift.simulator=platform=iOS Simulator,name=iPhone 6,OS=9.2 # sonar.swift.simulator=platform=iOS Simulator,name=iPhone 7,OS=12.0 -sonar.swift.simulator=platform=iOS Simulator,name=iPhone 15,OS=17.4 +sonar.swift.simulator=platform=iOS Simulator,name=iPhone 6,OS=latest # Xcode project configuration (.xcodeproj) # and use the later to specify which project(s) to include in the analysis (comma separated list) From 021040a94d780f2b522516262af7f63c690bead9 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 15:08:28 -0300 Subject: [PATCH 33/61] Add to test --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 1736b93..fc13b93 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -47,7 +47,7 @@ sonar.tests=Example/Tests # As string expected in destination argument of xcodebuild command # Example = sonar.swift.simulator=platform=iOS Simulator,name=iPhone 6,OS=9.2 # sonar.swift.simulator=platform=iOS Simulator,name=iPhone 7,OS=12.0 -sonar.swift.simulator=platform=iOS Simulator,name=iPhone 6,OS=latest +sonar.swift.simulator=platform=iOS Simulator,name=iPhone 7,OS=12.0 # Xcode project configuration (.xcodeproj) # and use the later to specify which project(s) to include in the analysis (comma separated list) From 218b5375b97ad0e04ae7fd3a4e25faf1ea1084d8 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 15:10:04 -0300 Subject: [PATCH 34/61] Add to test --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index fc13b93..700786a 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -47,7 +47,7 @@ sonar.tests=Example/Tests # As string expected in destination argument of xcodebuild command # Example = sonar.swift.simulator=platform=iOS Simulator,name=iPhone 6,OS=9.2 # sonar.swift.simulator=platform=iOS Simulator,name=iPhone 7,OS=12.0 -sonar.swift.simulator=platform=iOS Simulator,name=iPhone 7,OS=12.0 +sonar.swift.simulator=platform=iOS Simulator,name=iPhone 15,OS=latest # Xcode project configuration (.xcodeproj) # and use the later to specify which project(s) to include in the analysis (comma separated list) From 7c17797a04aa9828b833c6349b7731d2fc457102 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 15:14:26 -0300 Subject: [PATCH 35/61] Add to test --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 700786a..4687e24 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -47,7 +47,7 @@ sonar.tests=Example/Tests # As string expected in destination argument of xcodebuild command # Example = sonar.swift.simulator=platform=iOS Simulator,name=iPhone 6,OS=9.2 # sonar.swift.simulator=platform=iOS Simulator,name=iPhone 7,OS=12.0 -sonar.swift.simulator=platform=iOS Simulator,name=iPhone 15,OS=latest +sonar.swift.simulator=platform=iOS Simulator,id=6A3F7EC2-F53A-4D09-A280-1ADCB5D7AF17 # Xcode project configuration (.xcodeproj) # and use the later to specify which project(s) to include in the analysis (comma separated list) From db9675f41a7c4bc89a551831e8ab856ed0b1e30f Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 15:19:21 -0300 Subject: [PATCH 36/61] Add to test --- .github/workflows/check_sonar_tests.yml | 4 ++++ sonar-project.properties | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index 1f133a5..f812ca6 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -79,6 +79,10 @@ jobs: echo "Xcode caches and temporary files cleared!" + - name: Run Sonar-Swift Script + run: | + xcrun simctl list + - name: Run Sonar-Swift Script run: | chmod +x ./run-sonar-swift.sh diff --git a/sonar-project.properties b/sonar-project.properties index 4687e24..700786a 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -47,7 +47,7 @@ sonar.tests=Example/Tests # As string expected in destination argument of xcodebuild command # Example = sonar.swift.simulator=platform=iOS Simulator,name=iPhone 6,OS=9.2 # sonar.swift.simulator=platform=iOS Simulator,name=iPhone 7,OS=12.0 -sonar.swift.simulator=platform=iOS Simulator,id=6A3F7EC2-F53A-4D09-A280-1ADCB5D7AF17 +sonar.swift.simulator=platform=iOS Simulator,name=iPhone 15,OS=latest # Xcode project configuration (.xcodeproj) # and use the later to specify which project(s) to include in the analysis (comma separated list) From 7172347d516e9a2852fe804aeed78ac36367662b Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 15:24:49 -0300 Subject: [PATCH 37/61] Add to test --- .github/workflows/check_sonar_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index f812ca6..a6be75a 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -81,7 +81,7 @@ jobs: - name: Run Sonar-Swift Script run: | - xcrun simctl list + xcrun simctl list devices - name: Run Sonar-Swift Script run: | From 680cadd61eeb4199130426f5d51248f795ed6082 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 15:26:55 -0300 Subject: [PATCH 38/61] Add to test --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 700786a..4687e24 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -47,7 +47,7 @@ sonar.tests=Example/Tests # As string expected in destination argument of xcodebuild command # Example = sonar.swift.simulator=platform=iOS Simulator,name=iPhone 6,OS=9.2 # sonar.swift.simulator=platform=iOS Simulator,name=iPhone 7,OS=12.0 -sonar.swift.simulator=platform=iOS Simulator,name=iPhone 15,OS=latest +sonar.swift.simulator=platform=iOS Simulator,id=6A3F7EC2-F53A-4D09-A280-1ADCB5D7AF17 # Xcode project configuration (.xcodeproj) # and use the later to specify which project(s) to include in the analysis (comma separated list) From 76363161dcc2a461e720256c681c752f8a748183 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 15:53:27 -0300 Subject: [PATCH 39/61] Add to test --- .github/workflows/check_sonar_tests.yml | 44 ++++--------------------- 1 file changed, 6 insertions(+), 38 deletions(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index a6be75a..bd6c700 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -25,6 +25,11 @@ jobs: with: fetch-depth: 0 + - name: Install CocoaPods + run: | + gem install cocoapods + pod install --project-directory=Example + - name: Install dependencies run: | # Update Homebrew @@ -42,44 +47,7 @@ jobs: # Install Lizard brew install lizard - # Ensure xcodebuild is available (part of Xcode Command Line Tools) - xcode-select --install || echo "Xcode Command Line Tools already installed" - - # Install NVM (Node Version Manager) - curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash - - # Source nvm to make it available in the current session - source ~/.bash_profile || source ~/.zshrc - - # Install a specific version of Node.js (example: v16) - nvm install 16 - nvm use 16 - - # Optionally, you can set a default version - nvm alias default 16 - - # Verify Node and NVM installation - node -v - npm -v - - - name: Clean Xcode Caches - run: | - # Remove Xcode caches - rm -rf ~/Library/Caches/com.apple.dt.Xcode - - # Remove Xcode derived data - rm -rf ~/Library/Developer/Xcode/DerivedData - - # Remove Xcode build caches - rm -rf ~/Library/Developer/Xcode/Archives - rm -rf ~/Library/Developer/Xcode/iOS\ Device\ Logs - - # Optionally: Remove Xcode preferences - rm -rf ~/Library/Preferences/com.apple.dt.Xcode.plist - - echo "Xcode caches and temporary files cleared!" - - - name: Run Sonar-Swift Script + - name: Devices list run: | xcrun simctl list devices From a1607671e73e40cb82ede8cf32484c70cad97670 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 16:05:20 -0300 Subject: [PATCH 40/61] Add to test --- .github/workflows/check_sonar_tests.yml | 41 ++++++++++++------------- sonar-project.properties | 11 +++---- 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index bd6c700..31549ff 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -28,7 +28,11 @@ jobs: - name: Install CocoaPods run: | gem install cocoapods - pod install --project-directory=Example + pod install --project-directory=Example + + - name: Generate sonar-project.properties + run: | + echo "sonar.login=${{ env.SONAR_TOKEN_SECRET }}" >> ./sonar-project.properties - name: Install dependencies run: | @@ -46,10 +50,20 @@ jobs: # Install Lizard brew install lizard - - - name: Devices list + + - name: Install SonarQube Scanner run: | - xcrun simctl list devices + SONAR_SCANNER_VERSION=5.0.1.3006 + SONAR_SCANNER_DIR=/opt/sonar-scanner + + curl -o sonar-scanner-cli.zip -L "https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_VERSION}-linux.zip" + + sudo apt-get install -y unzip + unzip sonar-scanner-cli.zip + sudo mv sonar-scanner-${SONAR_SCANNER_VERSION}-linux ${SONAR_SCANNER_DIR} + + echo "${SONAR_SCANNER_DIR}/bin" >> $GITHUB_PATH + echo "SonarScanner installed successfully!" - name: Run Sonar-Swift Script run: | @@ -62,21 +76,4 @@ jobs: echo "Coverage report generated successfully: sonar-reports/generic-coverage.xml" else echo "Coverage report not found!" && exit 1 - fi - - - name: Run SonarQube Analysis - run: | - sonar-scanner -X \ - -Dsonar.host.url=${SONAR_HOST_URL} \ - -Dsonar.login=${SONAR_TOKEN} \ - -Dsonar.projectKey=${SONAR_PROJECT_KEY} \ - -Dsonar.projectName=${SONAR_PROJECT_NAME} \ - -Dsonar.pullrequest.base="${{ github.base_ref }}" \ - -Dsonar.pullrequest.branch="${{ github.head_ref }}" \ - -Dsonar.pullrequest.key="${{ github.event.pull_request.number }}" \ - -Dsonar.scm.revision="${{ github.event.pull_request.head.sha }}" \ - -Dsonar.coverageReportPaths=sonar-reports/generic-coverage.xml \ - -Dsonar.scm.disabled=true \ - -Dsonar.language=swift \ - -Dsonar.sources="." \ - -Dsonar.verbose=true \ No newline at end of file + fi \ No newline at end of file diff --git a/sonar-project.properties b/sonar-project.properties index 4687e24..4c8a87e 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -17,15 +17,12 @@ # # Sonar Server details -sonar.host.url=http://localhost:9000 -sonar.login=admin -sonar.password=Sonarqube$24 -# sonar.token=sqp_8cba87ecfe9b5459a833660cabcdc5e8a138deb8 +sonar.host.url=https://sonarqube.trustly.one +sonar.login=${SONAR_TOKEN_SECRET} # Project Details -sonar.projectKey=org.cocoapods.TrustlySDK-Example -sonar.projectName=TrustlySDKIOS -sonar.projectDescription=This is the Sonar demo application for the code quality check +sonar.projectKey=trustly-ios +sonar.projectName=trustly-ios # Comment if you have a project with mixed ObjC / Swift sonar.language=swift From de73c3e2af2712a20c9f9e613b62a8057074db80 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 16:07:05 -0300 Subject: [PATCH 41/61] Add to test --- .github/workflows/check_sonar_tests.yml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index 31549ff..cf14ff6 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -53,16 +53,8 @@ jobs: - name: Install SonarQube Scanner run: | - SONAR_SCANNER_VERSION=5.0.1.3006 - SONAR_SCANNER_DIR=/opt/sonar-scanner + brew install sonar-scanner - curl -o sonar-scanner-cli.zip -L "https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_VERSION}-linux.zip" - - sudo apt-get install -y unzip - unzip sonar-scanner-cli.zip - sudo mv sonar-scanner-${SONAR_SCANNER_VERSION}-linux ${SONAR_SCANNER_DIR} - - echo "${SONAR_SCANNER_DIR}/bin" >> $GITHUB_PATH echo "SonarScanner installed successfully!" - name: Run Sonar-Swift Script From e3c491cb25bf590a5818d655745e1eae97fbb8f0 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 16:13:49 -0300 Subject: [PATCH 42/61] Add to test --- .github/workflows/check_sonar_tests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index cf14ff6..a93f4d3 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -30,10 +30,6 @@ jobs: gem install cocoapods pod install --project-directory=Example - - name: Generate sonar-project.properties - run: | - echo "sonar.login=${{ env.SONAR_TOKEN_SECRET }}" >> ./sonar-project.properties - - name: Install dependencies run: | # Update Homebrew @@ -50,6 +46,10 @@ jobs: # Install Lizard brew install lizard + + - name: Generate sonar-project.properties + run: | + echo "sonar.login=${{ env.SONAR_TOKEN_SECRET }}" >> sonar-project.properties - name: Install SonarQube Scanner run: | From c6e45d0c3e0ad62f90e84b178cca06e5f183e3aa Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 16:20:11 -0300 Subject: [PATCH 43/61] Add to test --- .github/workflows/check_sonar_tests.yml | 33 ++++++++++++++++--------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index a93f4d3..2668973 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -34,28 +34,23 @@ jobs: run: | # Update Homebrew brew update - # Install SwiftLint brew install swiftlint - # Install Tailor brew install tailor - # Install xcpretty sudo gem install -n /usr/local/bin xcpretty - # Install Lizard brew install lizard - - name: Generate sonar-project.properties + - name: Devices list run: | - echo "sonar.login=${{ env.SONAR_TOKEN_SECRET }}" >> sonar-project.properties - - - name: Install SonarQube Scanner + xcrun simctl list devices + + - name: Install sonnar-scanner run: | - brew install sonar-scanner + brew install sonar-scanner - echo "SonarScanner installed successfully!" - name: Run Sonar-Swift Script run: | @@ -68,4 +63,20 @@ jobs: echo "Coverage report generated successfully: sonar-reports/generic-coverage.xml" else echo "Coverage report not found!" && exit 1 - fi \ No newline at end of file + fi + - name: Run SonarQube Analysis + run: | + sonar-scanner -X \ + -Dsonar.host.url=${SONAR_HOST_URL} \ + -Dsonar.login=${SONAR_TOKEN} \ + -Dsonar.projectKey=${SONAR_PROJECT_KEY} \ + -Dsonar.projectName=${SONAR_PROJECT_NAME} \ + -Dsonar.pullrequest.base="${{ github.base_ref }}" \ + -Dsonar.pullrequest.branch="${{ github.head_ref }}" \ + -Dsonar.pullrequest.key="${{ github.event.pull_request.number }}" \ + -Dsonar.scm.revision="${{ github.event.pull_request.head.sha }}" \ + -Dsonar.coverageReportPaths=sonar-reports/generic-coverage.xml \ + -Dsonar.scm.disabled=true \ + -Dsonar.language=swift \ + -Dsonar.sources="." \ + -Dsonar.verbose=true \ No newline at end of file From 6df6eb311020f40d7cb787a4a7e81319f442bba4 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 16:26:58 -0300 Subject: [PATCH 44/61] Add to test --- .github/workflows/check_sonar_tests.yml | 4 ++++ sonar-project.properties | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index 2668973..d1eab8b 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -51,6 +51,10 @@ jobs: run: | brew install sonar-scanner + - name: Generate sonar-project.properties + run: | + echo "sonar.login=${SONAR_TOKEN}" >> sonar-project.properties + - name: Run Sonar-Swift Script run: | diff --git a/sonar-project.properties b/sonar-project.properties index 4c8a87e..3864fe9 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -18,7 +18,7 @@ # Sonar Server details sonar.host.url=https://sonarqube.trustly.one -sonar.login=${SONAR_TOKEN_SECRET} +sonar.login=${SONAR_TOKEN} # Project Details sonar.projectKey=trustly-ios From 496784d281c44da58d1881d58bacae4c9e42dab0 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 16:31:14 -0300 Subject: [PATCH 45/61] Add to test --- .github/workflows/check_sonar_tests.yml | 15 +++------------ sonar-project.properties | 2 +- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index d1eab8b..558946e 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -25,11 +25,6 @@ jobs: with: fetch-depth: 0 - - name: Install CocoaPods - run: | - gem install cocoapods - pod install --project-directory=Example - - name: Install dependencies run: | # Update Homebrew @@ -43,19 +38,15 @@ jobs: # Install Lizard brew install lizard - - name: Devices list + - name: Install CocoaPods run: | - xcrun simctl list devices + gem install cocoapods + pod install --project-directory=Example - name: Install sonnar-scanner run: | brew install sonar-scanner - - name: Generate sonar-project.properties - run: | - echo "sonar.login=${SONAR_TOKEN}" >> sonar-project.properties - - - name: Run Sonar-Swift Script run: | chmod +x ./run-sonar-swift.sh diff --git a/sonar-project.properties b/sonar-project.properties index 3864fe9..33cdeb7 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -18,7 +18,7 @@ # Sonar Server details sonar.host.url=https://sonarqube.trustly.one -sonar.login=${SONAR_TOKEN} +sonar.login=test # Project Details sonar.projectKey=trustly-ios From 63fedba6b270841dc61662955aa523cf08324187 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 16:44:08 -0300 Subject: [PATCH 46/61] Add to test --- .github/workflows/check_sonar_tests.yml | 28 ++++++++++--------------- sonar-project.properties | 2 +- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index 558946e..2a72c2e 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -47,6 +47,16 @@ jobs: run: | brew install sonar-scanner + - name: Set up SonarQube Scanner + uses: sonarsource/sonar-scanner-action@v2 + with: + sonar-project-key: ${{ secrets.SONAR_PROJECT_KEY }} + + - name: Run SonarQube Analysis + run: | + # Create sonar-project.properties or update it dynamically + echo "sonar.login=${{ secrets.SONAR_TOKEN_SECRET }}" >> sonar-project.properties + - name: Run Sonar-Swift Script run: | chmod +x ./run-sonar-swift.sh @@ -58,20 +68,4 @@ jobs: echo "Coverage report generated successfully: sonar-reports/generic-coverage.xml" else echo "Coverage report not found!" && exit 1 - fi - - name: Run SonarQube Analysis - run: | - sonar-scanner -X \ - -Dsonar.host.url=${SONAR_HOST_URL} \ - -Dsonar.login=${SONAR_TOKEN} \ - -Dsonar.projectKey=${SONAR_PROJECT_KEY} \ - -Dsonar.projectName=${SONAR_PROJECT_NAME} \ - -Dsonar.pullrequest.base="${{ github.base_ref }}" \ - -Dsonar.pullrequest.branch="${{ github.head_ref }}" \ - -Dsonar.pullrequest.key="${{ github.event.pull_request.number }}" \ - -Dsonar.scm.revision="${{ github.event.pull_request.head.sha }}" \ - -Dsonar.coverageReportPaths=sonar-reports/generic-coverage.xml \ - -Dsonar.scm.disabled=true \ - -Dsonar.language=swift \ - -Dsonar.sources="." \ - -Dsonar.verbose=true \ No newline at end of file + fi \ No newline at end of file diff --git a/sonar-project.properties b/sonar-project.properties index 33cdeb7..4c8a87e 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -18,7 +18,7 @@ # Sonar Server details sonar.host.url=https://sonarqube.trustly.one -sonar.login=test +sonar.login=${SONAR_TOKEN_SECRET} # Project Details sonar.projectKey=trustly-ios From 8a1fbfd750e8376d4769a14480465bc1d50dcea9 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 16:45:50 -0300 Subject: [PATCH 47/61] Add to test --- .github/workflows/check_sonar_tests.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index 2a72c2e..3123794 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -46,11 +46,6 @@ jobs: - name: Install sonnar-scanner run: | brew install sonar-scanner - - - name: Set up SonarQube Scanner - uses: sonarsource/sonar-scanner-action@v2 - with: - sonar-project-key: ${{ secrets.SONAR_PROJECT_KEY }} - name: Run SonarQube Analysis run: | From e355d7c53e68c05648f353d24b5b4702c6a05acc Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 16:50:41 -0300 Subject: [PATCH 48/61] Add to test --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 4c8a87e..dd5ea12 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -18,7 +18,7 @@ # Sonar Server details sonar.host.url=https://sonarqube.trustly.one -sonar.login=${SONAR_TOKEN_SECRET} +sonar.login= # Project Details sonar.projectKey=trustly-ios From de711890702a7cad32071912dbd64fb2d46e3967 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 16:55:22 -0300 Subject: [PATCH 49/61] Add to test --- sonar-project.properties | 1 - 1 file changed, 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index dd5ea12..30c960a 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -18,7 +18,6 @@ # Sonar Server details sonar.host.url=https://sonarqube.trustly.one -sonar.login= # Project Details sonar.projectKey=trustly-ios From 2ec8a412f42950b23bac39ee1f50995296be2d9c Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 17:04:53 -0300 Subject: [PATCH 50/61] Add to test --- .github/workflows/check_sonar_tests.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index 3123794..076e147 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -10,6 +10,8 @@ env: OWNER: ${{ github.repository_owner }} REPO: ${{ github.event.repository.name }} PR_NUMBER: ${{ github.event.number }} + BRANCH_ORIGIN: ${{ github.head_ref }} + BASE_BRANCH: ${{ github.base_ref }} SONAR_HOST_URL: "https://sonarqube.trustly.one" SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_SECRET }} SONAR_PROJECT_KEY: "trustly-ios" @@ -25,6 +27,14 @@ jobs: with: fetch-depth: 0 + - name: Get Git Revision (Commit SHA) + id: git_revision + run: | + cd trustly-android-sdk || exit + git fetch origin "${BRANCH_ORIGIN}" + GIT_REVISION=$(git rev-parse origin/${BRANCH_ORIGIN}) + echo "Git Revision: $GIT_REVISION" + - name: Install dependencies run: | # Update Homebrew @@ -51,6 +61,10 @@ jobs: run: | # Create sonar-project.properties or update it dynamically echo "sonar.login=${{ secrets.SONAR_TOKEN_SECRET }}" >> sonar-project.properties + echo "sonar.pullrequest.key=${{ github.event.number }}" >> sonar-project.properties + echo "sonar.pullrequest.branch=${{ github.head_ref }}" >> sonar-project.properties + echo "sonar.pullrequest.base=${{ github.base_ref }}" >> sonar-project.properties + echo "sonar.scm.revision=${GIT_REVISION}" >> sonar-project.properties - name: Run Sonar-Swift Script run: | From 38d5382dd1ecc8195ed7df8bb326c2ca88d21829 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 17:07:02 -0300 Subject: [PATCH 51/61] Add to test --- .github/workflows/check_sonar_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index 076e147..c589818 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -30,7 +30,7 @@ jobs: - name: Get Git Revision (Commit SHA) id: git_revision run: | - cd trustly-android-sdk || exit + cd trustly-ios || exit git fetch origin "${BRANCH_ORIGIN}" GIT_REVISION=$(git rev-parse origin/${BRANCH_ORIGIN}) echo "Git Revision: $GIT_REVISION" From c061e3f2460ab8077f1a9d2188dd2f6ab7277840 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 17:08:38 -0300 Subject: [PATCH 52/61] Add to test --- .github/workflows/check_sonar_tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index c589818..be7a417 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -30,7 +30,6 @@ jobs: - name: Get Git Revision (Commit SHA) id: git_revision run: | - cd trustly-ios || exit git fetch origin "${BRANCH_ORIGIN}" GIT_REVISION=$(git rev-parse origin/${BRANCH_ORIGIN}) echo "Git Revision: $GIT_REVISION" From 37465a7b34dbfd4051219cd719c704b678debb81 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 17:14:59 -0300 Subject: [PATCH 53/61] Add to test --- .github/workflows/check_sonar_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index be7a417..058836b 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -63,7 +63,7 @@ jobs: echo "sonar.pullrequest.key=${{ github.event.number }}" >> sonar-project.properties echo "sonar.pullrequest.branch=${{ github.head_ref }}" >> sonar-project.properties echo "sonar.pullrequest.base=${{ github.base_ref }}" >> sonar-project.properties - echo "sonar.scm.revision=${GIT_REVISION}" >> sonar-project.properties + echo "sonar.scm.revision=$GIT_REVISION" >> sonar-project.properties - name: Run Sonar-Swift Script run: | From 8d8fa6b8e8c15063d9b578b92bb8f7c28a468c2e Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 17:16:38 -0300 Subject: [PATCH 54/61] Add to test --- .github/workflows/check_sonar_tests.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index 058836b..21371e5 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -32,7 +32,8 @@ jobs: run: | git fetch origin "${BRANCH_ORIGIN}" GIT_REVISION=$(git rev-parse origin/${BRANCH_ORIGIN}) - echo "Git Revision: $GIT_REVISION" + echo "Git Revision: $GIT_REVISION" + echo "GIT_REVISION=$GIT_REVISION" >> $GITHUB_ENV - name: Install dependencies run: | @@ -63,7 +64,7 @@ jobs: echo "sonar.pullrequest.key=${{ github.event.number }}" >> sonar-project.properties echo "sonar.pullrequest.branch=${{ github.head_ref }}" >> sonar-project.properties echo "sonar.pullrequest.base=${{ github.base_ref }}" >> sonar-project.properties - echo "sonar.scm.revision=$GIT_REVISION" >> sonar-project.properties + echo "sonar.scm.revision=${{ env.GIT_REVISION }}" >> sonar-project.properties - name: Run Sonar-Swift Script run: | From e5e811b04e2c4fe5426840e6fb30e247b1ba9f53 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 17:24:10 -0300 Subject: [PATCH 55/61] Add to test --- sonar-project.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sonar-project.properties b/sonar-project.properties index 30c960a..c7104ac 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -77,7 +77,7 @@ sonar.sourceEncoding=UTF-8 # JUnit report generated by run-sonar.sh is stored in sonar-reports/TEST-report.xml # Change it only if you generate the file on your own # The XML files have to be prefixed by TEST- otherwise they are not processed -sonar.junit.reportsPath=sonar-reports/TEST-report.xml +# sonar.junit.reportsPath=sonar-reports/TEST-report.xml # Cobertura report generated by run-sonar.sh is stored in sonar-reports/coverage-swift.xml # Change it only if you generate the file on your own @@ -89,10 +89,10 @@ sonar.coverageReportPaths=sonar-reports/generic-coverage.xml # OCLint report generated by run-sonar.sh is stored in sonar-reports/oclint.xml # Change it only if you generate the file on your own -sonar.swift.swiftlint.report=sonar-reports/*swiftlint.txt +# sonar.swift.swiftlint.report=sonar-reports/*swiftlint.txt # Change it only if you generate the file on your own -sonar.swift.tailor.report=sonar-reports/*tailor.txt +# sonar.swift.tailor.report=sonar-reports/*tailor.txt # Paths to exclude from coverage report (surefire, 3rd party libraries etc.) # sonar.swift.excludedPathsFromCoverage=pattern1,pattern2 From 2900a52f7600d879cfa24f88c6166a8b28cd2261 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Wed, 18 Dec 2024 17:43:55 -0300 Subject: [PATCH 56/61] Add to test --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index c7104ac..22a05bc 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -71,7 +71,7 @@ sonar.swift.appConfiguration=Debug sonar.sourceEncoding=UTF-8 # SCM -# sonar.scm.enabled=true +sonar.scm.enabled=true # sonar.scm.url=scm:git:http://xxx # JUnit report generated by run-sonar.sh is stored in sonar-reports/TEST-report.xml From 9ed7d6fd3b3056866b94b2764ba4fbd4d452c6ae Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Thu, 19 Dec 2024 09:37:14 -0300 Subject: [PATCH 57/61] Add to test --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 22a05bc..c7104ac 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -71,7 +71,7 @@ sonar.swift.appConfiguration=Debug sonar.sourceEncoding=UTF-8 # SCM -sonar.scm.enabled=true +# sonar.scm.enabled=true # sonar.scm.url=scm:git:http://xxx # JUnit report generated by run-sonar.sh is stored in sonar-reports/TEST-report.xml From 4e910724a8ee88b75edf2e4ca5f879604dc811f5 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Thu, 19 Dec 2024 10:26:58 -0300 Subject: [PATCH 58/61] Add to test --- .github/workflows/check_sonar_tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index 21371e5..59153ae 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -75,6 +75,7 @@ jobs: run: | if [ -f "sonar-reports/generic-coverage.xml" ]; then echo "Coverage report generated successfully: sonar-reports/generic-coverage.xml" + cat sonar-reports/generic-coverage.xml else echo "Coverage report not found!" && exit 1 fi \ No newline at end of file From b99ac037d1b3545b322a9c09e6d52337e16c9b1c Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Thu, 19 Dec 2024 11:34:25 -0300 Subject: [PATCH 59/61] Add to test --- .github/workflows/check_sonar_tests.yml | 3 +++ sonar-project.properties | 7 ------- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index 59153ae..d7cb347 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -60,6 +60,9 @@ jobs: - name: Run SonarQube Analysis run: | # Create sonar-project.properties or update it dynamically + echo "sonar.host.url=${{ env.SONAR_HOST_URL }} >> sonar-project.properties + echo "sonar.projectKey=${{ env.SONAR_PROJECT_KEY }}}" >> sonar-project.properties + echo "sonar.projectName=${{ env.SONAR_PROJECT_NAME }}" >> sonar-project.properties echo "sonar.login=${{ secrets.SONAR_TOKEN_SECRET }}" >> sonar-project.properties echo "sonar.pullrequest.key=${{ github.event.number }}" >> sonar-project.properties echo "sonar.pullrequest.branch=${{ github.head_ref }}" >> sonar-project.properties diff --git a/sonar-project.properties b/sonar-project.properties index c7104ac..590990b 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -16,13 +16,6 @@ # along with this program. If not, see . # -# Sonar Server details -sonar.host.url=https://sonarqube.trustly.one - -# Project Details -sonar.projectKey=trustly-ios -sonar.projectName=trustly-ios - # Comment if you have a project with mixed ObjC / Swift sonar.language=swift From f02241eac8779fd0650a45f81b42261f98f6957b Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Thu, 19 Dec 2024 11:40:34 -0300 Subject: [PATCH 60/61] Add to test --- .github/workflows/check_sonar_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index d7cb347..5824ed3 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -60,7 +60,7 @@ jobs: - name: Run SonarQube Analysis run: | # Create sonar-project.properties or update it dynamically - echo "sonar.host.url=${{ env.SONAR_HOST_URL }} >> sonar-project.properties + echo "sonar.host.url=${{ env.SONAR_HOST_URL }}" >> sonar-project.properties echo "sonar.projectKey=${{ env.SONAR_PROJECT_KEY }}}" >> sonar-project.properties echo "sonar.projectName=${{ env.SONAR_PROJECT_NAME }}" >> sonar-project.properties echo "sonar.login=${{ secrets.SONAR_TOKEN_SECRET }}" >> sonar-project.properties From 3de44609d061049d01b4a2d9e0e34df695df8587 Mon Sep 17 00:00:00 2001 From: Gabriel Santos Date: Thu, 19 Dec 2024 11:51:03 -0300 Subject: [PATCH 61/61] Add to test --- .github/workflows/check_sonar_tests.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/check_sonar_tests.yml b/.github/workflows/check_sonar_tests.yml index 5824ed3..b8ca4af 100644 --- a/.github/workflows/check_sonar_tests.yml +++ b/.github/workflows/check_sonar_tests.yml @@ -1,4 +1,4 @@ -name: CI - iOS +name: CI - iOS Quality Check on: pull_request: @@ -6,14 +6,11 @@ on: workflow_dispatch: env: - GH_TOKEN: ${{ secrets.GIT_TOKEN_SECRET }} - OWNER: ${{ github.repository_owner }} - REPO: ${{ github.event.repository.name }} PR_NUMBER: ${{ github.event.number }} BRANCH_ORIGIN: ${{ github.head_ref }} BASE_BRANCH: ${{ github.base_ref }} - SONAR_HOST_URL: "https://sonarqube.trustly.one" SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_SECRET }} + SONAR_HOST_URL: "https://sonarqube.trustly.one" SONAR_PROJECT_KEY: "trustly-ios" SONAR_PROJECT_NAME: "trustly-ios" @@ -61,7 +58,7 @@ jobs: run: | # Create sonar-project.properties or update it dynamically echo "sonar.host.url=${{ env.SONAR_HOST_URL }}" >> sonar-project.properties - echo "sonar.projectKey=${{ env.SONAR_PROJECT_KEY }}}" >> sonar-project.properties + echo "sonar.projectKey=${{ env.SONAR_PROJECT_KEY }}" >> sonar-project.properties echo "sonar.projectName=${{ env.SONAR_PROJECT_NAME }}" >> sonar-project.properties echo "sonar.login=${{ secrets.SONAR_TOKEN_SECRET }}" >> sonar-project.properties echo "sonar.pullrequest.key=${{ github.event.number }}" >> sonar-project.properties