2
2
name : Test
3
3
on :
4
4
- push
5
+ defaults :
6
+ run :
7
+ shell : bash # to enable pipefail
8
+ env :
9
+ CC_TEST_REPORTER_ID : ${{ secrets.CC_TEST_REPORTER_ID }}
10
+ CC_TEST_REPORTER_URL : https://codeclimate.com/downloads/test-reporter/test-reporter-0.6.3-linux-amd64
11
+ DEVELOPER_DIR : " /Applications/Xcode_12.4.app/Contents/Developer"
5
12
jobs :
13
+ prepare-test :
14
+ runs-on : ubuntu-18.04
15
+ steps :
16
+ - uses : actions/cache@v2
17
+ id : cache-cc-test-reporter
18
+ with :
19
+ path : cc-test-reporter
20
+ key : ${{ env.CC_TEST_REPORTER_URL }}
21
+ - name : Install dependencies
22
+ if : steps.cache-cc-test-reporter.outputs.cache-hit != 'true'
23
+ run : |
24
+ curl -LSso cc-test-reporter ${{ env.CC_TEST_REPORTER_URL }}
25
+ chmod +x cc-test-reporter
26
+ - name : Notify before build
27
+ run : ./cc-test-reporter before-build
6
28
unit-test :
29
+ needs : prepare-test
7
30
runs-on : macOS-10.15
8
31
env :
9
32
DEVELOPER_DIR : " /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer"
@@ -30,51 +53,74 @@ jobs:
30
53
- uses : actions/checkout@v2
31
54
- name : Modify Cartfile.resolved
32
55
run : sed -i '' -E '/apollographql\/apollo-ios/s/"[0-9.]+"/"${{ matrix.apollo }}"/' Cartfile.resolved
33
- - name : Install dependencies
56
+ - uses : ruby/setup-ruby@v1
57
+ with :
58
+ ruby-version : 2.6
59
+ bundler-cache : true
60
+ env :
61
+ BUNDLE_WITHOUT : development:documentation
62
+ - uses : actions/cache@v2
63
+ id : cache-carthage-build
64
+ with :
65
+ path : Carthage/Build
66
+ key : ${{ matrix.platform }}-${{ hashFiles('Cartfile.resolved') }}
67
+ - name : Install Carthage dependencies
68
+ if : steps.cache-carthage-build.outputs.cache-hit != 'true'
34
69
run : |
35
70
carthage checkout
36
71
( cd Carthage/Checkouts/apollo-ios && swift package resolve ) # Workaround for Carthage's timeout error while reading xcodeproj.
37
72
carthage build --platform '${{ matrix.platform }}' --use-xcframeworks --no-use-binaries
38
73
- name : Run unit tests
39
- run : xcodebuild test -project ApolloDeveloperKit.xcodeproj -scheme ApolloDeveloperKit -sdk '${{ matrix.sdk }}' -destination '${{ matrix.destination }}' | xcpretty
40
- shell : bash # to enable pipefail
74
+ run : xcodebuild test -project ApolloDeveloperKit.xcodeproj -scheme ApolloDeveloperKit -sdk '${{ matrix.sdk }}' -destination '${{ matrix.destination }}' | bundle exec xcpretty
75
+ - name : Collect coverages
76
+ run : bundle exec slather coverage -x --scheme ApolloDeveloperKit ApolloDeveloperKit.xcodeproj
77
+ - uses : actions/upload-artifact@v2
78
+ with :
79
+ name : coverage
80
+ path : cobertura.xml
41
81
install-test :
42
82
runs-on : macOS-10.15
43
- env :
44
- DEVELOPER_DIR : " /Applications/Xcode_12.app/Contents/Developer"
45
83
steps :
46
84
- uses : actions/checkout@v2
85
+ - uses : ruby/setup-ruby@v1
86
+ with :
87
+ ruby-version : 2.6
88
+ bundler-cache : true
89
+ env :
90
+ BUNDLE_WITHOUT : development:documentation
47
91
- name : Run install tests
48
- run : make -C InstallTests carthage
92
+ run : bundle exec make -C InstallTests carthage
49
93
swiftpm-test :
50
94
runs-on : macOS-10.15
51
- env :
52
- DEVELOPER_DIR : " /Applications/Xcode_12.4.app/Contents/Developer"
53
95
steps :
54
96
- uses : actions/checkout@v2
55
97
- name : Run unit tests
56
98
run : swift test
57
99
lint-podspec :
58
100
runs-on : macOS-10.15
59
- env :
60
- BUNDLE_JOBS : 4
61
- BUNDLE_RETRY : 3
62
- BUNDLE_WITHOUT : documentation:test
63
- DEVELOPER_DIR : " /Applications/Xcode_12.app/Contents/Developer"
64
101
steps :
65
102
- uses : actions/checkout@v2
66
- - name : Install dependencies
67
- run : bundle install
103
+ - uses : ruby/setup-ruby@v1
104
+ with :
105
+ ruby-version : 2.6
106
+ bundler-cache : true
107
+ env :
108
+ BUNDLE_WITHOUT : documentation:test
68
109
- name : Lint podspec
69
110
run : bundle exec pod lib lint --verbose
70
111
frontend-test :
112
+ needs : prepare-test
71
113
runs-on : ubuntu-18.04
72
114
steps :
73
115
- uses : actions/checkout@v2
74
116
- name : Install dependencies
75
117
run : npm install
76
118
- name : Run frontend tests
77
- run : npm test
119
+ run : npm test -- --coverage
120
+ - uses : actions/upload-artifact@v2
121
+ with :
122
+ name : coverage
123
+ path : coverage/clover.xml
78
124
frontend-rebuild :
79
125
runs-on : ubuntu-18.04
80
126
steps :
@@ -87,3 +133,25 @@ jobs:
87
133
run : npm run build
88
134
- name : Check differences
89
135
run : git diff --exit-code .
136
+ report-coverages :
137
+ needs :
138
+ - unit-test
139
+ - frontend-test
140
+ runs-on : ubuntu-18.04
141
+ steps :
142
+ - uses : actions/checkout@v2
143
+ - uses : actions/cache@v2
144
+ with :
145
+ path : cc-test-reporter
146
+ key : ${{ env.CC_TEST_REPORTER_URL }}
147
+ - uses : actions/download-artifact@v2
148
+ with :
149
+ name : coverage
150
+ path : coverage
151
+ - name : Sum coverages
152
+ run : |
153
+ ./cc-test-reporter format-coverage --input-type=cobertura --output=coverage/unit-test.json coverage/cobertura.xml
154
+ ./cc-test-reporter format-coverage --input-type=clover --output=coverage/frontend-test.json coverage/clover.xml
155
+ ./cc-test-reporter sum-coverage coverage/unit-test.json coverage/frontend-test.json
156
+ - name : Upload coverages
157
+ run : ./cc-test-reporter upload-coverage
0 commit comments