Generate JUnit test reports for iOS builds

Summary: Closes https://github.com/facebook/react-native/pull/17794

Differential Revision: D6850015

Pulled By: hramos

fbshipit-source-id: bd230a5aa6fe14fb760f7b0c5f0989bf6ee1e8ea
This commit is contained in:
Héctor Ramos 2018-01-31 14:48:51 -08:00 committed by Facebook Github Bot
parent a70fdac5bd
commit a2f3ba864e
3 changed files with 61 additions and 12 deletions

View File

@ -88,8 +88,8 @@ aliases:
sudo apt-get install -y nodejs sudo apt-get install -y nodejs
- &run-js-tests - &run-js-tests
| name: JavaScript Test Suite
yarn test --maxWorkers=2 command: yarn test-ci
- &run-lint-checks - &run-lint-checks
| |
@ -183,11 +183,16 @@ aliases:
- &collect-android-test-results - &collect-android-test-results
name: Collect Test Results name: Collect Test Results
command: | command: |
mkdir -p ~/junit/ find . -type f -regex ".*/build/test-results/debug/.*xml" -exec cp {} ~/reports/junit/ \;
find . -type f -regex ".*/build/test-results/debug/.*xml" -exec cp {} ~/junit/ \; find . -type f -regex ".*/outputs/androidTest-results/connected/.*xml" -exec cp {} ~/reports/junit/ \;
find . -type f -regex ".*/outputs/androidTest-results/connected/.*xml" -exec cp {} ~/junit/ \; find . -type f -regex ".*/buck-out/gen/ReactAndroid/src/test/.*/.*xml" -exec cp {} ~/reports/junit/ \;
when: always when: always
- &setup-artifacts
name: Initial Setup
command: |
mkdir -p ~/reports/junit/
defaults: &defaults defaults: &defaults
working_directory: ~/react-native working_directory: ~/react-native
@ -213,6 +218,8 @@ jobs:
- image: circleci/node:8 - image: circleci/node:8
steps: steps:
- checkout - checkout
- run: *setup-artifacts
- restore-cache: *restore-yarn-cache - restore-cache: *restore-yarn-cache
- run: *yarn - run: *yarn
- save-cache: *save-yarn-cache - save-cache: *save-yarn-cache
@ -226,10 +233,16 @@ jobs:
- image: circleci/node:8 - image: circleci/node:8
steps: steps:
- checkout - checkout
- run: *setup-artifacts
- restore-cache: *restore-yarn-cache - restore-cache: *restore-yarn-cache
- run: *yarn - run: *yarn
- save-cache: *save-yarn-cache - save-cache: *save-yarn-cache
- run: *run-js-tests - run: *run-js-tests
- store_test_results:
path: ~/reports/junit
- store_artifacts:
path: ~/reports/junit
# Runs JavaScript tests on Node 6 # Runs JavaScript tests on Node 6
test-js-node-6: test-js-node-6:
@ -238,10 +251,16 @@ jobs:
- image: circleci/node:6 - image: circleci/node:6
steps: steps:
- checkout - checkout
- run: *setup-artifacts
- restore-cache: *restore-yarn-cache - restore-cache: *restore-yarn-cache
- run: *yarn - run: *yarn
- save-cache: *save-yarn-cache - save-cache: *save-yarn-cache
- run: *run-js-tests - run: *run-js-tests
- store_test_results:
path: ~/reports/junit
- store_artifacts:
path: ~/reports/junit
# Runs unit tests on iOS devices # Runs unit tests on iOS devices
test-objc-ios: test-objc-ios:
@ -253,10 +272,16 @@ jobs:
- xcrun instruments -w "iPhone 5s (10.3.1)" || true - xcrun instruments -w "iPhone 5s (10.3.1)" || true
steps: steps:
- checkout - checkout
- run: *setup-artifacts
- restore-cache: *restore-yarn-cache - restore-cache: *restore-yarn-cache
- run: *yarn - run: *yarn
- save-cache: *save-yarn-cache - save-cache: *save-yarn-cache
- run: ./scripts/objc-test-ios.sh - run: ./scripts/objc-test-ios.sh
- store_test_results:
path: ~/reports/junit
- store_artifacts:
path: ~/reports/junit
# Runs unit tests on tvOS devices # Runs unit tests on tvOS devices
test-objc-tvos: test-objc-tvos:
@ -268,10 +293,16 @@ jobs:
- xcrun instruments -w "Apple TV 1080p (10.0)" || true - xcrun instruments -w "Apple TV 1080p (10.0)" || true
steps: steps:
- checkout - checkout
- run: *setup-artifacts
- restore-cache: *restore-yarn-cache - restore-cache: *restore-yarn-cache
- run: *yarn - run: *yarn
- save-cache: *save-yarn-cache - save-cache: *save-yarn-cache
- run: ./scripts/objc-test-tvos.sh - run: ./scripts/objc-test-tvos.sh
- store_test_results:
path: ~/reports/junit
- store_artifacts:
path: ~/reports/junit
# Runs end to end tests # Runs end to end tests
test-objc-e2e: test-objc-e2e:
@ -283,6 +314,8 @@ jobs:
- xcrun instruments -w "iPhone 5s (10.3.1)" || true - xcrun instruments -w "iPhone 5s (10.3.1)" || true
steps: steps:
- checkout - checkout
- run: *setup-artifacts
- restore-cache: *restore-yarn-cache - restore-cache: *restore-yarn-cache
- run: *yarn - run: *yarn
- save-cache: *save-yarn-cache - save-cache: *save-yarn-cache
@ -295,6 +328,8 @@ jobs:
xcode: "9.0" xcode: "9.0"
steps: steps:
- checkout - checkout
- run: *setup-artifacts
- restore-cache: *restore-yarn-cache - restore-cache: *restore-yarn-cache
- run: *yarn - run: *yarn
- save-cache: *save-yarn-cache - save-cache: *save-yarn-cache
@ -305,6 +340,7 @@ jobs:
<<: *android_defaults <<: *android_defaults
steps: steps:
- checkout - checkout
- run: *setup-artifacts
# Configure Android dependencies # Configure Android dependencies
- run: *configure-android-path - run: *configure-android-path
@ -349,6 +385,7 @@ jobs:
<<: *android_defaults <<: *android_defaults
steps: steps:
- checkout - checkout
- run: *setup-artifacts
# Configure Android dependencies # Configure Android dependencies
- run: *configure-android-path - run: *configure-android-path
@ -399,9 +436,9 @@ jobs:
# post (always runs) # post (always runs)
- run: *collect-android-test-results - run: *collect-android-test-results
- store_test_results: - store_test_results:
path: ~/junit path: ~/reports/junit
- store_artifacts: - store_artifacts:
path: ~/junit path: ~/reports/junit
analyze-pull-request: analyze-pull-request:
<<: *defaults <<: *defaults
@ -409,12 +446,14 @@ jobs:
- image: circleci/node:8 - image: circleci/node:8
steps: steps:
- checkout - checkout
- run: *setup-artifacts
- restore-cache: *restore-cache-analysis - restore-cache: *restore-cache-analysis
- run: *yarn - run: *yarn
- run: - run:
name: Install Additional Dependencies name: Install Additional Dependencies
command: | command: |
if [ -n "$CIRCLE_PULL_REQUEST" ]; then if [ -n "$CIRCLE_PR_NUMBER" ]; then
yarn add github@0.2.4 yarn add github@0.2.4
cd danger cd danger
yarn install --non-interactive --cache-folder ~/.cache/yarn yarn install --non-interactive --cache-folder ~/.cache/yarn
@ -425,21 +464,28 @@ jobs:
- run: - run:
name: Analyze Pull Request name: Analyze Pull Request
command: | command: |
if [ -n "$CIRCLE_PULL_REQUEST" ]; then if [ -n "$CIRCLE_PR_NUMBER" ]; then
cd danger && DANGER_GITHUB_API_TOKEN="e622517d9f1136ea8900""07c6373666312cdfaa69" yarn danger cd danger && DANGER_GITHUB_API_TOKEN="e622517d9f1136ea8900""07c6373666312cdfaa69" yarn danger
else else
echo "Skipping pull request analysis." echo "Skipping pull request analysis."
fi fi
background: true
when: always when: always
- run: - run:
name: Analyze Code name: Analyze Code
command: | command: |
if [ -n "$CIRCLE_PR_NUMBER" ]; then if [ -n "$CIRCLE_PR_NUMBER" ]; then
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 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
yarn lint --format junit -o ~/reports/junit/js-lint-results.xml
else else
echo "Skipping code analysis." echo "Skipping code analysis."
fi fi
background: true
when: always when: always
- store_test_results:
path: ~/reports/junit
- store_artifacts:
path: ~/reports/junit
# Workflows enables us to run multiple jobs in parallel # Workflows enables us to run multiple jobs in parallel
workflows: workflows:

View File

@ -123,6 +123,7 @@
], ],
"scripts": { "scripts": {
"test": "jest", "test": "jest",
"test-ci": "JEST_JUNIT_OUTPUT=\"~/reports/junit/js-test-results.xml\" jest --maxWorkers=2 --ci --testResultsProcessor=\"jest-junit\"",
"flow": "flow", "flow": "flow",
"lint": "eslint .", "lint": "eslint .",
"prettier": "find . -name node_modules -prune -or -name '*.js' -print | xargs prettier --write", "prettier": "find . -name node_modules -prune -or -name '*.js' -print | xargs prettier --write",
@ -216,6 +217,7 @@
"eslint-plugin-react": "^7.2.1", "eslint-plugin-react": "^7.2.1",
"flow-bin": "^0.64.0", "flow-bin": "^0.64.0",
"jest": "22.1.2", "jest": "22.1.2",
"jest-junit": "^3.4.1",
"prettier": "1.9.1", "prettier": "1.9.1",
"react": "16.2.0", "react": "16.2.0",
"react-test-renderer": "16.2.0", "react-test-renderer": "16.2.0",

View File

@ -81,7 +81,8 @@ xcodebuild \
-scheme $SCHEME \ -scheme $SCHEME \
-sdk $SDK \ -sdk $SDK \
-destination "$DESTINATION" \ -destination "$DESTINATION" \
build test build test \
| xcpretty --report junit --output ~/reports/junit/objc-xcodebuild-results.xml
else else