-
Notifications
You must be signed in to change notification settings - Fork 192
/
action.yml
126 lines (114 loc) · 3.83 KB
/
action.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: 'Run xcodebuild test'
description: 'Action runs the test for the scheme specified'
inputs:
scheme:
required: true
type: string
project_path:
required: false
type: string
xcode_path:
required: false
type: string
destination:
required: true
type: string
sdk:
required: false
type: string
default: 'iphonesimulator'
other_flags:
required: false
type: string
default: ''
generate_coverage:
required: false
type: boolean
default: false
cloned_source_packages_path:
required: false
type: string
default: ''
derived_data_path:
required: false
type: string
default: ''
disable_package_resolution:
required: false
type: boolean
default: false
test_without_building:
required: false
type: boolean
default: false
runs:
using: "composite"
steps:
- name: Test ${{ inputs.scheme }}
env:
SCHEME: ${{ inputs.scheme }}
PROJECT_PATH: ${{ inputs.project_path }}
XCODE_PATH: ${{ inputs.xcode_path }}
CLONED_SOURCE_PACKAGES_PATH: ${{ inputs.cloned_source_packages_path }}
DERIVED_DATA_PATH: ${{ inputs.derived_data_path }}
run: |
if [ ! -z "$PROJECT_PATH" ]; then
cd $PROJECT_PATH
fi
if [ ! -z "$XCODE_PATH" ]; then
echo "Using Xcode $XCODE_PATH"
sudo xcode-select -s $XCODE_PATH
fi
clonedSourcePackagesPath=""
if [ ! -z "$CLONED_SOURCE_PACKAGES_PATH" ]; then
echo "Using custom cloned source packages path"
clonedSourcePackagesPath+="-clonedSourcePackagesDirPath $CLONED_SOURCE_PACKAGES_PATH"
fi
derivedDataPath=""
if [ ! -z "$DERIVED_DATA_PATH" ]; then
echo "Using custom DerivedData path"
derivedDataPath+="-derivedDataPath $DERIVED_DATA_PATH"
fi
coverageFlags=""
if [ "${{ inputs.generate_coverage }}" == "true" ]; then
echo "Code Coverage is enabled!"
coverageFlags+="-enableCodeCoverage YES"
if [ -z "$clonedSourcePackagesPath" ]; then
clonedSourcePackagesPath+="-clonedSourcePackagesDirPath ~/Library/Developer/Xcode/DerivedData/Amplify"
fi
if [ -z "$derivedDataPath" ]; then
derivedDataPath+="-derivedDataPath Build/"
fi
fi
if [ "${{ inputs.disable_package_resolution }}" == "true" ]; then
echo "Disabling Automatic Package Resolution"
clonedSourcePackagesPath+=" -disableAutomaticPackageResolution"
fi
action="test"
if [ "${{ inputs.test_without_building }}" == "true" ]; then
echo "Testing without building..."
action+="-without-building"
fi
xcode-select -p
xcodebuild -version
xcodebuild $action -scheme $SCHEME -sdk '${{ inputs.sdk }}' -destination '${{ inputs.destination }}' ${{ inputs.other_flags }} $clonedSourcePackagesPath $derivedDataPath $coverageFlags | xcpretty --simple --color --report junit && exit ${PIPESTATUS[0]}
shell: bash
- name: Generate Coverage report
if: ${{ inputs.generate_coverage == 'true' }}
env:
SCHEME: ${{ inputs.scheme }}
DERIVED_DATA_PATH: ${{ inputs.derived_data_path }}
run: |
echo "Generating Coverage report..."
derivedDataPath=""
if [ ! -z "$DERIVED_DATA_PATH" ]; then
derivedDataPath="$DERIVED_DATA_PATH"
else
derivedDataPath="Build"
fi
cd $derivedDataPath/Build/ProfileData
cd $(ls -d */|head -n 1)
pathCoverage=Build/Build/ProfileData/${PWD##*/}/Coverage.profdata
cd ${{ github.workspace }}
xcrun llvm-cov export -format="lcov" -instr-profile $pathCoverage $derivedDataPath/Build/Products/Debug-${{ inputs.sdk }}/$SCHEME.o > $SCHEME-Coverage.lcov
shell: bash