-
-
Notifications
You must be signed in to change notification settings - Fork 9
80 lines (76 loc) · 2.75 KB
/
xcode-build.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
name: Build and Analyze
on:
pull_request:
paths:
- 'SlimHUD/**'
- 'SlimHUDTests/**'
- 'SlimHUDUITests/**'
push:
paths:
- 'SlimHUD/**'
- 'SlimHUDTests/**'
- 'SlimHUDUITests/**'
branches:
- develop
workflow_dispatch:
concurrency:
group: "unitests${{ github.head_ref || github.run_id }}"
cancel-in-progress: true
env:
test-results-check-name: Test results
jobs:
unit-tests-run:
runs-on: macos-12
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Switch Xcode version
run: sudo xcode-select -s "/Applications/Xcode_14.2.app"
- name: Build and Test
continue-on-error: true
id: run-tests
run: |
xcodebuild clean test \
-project SlimHUD.xcodeproj \
-scheme SlimHUD-Unit-Only \
-destination platform=macOS \
-resultBundlePath TestResults \
-test-iterations 20 -retry-tests-on-failure \
CODE_SIGNING_ALLOWED=NO || exit 1
- name: Post test results
uses: AlexPerathoner/[email protected]
if: ${{ (success() || failure()) && github.event_name == 'pull_request' }}
with:
path: "TestResults.xcresult"
title: ${{ env.test-results-check-name }}
upload-bundles: never
show-code-coverage: true
- name: Generate coverage report
run: |
bash ./Configuration/xccov-to-sonarqube-generic.sh TestResults.xcresult/ > sonarqube-generic-coverage.xml
sed -i '' "s/projectVersion=1.0/projectVersion=$(xcrun agvtool what-version -terse) /g" sonar-project.properties
- name: Save coverage report
uses: actions/upload-artifact@master
with:
name: sonarqube-generic-coverage
path: sonarqube-generic-coverage.xml
- name: Checkout
uses: actions/checkout@v3
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- name: Replace version
run: sed -i '' "s/projectVersion=1.0/projectVersion=$(xcrun agvtool what-version -terse)/g" sonar-project.properties
- uses: actions/download-artifact@master # download all previously generated artifacts
with:
name: sonarqube-generic-coverage
- name: Setup sonarqube
uses: warchant/setup-sonar-scanner@v3
- name: Run sonarqube
run: |
sonar-scanner
- name: Check failures
# Flaky tests make the output status generated by xcresulttool not reliable. Using xcodebuild's status directly.
# This means that this workflow could and will fail if some test don't pass, even after retrying them
if: steps.run-tests.outcome != 'success'
run: exit 1