-
Notifications
You must be signed in to change notification settings - Fork 34
85 lines (77 loc) · 3.23 KB
/
SonarCloud.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: SonarCloud
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build
runs-on: macos-latest
env:
SONAR_SCANNER_VERSION: 4.6.2.2472
SONAR_SERVER_URL: "https://sonarcloud.io"
DERIVED_DATA: $HOME/.DerivedData
XCTEST_WORKSPACE: GrowingAnalytics.xcworkspace
XCTEST_SCHEME: GrowingAnalyticsTests
XCTEST_TESTPLAN: GrowingAnalyticsTests
XCTEST_DESTINATION: "platform=iOS Simulator,name=iPhone 13"
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 11
- name: Download and set up sonar-scanner
env:
SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-macosx.zip
run: |
mkdir -p $HOME/.sonar
mkdir -p $HOME/.cache
curl -sSLo $HOME/.sonar/sonar-scanner.zip ${{ env.SONAR_SCANNER_DOWNLOAD_URL }}
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
echo "$HOME/.sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-macosx/bin" >> $GITHUB_PATH
- name: Download and set up build-wrapper
env:
BUILD_WRAPPER_DOWNLOAD_URL: ${{ env.SONAR_SERVER_URL }}/static/cpp/build-wrapper-macosx-x86.zip
run: |
curl -sSLo $HOME/.sonar/build-wrapper-macosx-x86.zip ${{ env.BUILD_WRAPPER_DOWNLOAD_URL }}
unzip -o $HOME/.sonar/build-wrapper-macosx-x86.zip -d $HOME/.sonar/
echo "$HOME/.sonar/build-wrapper-macosx-x86" >> $GITHUB_PATH
- name: Cache cocoapods
uses: actions/cache@v3
with:
path: Pods
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-pods-
- name: Pod Install
run: pod install
- name: Run build-wrapper
run: |
mkdir -p ${{ env.DERIVED_DATA }}
build-wrapper-macosx-x86 --out-dir ${{ env.DERIVED_DATA }}/compilation-database \
xcodebuild test -workspace ${{ env.XCTEST_WORKSPACE }} \
-scheme ${{ env.XCTEST_SCHEME }} \
-testPlan ${{ env.XCTEST_TESTPLAN }} \
-destination "${{ env.XCTEST_DESTINATION }}" \
-enableCodeCoverage YES \
-derivedDataPath ${{ env.DERIVED_DATA }}
- name: Parse xcresult to Sonarqube xml
run: |
brew tap a7ex/homebrew-formulae
brew install xcresultparser
xcresultparser -c -o xml ${{ env.DERIVED_DATA }}/Logs/Test/*.xcresult/ > ${{ env.DERIVED_DATA }}/sonarqube-generic-coverage.xml
- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner \
-Dsonar.host.url="${{ env.SONAR_SERVER_URL }}" \
-Dsonar.cfamily.build-wrapper-output="${{ env.DERIVED_DATA }}/compilation-database" \
-Dsonar.coverageReportPaths="${{ env.DERIVED_DATA }}/sonarqube-generic-coverage.xml"