Skip to content

Commit

Permalink
Generate JUnit test reports for iOS builds
Browse files Browse the repository at this point in the history
Summary: Closes #17794

Differential Revision: D6850015

Pulled By: hramos

fbshipit-source-id: bd230a5aa6fe14fb760f7b0c5f0989bf6ee1e8ea
  • Loading branch information
hramos authored and facebook-github-bot committed Jan 31, 2018
1 parent a70fdac commit a2f3ba8
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 12 deletions.
68 changes: 57 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ aliases:
sudo apt-get install -y nodejs

- &run-js-tests
|
yarn test --maxWorkers=2
name: JavaScript Test Suite
command: yarn test-ci

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

- &setup-artifacts
name: Initial Setup
command: |
mkdir -p ~/reports/junit/
defaults: &defaults
working_directory: ~/react-native

Expand All @@ -213,6 +218,8 @@ jobs:
- image: circleci/node:8
steps:
- checkout
- run: *setup-artifacts

- restore-cache: *restore-yarn-cache
- run: *yarn
- save-cache: *save-yarn-cache
Expand All @@ -226,10 +233,16 @@ jobs:
- image: circleci/node:8
steps:
- checkout
- run: *setup-artifacts

- restore-cache: *restore-yarn-cache
- run: *yarn
- save-cache: *save-yarn-cache
- run: *run-js-tests
- store_test_results:
path: ~/reports/junit
- store_artifacts:
path: ~/reports/junit

# Runs JavaScript tests on Node 6
test-js-node-6:
Expand All @@ -238,10 +251,16 @@ jobs:
- image: circleci/node:6
steps:
- checkout
- run: *setup-artifacts

- restore-cache: *restore-yarn-cache
- run: *yarn
- save-cache: *save-yarn-cache
- run: *run-js-tests
- store_test_results:
path: ~/reports/junit
- store_artifacts:
path: ~/reports/junit

# Runs unit tests on iOS devices
test-objc-ios:
Expand All @@ -253,10 +272,16 @@ jobs:
- xcrun instruments -w "iPhone 5s (10.3.1)" || true
steps:
- checkout
- run: *setup-artifacts

- restore-cache: *restore-yarn-cache
- run: *yarn
- save-cache: *save-yarn-cache
- run: ./scripts/objc-test-ios.sh
- store_test_results:
path: ~/reports/junit
- store_artifacts:
path: ~/reports/junit

# Runs unit tests on tvOS devices
test-objc-tvos:
Expand All @@ -268,10 +293,16 @@ jobs:
- xcrun instruments -w "Apple TV 1080p (10.0)" || true
steps:
- checkout
- run: *setup-artifacts

- restore-cache: *restore-yarn-cache
- run: *yarn
- save-cache: *save-yarn-cache
- run: ./scripts/objc-test-tvos.sh
- store_test_results:
path: ~/reports/junit
- store_artifacts:
path: ~/reports/junit

# Runs end to end tests
test-objc-e2e:
Expand All @@ -283,6 +314,8 @@ jobs:
- xcrun instruments -w "iPhone 5s (10.3.1)" || true
steps:
- checkout
- run: *setup-artifacts

- restore-cache: *restore-yarn-cache
- run: *yarn
- save-cache: *save-yarn-cache
Expand All @@ -295,6 +328,8 @@ jobs:
xcode: "9.0"
steps:
- checkout
- run: *setup-artifacts

- restore-cache: *restore-yarn-cache
- run: *yarn
- save-cache: *save-yarn-cache
Expand All @@ -305,6 +340,7 @@ jobs:
<<: *android_defaults
steps:
- checkout
- run: *setup-artifacts

# Configure Android dependencies
- run: *configure-android-path
Expand Down Expand Up @@ -349,7 +385,8 @@ jobs:
<<: *android_defaults
steps:
- checkout

- run: *setup-artifacts

# Configure Android dependencies
- run: *configure-android-path
- run: *install-build-dependencies
Expand Down Expand Up @@ -399,22 +436,24 @@ jobs:
# post (always runs)
- run: *collect-android-test-results
- store_test_results:
path: ~/junit
path: ~/reports/junit
- store_artifacts:
path: ~/junit
path: ~/reports/junit

analyze-pull-request:
<<: *defaults
docker:
- image: circleci/node:8
steps:
- checkout
- run: *setup-artifacts

- restore-cache: *restore-cache-analysis
- run: *yarn
- run:
name: Install Additional Dependencies
command: |
if [ -n "$CIRCLE_PULL_REQUEST" ]; then
if [ -n "$CIRCLE_PR_NUMBER" ]; then
yarn add [email protected]
cd danger
yarn install --non-interactive --cache-folder ~/.cache/yarn
Expand All @@ -425,22 +464,29 @@ jobs:
- run:
name: Analyze Pull Request
command: |
if [ -n "$CIRCLE_PULL_REQUEST" ]; then
if [ -n "$CIRCLE_PR_NUMBER" ]; then
cd danger && DANGER_GITHUB_API_TOKEN="e622517d9f1136ea8900""07c6373666312cdfaa69" yarn danger
else
echo "Skipping pull request analysis."
fi
background: true
when: always
- run:
name: Analyze Code
command: |
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
yarn lint --format junit -o ~/reports/junit/js-lint-results.xml
else
echo "Skipping code analysis."
fi
background: true
when: always

- store_test_results:
path: ~/reports/junit
- store_artifacts:
path: ~/reports/junit

# Workflows enables us to run multiple jobs in parallel
workflows:
version: 2
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
],
"scripts": {
"test": "jest",
"test-ci": "JEST_JUNIT_OUTPUT=\"~/reports/junit/js-test-results.xml\" jest --maxWorkers=2 --ci --testResultsProcessor=\"jest-junit\"",
"flow": "flow",
"lint": "eslint .",
"prettier": "find . -name node_modules -prune -or -name '*.js' -print | xargs prettier --write",
Expand Down Expand Up @@ -216,6 +217,7 @@
"eslint-plugin-react": "^7.2.1",
"flow-bin": "^0.64.0",
"jest": "22.1.2",
"jest-junit": "^3.4.1",
"prettier": "1.9.1",
"react": "16.2.0",
"react-test-renderer": "16.2.0",
Expand Down
3 changes: 2 additions & 1 deletion scripts/objc-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ xcodebuild \
-scheme $SCHEME \
-sdk $SDK \
-destination "$DESTINATION" \
build test
build test \
| xcpretty --report junit --output ~/reports/junit/objc-xcodebuild-results.xml

else

Expand Down

0 comments on commit a2f3ba8

Please sign in to comment.