Skip to content

Commit a2f3ba8

Browse files
hramosfacebook-github-bot
authored andcommittedJan 31, 2018
Generate JUnit test reports for iOS builds
Summary: Closes #17794 Differential Revision: D6850015 Pulled By: hramos fbshipit-source-id: bd230a5aa6fe14fb760f7b0c5f0989bf6ee1e8ea
1 parent a70fdac commit a2f3ba8

File tree

3 files changed

+61
-12
lines changed

3 files changed

+61
-12
lines changed
 

‎.circleci/config.yml

+57-11
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ aliases:
8888
sudo apt-get install -y nodejs
8989

9090
- &run-js-tests
91-
|
92-
yarn test --maxWorkers=2
91+
name: JavaScript Test Suite
92+
command: yarn test-ci
9393

9494
- &run-lint-checks
9595
|
@@ -183,11 +183,16 @@ aliases:
183183
- &collect-android-test-results
184184
name: Collect Test Results
185185
command: |
186-
mkdir -p ~/junit/
187-
find . -type f -regex ".*/build/test-results/debug/.*xml" -exec cp {} ~/junit/ \;
188-
find . -type f -regex ".*/outputs/androidTest-results/connected/.*xml" -exec cp {} ~/junit/ \;
186+
find . -type f -regex ".*/build/test-results/debug/.*xml" -exec cp {} ~/reports/junit/ \;
187+
find . -type f -regex ".*/outputs/androidTest-results/connected/.*xml" -exec cp {} ~/reports/junit/ \;
188+
find . -type f -regex ".*/buck-out/gen/ReactAndroid/src/test/.*/.*xml" -exec cp {} ~/reports/junit/ \;
189189
when: always
190190

191+
- &setup-artifacts
192+
name: Initial Setup
193+
command: |
194+
mkdir -p ~/reports/junit/
195+
191196
defaults: &defaults
192197
working_directory: ~/react-native
193198

@@ -213,6 +218,8 @@ jobs:
213218
- image: circleci/node:8
214219
steps:
215220
- checkout
221+
- run: *setup-artifacts
222+
216223
- restore-cache: *restore-yarn-cache
217224
- run: *yarn
218225
- save-cache: *save-yarn-cache
@@ -226,10 +233,16 @@ jobs:
226233
- image: circleci/node:8
227234
steps:
228235
- checkout
236+
- run: *setup-artifacts
237+
229238
- restore-cache: *restore-yarn-cache
230239
- run: *yarn
231240
- save-cache: *save-yarn-cache
232241
- run: *run-js-tests
242+
- store_test_results:
243+
path: ~/reports/junit
244+
- store_artifacts:
245+
path: ~/reports/junit
233246

234247
# Runs JavaScript tests on Node 6
235248
test-js-node-6:
@@ -238,10 +251,16 @@ jobs:
238251
- image: circleci/node:6
239252
steps:
240253
- checkout
254+
- run: *setup-artifacts
255+
241256
- restore-cache: *restore-yarn-cache
242257
- run: *yarn
243258
- save-cache: *save-yarn-cache
244259
- run: *run-js-tests
260+
- store_test_results:
261+
path: ~/reports/junit
262+
- store_artifacts:
263+
path: ~/reports/junit
245264

246265
# Runs unit tests on iOS devices
247266
test-objc-ios:
@@ -253,10 +272,16 @@ jobs:
253272
- xcrun instruments -w "iPhone 5s (10.3.1)" || true
254273
steps:
255274
- checkout
275+
- run: *setup-artifacts
276+
256277
- restore-cache: *restore-yarn-cache
257278
- run: *yarn
258279
- save-cache: *save-yarn-cache
259280
- run: ./scripts/objc-test-ios.sh
281+
- store_test_results:
282+
path: ~/reports/junit
283+
- store_artifacts:
284+
path: ~/reports/junit
260285

261286
# Runs unit tests on tvOS devices
262287
test-objc-tvos:
@@ -268,10 +293,16 @@ jobs:
268293
- xcrun instruments -w "Apple TV 1080p (10.0)" || true
269294
steps:
270295
- checkout
296+
- run: *setup-artifacts
297+
271298
- restore-cache: *restore-yarn-cache
272299
- run: *yarn
273300
- save-cache: *save-yarn-cache
274301
- run: ./scripts/objc-test-tvos.sh
302+
- store_test_results:
303+
path: ~/reports/junit
304+
- store_artifacts:
305+
path: ~/reports/junit
275306

276307
# Runs end to end tests
277308
test-objc-e2e:
@@ -283,6 +314,8 @@ jobs:
283314
- xcrun instruments -w "iPhone 5s (10.3.1)" || true
284315
steps:
285316
- checkout
317+
- run: *setup-artifacts
318+
286319
- restore-cache: *restore-yarn-cache
287320
- run: *yarn
288321
- save-cache: *save-yarn-cache
@@ -295,6 +328,8 @@ jobs:
295328
xcode: "9.0"
296329
steps:
297330
- checkout
331+
- run: *setup-artifacts
332+
298333
- restore-cache: *restore-yarn-cache
299334
- run: *yarn
300335
- save-cache: *save-yarn-cache
@@ -305,6 +340,7 @@ jobs:
305340
<<: *android_defaults
306341
steps:
307342
- checkout
343+
- run: *setup-artifacts
308344

309345
# Configure Android dependencies
310346
- run: *configure-android-path
@@ -349,7 +385,8 @@ jobs:
349385
<<: *android_defaults
350386
steps:
351387
- checkout
352-
388+
- run: *setup-artifacts
389+
353390
# Configure Android dependencies
354391
- run: *configure-android-path
355392
- run: *install-build-dependencies
@@ -399,22 +436,24 @@ jobs:
399436
# post (always runs)
400437
- run: *collect-android-test-results
401438
- store_test_results:
402-
path: ~/junit
439+
path: ~/reports/junit
403440
- store_artifacts:
404-
path: ~/junit
441+
path: ~/reports/junit
405442

406443
analyze-pull-request:
407444
<<: *defaults
408445
docker:
409446
- image: circleci/node:8
410447
steps:
411448
- checkout
449+
- run: *setup-artifacts
450+
412451
- restore-cache: *restore-cache-analysis
413452
- run: *yarn
414453
- run:
415454
name: Install Additional Dependencies
416455
command: |
417-
if [ -n "$CIRCLE_PULL_REQUEST" ]; then
456+
if [ -n "$CIRCLE_PR_NUMBER" ]; then
418457
yarn add github@0.2.4
419458
cd danger
420459
yarn install --non-interactive --cache-folder ~/.cache/yarn
@@ -425,22 +464,29 @@ jobs:
425464
- run:
426465
name: Analyze Pull Request
427466
command: |
428-
if [ -n "$CIRCLE_PULL_REQUEST" ]; then
467+
if [ -n "$CIRCLE_PR_NUMBER" ]; then
429468
cd danger && DANGER_GITHUB_API_TOKEN="e622517d9f1136ea8900""07c6373666312cdfaa69" yarn danger
430469
else
431470
echo "Skipping pull request analysis."
432471
fi
472+
background: true
433473
when: always
434474
- run:
435475
name: Analyze Code
436476
command: |
437477
if [ -n "$CIRCLE_PR_NUMBER" ]; then
438478
cat <(echo eslint; yarn --silent lint --format=json; echo flow; yarn --silent flow check --json) | GITHUB_TOKEN="af6ef0d15709bc91d""06a6217a5a826a226fb57b7" CI_USER=$CIRCLE_PROJECT_USERNAME CI_REPO=$CIRCLE_PROJECT_REPONAME PULL_REQUEST_NUMBER=$CIRCLE_PR_NUMBER node bots/code-analysis-bot.js
479+
yarn lint --format junit -o ~/reports/junit/js-lint-results.xml
439480
else
440481
echo "Skipping code analysis."
441482
fi
483+
background: true
442484
when: always
443-
485+
- store_test_results:
486+
path: ~/reports/junit
487+
- store_artifacts:
488+
path: ~/reports/junit
489+
444490
# Workflows enables us to run multiple jobs in parallel
445491
workflows:
446492
version: 2

‎package.json

+2
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
],
124124
"scripts": {
125125
"test": "jest",
126+
"test-ci": "JEST_JUNIT_OUTPUT=\"~/reports/junit/js-test-results.xml\" jest --maxWorkers=2 --ci --testResultsProcessor=\"jest-junit\"",
126127
"flow": "flow",
127128
"lint": "eslint .",
128129
"prettier": "find . -name node_modules -prune -or -name '*.js' -print | xargs prettier --write",
@@ -216,6 +217,7 @@
216217
"eslint-plugin-react": "^7.2.1",
217218
"flow-bin": "^0.64.0",
218219
"jest": "22.1.2",
220+
"jest-junit": "^3.4.1",
219221
"prettier": "1.9.1",
220222
"react": "16.2.0",
221223
"react-test-renderer": "16.2.0",

‎scripts/objc-test.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ xcodebuild \
8181
-scheme $SCHEME \
8282
-sdk $SDK \
8383
-destination "$DESTINATION" \
84-
build test
84+
build test \
85+
| xcpretty --report junit --output ~/reports/junit/objc-xcodebuild-results.xml
8586

8687
else
8788

0 commit comments

Comments
 (0)
Please sign in to comment.