-
Notifications
You must be signed in to change notification settings - Fork 34
91 lines (77 loc) · 3.12 KB
/
ci.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
86
87
88
89
90
91
name: CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: macos-15
env:
DERIVED_DATA: ${{ github.workspace }}/.DerivedData
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Install sonar-scanner
uses: yolomao/sonarcloud-github-c-cpp@main
- name: Cache cocoapods
uses: actions/cache@v4
with:
save-always: true
path: ./Example/Pods
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-pods-
- name: Pod Install
run: cd Example && pod install && cd ..
- name: Run tests to generate coverage statistics # https://sonarsource.atlassian.net/browse/CPP-3987
run: |
set -euo pipefail
mkdir -p ${{ env.DERIVED_DATA }}
xcodebuild test -workspace Example/GrowingAnalytics.xcworkspace \
-scheme GrowingAnalyticsTests \
-testPlan GrowingAnalyticsTests \
-destination 'platform=iOS Simulator,name=iPhone 16 Pro' \
-enableCodeCoverage YES \
-derivedDataPath ${{ env.DERIVED_DATA }} \
OTHER_CFLAGS="\$(inherited) -gen-cdb-fragment-path ${{ env.DERIVED_DATA }}/compilation-database" \
| xcbeautify --renderer github-actions
pushd ${{ env.DERIVED_DATA }}/compilation-database
sed -e '1s/^/[\'$'\n''/' -e '$s/,$/\'$'\n'']/' *.json > ${{ env.DERIVED_DATA }}/compile_commands.json
popd
- name: Brew Install Xcresultparser
run: |
brew tap a7ex/homebrew-formulae
brew install xcresultparser
- name: Parse xcresult to Cobertura xml
run: |
xcresultparser -o cobertura ${{ env.DERIVED_DATA }}/Logs/Test/*.xcresult/ \
> ${{ env.DERIVED_DATA }}/cobertura-coverage.xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
fail_ci_if_error: true
files: ./.DerivedData/cobertura-coverage.xml
directory: ${{ github.workspace }}
verbose: true
- name: Parse xcresult to Sonarqube xml
run: |
xcresultparser -c -o xml ${{ env.DERIVED_DATA }}/Logs/Test/*.xcresult/ \
> ${{ env.DERIVED_DATA }}/sonar-coverage.xml
- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner \
-Dsonar.cfamily.compile-commands="${{ env.DERIVED_DATA }}/compile_commands.json" \
-Dsonar.coverageReportPaths="${{ env.DERIVED_DATA }}/sonar-coverage.xml"
# https://github.com/sonarsource-cfamily-examples/macos-xcode-coverage-gh-actions-sc/blob/main/.github/workflows/build.yml
# https://github.com/SonarSource/sonarcloud-github-c-cpp