Skip to content

Commit c30af36

Browse files
a7medevHeshamMegid
authored andcommitted
[MOB-11085] Integrate Danger Coverage Plugin (#958)
* Integrate coverage plugin with Danger * Fix `yarn install` * Add coverage thresholds
1 parent 98d5236 commit c30af36

File tree

4 files changed

+81
-27
lines changed

4 files changed

+81
-27
lines changed

.circleci/config.yml

Lines changed: 40 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ orbs:
66
node: circleci/[email protected]
77

88
commands:
9+
install_node_modules:
10+
parameters:
11+
app-dir:
12+
type: string
13+
default: .
14+
steps:
15+
- node/install-packages:
16+
pkg-manager: yarn
17+
# Network concurrency is set to 1 for installation from GitHub to work.
18+
override-ci-command: yarn install --frozen-lockfile --network-concurrency 1
19+
app-dir: << parameters.app-dir >>
920
install_pods:
1021
parameters:
1122
working_directory:
@@ -30,8 +41,9 @@ jobs:
3041
name: node/default
3142
steps:
3243
- advanced-checkout/shallow-checkout
33-
- node/install-packages:
34-
pkg-manager: yarn
44+
- install_node_modules
45+
- attach_workspace:
46+
at: coverage
3547
- run:
3648
name: Run Danger
3749
command: yarn danger ci
@@ -41,8 +53,7 @@ jobs:
4153
name: node/default
4254
steps:
4355
- advanced-checkout/shallow-checkout
44-
- node/install-packages:
45-
pkg-manager: yarn
56+
- install_node_modules
4657
- run:
4758
name: Check Format
4859
command: yarn format
@@ -55,11 +66,14 @@ jobs:
5566
name: node/default
5667
steps:
5768
- advanced-checkout/shallow-checkout
58-
- node/install-packages:
59-
pkg-manager: yarn
69+
- install_node_modules
6070
- run:
6171
name: Run Tests
6272
command: yarn test
73+
- persist_to_workspace:
74+
root: coverage
75+
paths:
76+
- lcov.info
6377

6478
test_android:
6579
executor:
@@ -69,11 +83,14 @@ jobs:
6983
steps:
7084
- advanced-checkout/shallow-checkout
7185
- node/install-yarn
72-
- node/install-packages:
73-
pkg-manager: yarn
86+
- install_node_modules
7487
- android/run-tests:
7588
working-directory: android
7689
test-command: ./gradlew test -PinstabugUploadEnable=false
90+
- persist_to_workspace:
91+
root: ~/project/android/build/reports/jacoco/jacocoTestReport
92+
paths:
93+
- jacocoTestReport.xml
7794

7895
validate_shell_files:
7996
machine:
@@ -95,8 +112,7 @@ jobs:
95112
xcode: 13.4.1
96113
steps:
97114
- advanced-checkout/shallow-checkout
98-
- node/install-packages:
99-
pkg-manager: yarn
115+
- install_node_modules
100116
- node/install-packages:
101117
pkg-manager: yarn
102118
app-dir: examples/default
@@ -113,8 +129,7 @@ jobs:
113129
INSTABUG_SOURCEMAPS_UPLOAD_DISABLE: true
114130
steps:
115131
- advanced-checkout/shallow-checkout
116-
- node/install-packages:
117-
pkg-manager: yarn
132+
- install_node_modules
118133
- install_pods:
119134
working_directory: ios
120135
- run:
@@ -131,14 +146,11 @@ jobs:
131146
- run:
132147
name: Convert xcresult into JSON report
133148
working_directory: ios/coverage
134-
command: xcrun xccov view --report --json result.xcresult > report.json
135-
- run:
136-
name: Clone xccov2lcov
137-
command: git clone [email protected]:trax-retail/xccov2lcov.git
138-
- run:
139-
name: Convert xccov into lcov report
140-
working_directory: xccov2lcov
141-
command: swift run xccov2lcov ../ios/coverage/report.json > ../ios/coverage/coverage.txt
149+
command: xcrun xccov view --report --json result.xcresult > xcode.json
150+
- persist_to_workspace:
151+
root: ios/coverage
152+
paths:
153+
- xcode.json
142154

143155
e2e_ios:
144156
macos:
@@ -148,8 +160,7 @@ jobs:
148160
INSTABUG_SOURCEMAPS_UPLOAD_DISABLE: true
149161
steps:
150162
- advanced-checkout/shallow-checkout
151-
- node/install-packages:
152-
pkg-manager: yarn
163+
- install_node_modules
153164
- node/install-packages:
154165
pkg-manager: yarn
155166
app-dir: examples/default
@@ -182,8 +193,7 @@ jobs:
182193
steps:
183194
- advanced-checkout/shallow-checkout
184195
- node/install-yarn
185-
- node/install-packages:
186-
pkg-manager: yarn
196+
- install_node_modules
187197
- node/install-packages:
188198
pkg-manager: yarn
189199
app-dir: examples/default
@@ -220,8 +230,7 @@ jobs:
220230
- run:
221231
working_directory: Escape/.build/release
222232
command: cp -f Escape /usr/local/bin/escape
223-
- node/install-packages:
224-
pkg-manager: yarn
233+
- install_node_modules:
225234
app-dir: project
226235
- run:
227236
working_directory: project
@@ -233,7 +242,11 @@ jobs:
233242
workflows:
234243
publish:
235244
jobs:
236-
- danger
245+
- danger:
246+
requires:
247+
- test_module
248+
- test_android
249+
- test_ios
237250
- lint
238251
- test_module
239252
- test_android

dangerfile.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import collectCoverage, { ReportType } from '@instabug/danger-plugin-coverage';
12
import { danger, fail, schedule, warn } from 'danger';
23

34
const hasSourceChanges = danger.git.modified_files.some((file) => file.startsWith('src/'));
@@ -20,3 +21,24 @@ async function hasDescription() {
2021
}
2122

2223
schedule(hasDescription());
24+
25+
collectCoverage([
26+
{
27+
label: 'JavaScript',
28+
type: ReportType.LCOV,
29+
filePath: 'coverage/lcov.info',
30+
threshold: 90,
31+
},
32+
{
33+
label: 'Android',
34+
type: ReportType.JACOCO,
35+
filePath: 'coverage/jacocoTestReport.xml',
36+
threshold: 40,
37+
},
38+
{
39+
label: 'iOS',
40+
type: ReportType.XCODE,
41+
filePath: 'coverage/xcode.json',
42+
threshold: 30,
43+
},
44+
]);

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
},
4444
"devDependencies": {
4545
"@apollo/client": "^3.7.0",
46+
"@instabug/danger-plugin-coverage": "Instabug/danger-plugin-coverage",
4647
"@react-native-community/eslint-config": "^3.1.0",
4748
"@react-navigation/native": "^5.9.8",
4849
"@rollup/plugin-commonjs": "^24.0.0",

yarn.lock

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,12 @@
11101110
resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45"
11111111
integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==
11121112

1113+
"@instabug/danger-plugin-coverage@Instabug/danger-plugin-coverage":
1114+
version "0.0.0-development"
1115+
resolved "git+ssh://[email protected]/Instabug/danger-plugin-coverage.git#049ba8c9b8df188d729dba437c474ac5b1a0cf00"
1116+
dependencies:
1117+
fast-xml-parser "^4.2.0"
1118+
11131119
"@jest/console@^24.7.1", "@jest/console@^24.9.0":
11141120
version "24.9.0"
11151121
resolved "https://registry.yarnpkg.com/@jest/console/-/console-24.9.0.tgz#79b1bc06fb74a8cfb01cbdedf945584b1b9707f0"
@@ -3827,6 +3833,13 @@ fast-levenshtein@^2.0.6, fast-levenshtein@~2.0.6:
38273833
resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917"
38283834
integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==
38293835

3836+
fast-xml-parser@^4.2.0:
3837+
version "4.2.0"
3838+
resolved "https://registry.yarnpkg.com/fast-xml-parser/-/fast-xml-parser-4.2.0.tgz#6db2ba33b95b8b4af93f94fe024d4b4d02a50855"
3839+
integrity sha512-+zVQv4aVTO+o8oRUyRL7PjgeVo1J6oP8Cw2+a8UTZQcj5V0yUK5T63gTN0ldgiHDPghUjKc4OpT6SwMTwnOQug==
3840+
dependencies:
3841+
strnum "^1.0.5"
3842+
38303843
fastq@^1.6.0:
38313844
version "1.13.0"
38323845
resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.13.0.tgz#616760f88a7526bdfc596b7cab8c18938c36b98c"
@@ -7955,6 +7968,11 @@ strip-json-comments@^3.1.0, strip-json-comments@^3.1.1:
79557968
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006"
79567969
integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==
79577970

7971+
strnum@^1.0.5:
7972+
version "1.0.5"
7973+
resolved "https://registry.yarnpkg.com/strnum/-/strnum-1.0.5.tgz#5c4e829fe15ad4ff0d20c3db5ac97b73c9b072db"
7974+
integrity sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA==
7975+
79587976
sudo-prompt@^9.0.0:
79597977
version "9.2.1"
79607978
resolved "https://registry.yarnpkg.com/sudo-prompt/-/sudo-prompt-9.2.1.tgz#77efb84309c9ca489527a4e749f287e6bdd52afd"

0 commit comments

Comments
 (0)