Skip to content

Commit

Permalink
Fix the rest of the libs
Browse files Browse the repository at this point in the history
wat

wat*2

dasdas

nlkm

shrug

xccov

hohosdlk

dunno

clean

dsa
  • Loading branch information
matux committed Feb 13, 2024
1 parent 09546f0 commit 9e04ff2
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 101 deletions.
110 changes: 51 additions & 59 deletions .github/workflows/masterCI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,81 +17,73 @@ jobs:
with:
fetch-depth: 0

- name: Create DerivedData folder
run: mkdir DerivedData
- name: Create build-wrapper dir
run: mkdir -p ${{ env.BUILD_WRAPPER_OUT_DIR }}

- name: Create ${{ env.BUILD_WRAPPER_OUT_DIR }} folder
working-directory: DerivedData
run: mkdir compilation-database
# - name: Build RollbarCommon
# working-directory: RollbarCommon
# run: swift build -v

- name: Build RollbarCommon
working-directory: RollbarCommon
run: swift build -v --build-path ../DerivedData
# - name: Build RollbarDeploys
# working-directory: RollbarDeploys
# run: swift build -v

- name: Build RollbarDeploys
working-directory: RollbarDeploys
run: swift build -v
# - name: Build RollbarNotifier
# working-directory: RollbarNotifier
# run: swift build -v

- name: Build RollbarNotifier
working-directory: RollbarNotifier
run: swift build -v

- name: Build RollbarAUL
working-directory: RollbarAUL
run: swift build -v
# - name: Build RollbarAUL
# working-directory: RollbarAUL
# run: swift build -v

- name: Install sonar-scanner and build-wrapper
uses: SonarSource/sonarcloud-github-c-cpp@v2
with:
cache-binaries: false

- name: SonarCloud RollbarCommon
- name: Run build-wrapper RollbarCommon
run: |
build-wrapper-macosx-x86 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} xcodebuild -workspace RollbarSDK.xcworkspace -scheme RollbarCommon -derivedDataPath DerivedData -enableCodeCoverage YES build test CODE_SIGN_IDENTITY="-" CODE_SIGNING_REQUIRED=NO
xcodebuild \
-workspace RollbarSDK.xcworkspace \
-scheme RollbarCommon \
-derivedDataPath DerivedData \
clean build
- name: Test RollbarCommon
run: |
xcodebuild \
test \
-workspace RollbarSDK.xcworkspace \
-scheme RollbarCommon \
-derivedDataPath DerivedData \
-enableCodeCoverage YES \
CODE_SIGN_IDENTITY="-" \
CODE_SIGNING_REQUIRED=NO
- name: SonarCloud RollbarDeploys
run:
SonarCloud/build-wrapper-macosx-x86/build-wrapper-macosx-x86
--out-dir DerivedData/compilation-database
xcodebuild
-workspace RollbarSDK.xcworkspace
-scheme RollbarDeploys
-derivedDataPath DerivedData
-enableCodeCoverage YES
build
test
CODE_SIGN_IDENTITY="-"
CODE_SIGNING_REQUIRED=NO
run: |
build-wrapper-macosx-x86 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} xcodebuild -workspace RollbarSDK.xcworkspace -scheme RollbarDeploys -derivedDataPath DerivedData -enableCodeCoverage YES build test CODE_SIGN_IDENTITY="-" CODE_SIGNING_REQUIRED=NO
- name: SonarCloud RollbarNotifier
run:
SonarCloud/build-wrapper-macosx-x86/build-wrapper-macosx-x86 --out-dir DerivedData/compilation-database
xcodebuild
-workspace RollbarSDK.xcworkspace
-scheme RollbarNotifier
-derivedDataPath DerivedData
-enableCodeCoverage YES
build
test
CODE_SIGN_IDENTITY="-"
CODE_SIGNING_REQUIRED=NO
run: |
build-wrapper-macosx-x86 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} xcodebuild -workspace RollbarSDK.xcworkspace -scheme RollbarNotifier -derivedDataPath DerivedData -enableCodeCoverage YES build test CODE_SIGN_IDENTITY="-" CODE_SIGNING_REQUIRED=NO
- name: SonarCloud RollbarAUL
run:
SonarCloud/build-wrapper-macosx-x86/build-wrapper-macosx-x86 --out-dir DerivedData/compilation-database
xcodebuild
-workspace RollbarSDK.xcworkspace
-scheme RollbarAUL
-derivedDataPath DerivedData
-enableCodeCoverage YES
build
test
CODE_SIGN_IDENTITY="-"
CODE_SIGNING_REQUIRED=NO

- name: SonarCloud Test Coverage Conversion
run: bash xccov-to-sonarqube-generic.sh DerivedData/Logs/Test/*.xcresult/ > sonarqube-generic-coverage.xml
run: |
build-wrapper-macosx-x86 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} xcodebuild -workspace RollbarSDK.xcworkspace -scheme RollbarAUL -derivedDataPath DerivedData -enableCodeCoverage YES build test CODE_SIGN_IDENTITY="-" CODE_SIGNING_REQUIRED=NO
- name: Collect coverage into one XML report
run: |
bash xccov-to-generic.sh DerivedData/Logs/Test/*.xcresult/ > generic-coverage.xml
- name: Run SonarScanner Analysis
run: SonarCloud/sonar-scanner-5.0.1.3006-macosx/bin/sonar-scanner -X -Dsonar.organization=${{ secrets.SONAR_ORGANIZATION_KEY }} -Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY }} -Dsonar.coverageReportPaths=sonarqube-generic-coverage.xml
run: |
sonar-scanner \
-X \
-Dsonar.cfamily.build-wrapper-output=${{ env.BUILD_WRAPPER_OUT_DIR }} \
-Dsonar.organization=${{ secrets.SONAR_ORGANIZATION_KEY }} \
-Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY }} \
-Dsonar.coverageReportPaths=generic-coverage.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
2 changes: 1 addition & 1 deletion RollbarSDK.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 1 addition & 8 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#sonar.projectKey=WideSpectrumComputing_rollbar-apple
#sonar.organization=widespectrumcomputing

# This is the name and version displayed in the SonarCloud UI.
sonar.projectName=rollbar-apple
sonar.projectVersion=1.0
Expand Down Expand Up @@ -29,7 +26,7 @@ sonar.cfamily.build-wrapper-output=DerivedData/compilation-database
sonar.cfamily.threads=1


# if you do not want to enable cache
# if you do not want to enable cache
# please explicitly disable it by setting the following property to your analysis:
sonar.cfamily.cache.enabled=false

Expand All @@ -38,7 +35,3 @@ sonar.cfamily.cache.enabled=false
#sonar.cfamily.cache.path=relative_or_absolute_path_to_cache_location

sonar.swift.coverage.reportPath=Coverage.report
#sonar.coverageReportPaths=sonarqube-generic-coverage.xml

# visit the documentation page for more information
# https://sonarcloud.io/documentation/analysis/languages/cfamily/
89 changes: 89 additions & 0 deletions xccov-to-generic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/env bash
set -euo pipefail

function convert_file {
local xccovarchive_file="$1"
local file_name="$2"
local xccov_options="$3"
echo " <file path=\"$file_name\">"
xcrun xccov view $xccov_options --file "$file_name" "$xccovarchive_file" | \
sed -n '
s/^ *\([0-9][0-9]*\): 0.*$/ <lineToCover lineNumber="\1" covered="false"\/>/p;
s/^ *\([0-9][0-9]*\): [1-9].*$/ <lineToCover lineNumber="\1" covered="true"\/>/p
'
echo ' </file>'
}

function xccov_to_generic {
echo '<coverage version="1">'
for xccovarchive_file in "$@"; do
if [[ ! -d $xccovarchive_file ]]
then
echo "Coverage FILE NOT FOUND AT PATH: $xccovarchive_file" 1>&2;
exit 1
fi

if [ $sdk_version -gt 10 ]; then # Apply optimization
xccovarchive_file=$(optimize_format)
fi

local xccov_options=""
if [[ $xccovarchive_file == *".xcresult"* ]]; then
xccov_options="--archive"
fi
xcrun xccov view $xccov_options --file-list "$xccovarchive_file" | while read -r file_name; do
convert_file "$xccovarchive_file" "$file_name" "$xccov_options"
done
done
echo '</coverage>'
}

function check_sdk_version {
sdk_major_version=`xcrun --show-sdk-version | cut -d . -f 1`

if [ $? -ne 0 ]; then
echo 'Failed to execute xcrun show-sdk-version' 1>&2
exit -1
fi
echo $sdk_major_version
}

function cleanup_tmp_files {
rm -rf tmp.json
rm -rf tmp.xccovarchive
}

# Optimize coverage files conversion time by exporting to a clean xcodearchive directory
# Credits to silverhammermba on issue #68 for the suggestion
function optimize_format {
cleanup_tmp_files
xcrun xcresulttool get --format json --path "$xccovarchive_file" > tmp.json
if [ $? -ne 0 ]; then
echo 'Failed to execute xcrun xcresulttool get' 1>&2
exit -1
fi

# local reference=$(jq -r '.actions._values[2].actionResult.coverage.archiveRef.id._value' tmp.json)
local reference=$(jq -r '.actions._values[]|[.actionResult.coverage.archiveRef.id],._values' tmp.json | grep value | cut -d : -f 2 | cut -d \" -f 2)
if [ $? -ne 0 ]; then
echo 'Failed to execute jq (https://stedolan.github.io/jq/)' 1>&2
exit -1
fi
# $reference can be a list of IDs (from a merged .xcresult bundle of multiple test plans)
for test_ref in $reference; do
xcrun xcresulttool export --type directory --path "$xccovarchive_file" --id "$test_ref" --output-path tmp.xccovarchive
if [ $? -ne 0 ]; then
echo "Failed to execute xcrun xcresulttool export for reference ${test_ref}" 1>&2
exit -1
fi
done
echo "tmp.xccovarchive"
}

sdk_version=$(check_sdk_version)
if [ $? -ne 0 ]; then
exit -1
fi

xccov_to_generic "$@"
cleanup_tmp_files
33 changes: 0 additions & 33 deletions xccov-to-sonarqube-generic.sh

This file was deleted.

0 comments on commit 9e04ff2

Please sign in to comment.