Skip to content
This repository was archived by the owner on Mar 23, 2025. It is now read-only.

Commit 4e03230

Browse files
authored
Merge pull request #306 from manicmaniac/send-coverage-to-code-climate
Send test coverages to Code Climate
2 parents 5ecfefb + 0d436dd commit 4e03230

File tree

3 files changed

+98
-16
lines changed

3 files changed

+98
-16
lines changed

Diff for: .github/workflows/test.yml

+84-16
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,31 @@
22
name: Test
33
on:
44
- 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"
512
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
628
unit-test:
29+
needs: prepare-test
730
runs-on: macOS-10.15
831
env:
932
DEVELOPER_DIR: "/Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer"
@@ -30,51 +53,74 @@ jobs:
3053
- uses: actions/checkout@v2
3154
- name: Modify Cartfile.resolved
3255
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'
3469
run: |
3570
carthage checkout
3671
( cd Carthage/Checkouts/apollo-ios && swift package resolve ) # Workaround for Carthage's timeout error while reading xcodeproj.
3772
carthage build --platform '${{ matrix.platform }}' --use-xcframeworks --no-use-binaries
3873
- 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
4181
install-test:
4282
runs-on: macOS-10.15
43-
env:
44-
DEVELOPER_DIR: "/Applications/Xcode_12.app/Contents/Developer"
4583
steps:
4684
- 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
4791
- name: Run install tests
48-
run: make -C InstallTests carthage
92+
run: bundle exec make -C InstallTests carthage
4993
swiftpm-test:
5094
runs-on: macOS-10.15
51-
env:
52-
DEVELOPER_DIR: "/Applications/Xcode_12.4.app/Contents/Developer"
5395
steps:
5496
- uses: actions/checkout@v2
5597
- name: Run unit tests
5698
run: swift test
5799
lint-podspec:
58100
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"
64101
steps:
65102
- 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
68109
- name: Lint podspec
69110
run: bundle exec pod lib lint --verbose
70111
frontend-test:
112+
needs: prepare-test
71113
runs-on: ubuntu-18.04
72114
steps:
73115
- uses: actions/checkout@v2
74116
- name: Install dependencies
75117
run: npm install
76118
- 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
78124
frontend-rebuild:
79125
runs-on: ubuntu-18.04
80126
steps:
@@ -87,3 +133,25 @@ jobs:
87133
run: npm run build
88134
- name: Check differences
89135
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

Diff for: Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ group :documentation do
1111
end
1212

1313
group :test do
14+
gem 'slather'
1415
gem 'xcpretty'
1516
end

Diff for: Gemfile.lock

+13
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ GEM
1212
json (>= 1.5.1)
1313
atomos (0.1.3)
1414
claide (1.0.3)
15+
clamp (1.3.2)
1516
cocoapods (1.9.3)
1617
activesupport (>= 4.0.2, < 5)
1718
claide (>= 1.0.2, < 2.0)
@@ -72,18 +73,29 @@ GEM
7273
xcinvoke (~> 0.3.0)
7374
json (2.3.1)
7475
liferaft (0.0.6)
76+
mini_portile2 (2.5.3)
7577
minitest (5.14.1)
7678
molinillo (0.6.6)
7779
mustache (1.1.1)
7880
nanaimo (0.3.0)
7981
nap (1.1.0)
8082
netrc (0.11.0)
83+
nokogiri (1.11.7)
84+
mini_portile2 (~> 2.5.0)
85+
racc (~> 1.4)
8186
open4 (1.3.4)
87+
racc (1.5.2)
8288
redcarpet (3.5.1)
8389
rouge (2.0.7)
8490
ruby-macho (1.4.0)
8591
sassc (2.4.0)
8692
ffi (~> 1.9)
93+
slather (2.7.1)
94+
CFPropertyList (>= 2.2, < 4)
95+
activesupport
96+
clamp (~> 1.3)
97+
nokogiri (~> 1.11)
98+
xcodeproj (~> 1.7)
8799
sqlite3 (1.4.2)
88100
thread_safe (0.3.6)
89101
typhoeus (1.4.0)
@@ -107,6 +119,7 @@ PLATFORMS
107119
DEPENDENCIES
108120
cocoapods
109121
jazzy
122+
slather
110123
xcpretty
111124

112125
BUNDLED WITH

0 commit comments

Comments
 (0)