Collect unit test results in test_android job

Summary:
Explicitly generate a XML file with unit test results, and convert this file to JUnit format for display in Circle.

Run in Circle: https://circleci.com/gh/hramos/react-native/1869

![screen shot 2018-03-28 at 12 07 15 pm](https://user-images.githubusercontent.com/165856/38050644-9712b6c6-3280-11e8-953c-a2eb722edf39.png)

[INTERNAL] [MINOR] [.circleci] - Collect, process, and display Android unit test results on Circle
Closes https://github.com/facebook/react-native/pull/18608

Differential Revision: D7433151

Pulled By: hramos

fbshipit-source-id: 7c18b552d7790b238b4c2a720fb316dff8fd7ec3
This commit is contained in:
Héctor Ramos 2018-03-28 12:53:08 -07:00 committed by Facebook Github Bot
parent 7cbb222cd5
commit b531612b2c
2 changed files with 24 additions and 19 deletions

View File

@ -56,20 +56,21 @@ aliases:
- &restore-cache-ndk - &restore-cache-ndk
keys: keys:
- v2-android-ndk-{{ arch }}-r10e-32-64-{{ checksum "scripts/circle-ci-android-setup.sh" }} - v3-android-ndk-{{ arch }}-r10e-{{ checksum "scripts/circle-ci-android-setup.sh" }}
- v2-android-ndk-{{ arch }}-r10e-32-64- - v3-android-ndk-{{ arch }}-r10e-
- &save-cache-ndk - &save-cache-ndk
paths: paths:
- /opt/ndk - /opt/ndk
key: v2-android-ndk-{{ arch }}-r10e-32-64-{{ checksum "scripts/circle-ci-android-setup.sh" }} key: v3-android-ndk-{{ arch }}-r10e-{{ checksum "scripts/circle-ci-android-setup.sh" }}
- &restore-cache-buck - &restore-cache-buck
keys: keys:
- v2-buck-{{ arch }}-v2018.02.16.01 - v3-buck-{{ arch }}-v2018.02.16.01
- &save-cache-buck - &save-cache-buck
paths: paths:
- ~/buck - ~/buck
key: v2-buck-{{ arch }}-v2018.02.16.01 - ~/okbuck
key: v3-buck-{{ arch }}-v2018.02.16.01
- &restore-cache-watchman - &restore-cache-watchman
keys: keys:
@ -141,6 +142,13 @@ aliases:
fi fi
cd ~/buck && ant cd ~/buck && ant
buck --version buck --version
# Install related tooling
if [[ ! -e ~/okbuck ]]; then
git clone https://github.com/uber/okbuck.git ~/okbuck --depth=1
fi
mkdir -p ~/react-native/tooling/junit
cp -R ~/okbuck/tooling/junit/* ~/react-native/tooling/junit/.
- &install-node - &install-node
name: Install Node name: Install Node
@ -237,7 +245,7 @@ aliases:
- &run-android-unit-tests - &run-android-unit-tests
name: Run Unit Tests name: Run Unit Tests
command: buck test ReactAndroid/src/test/... --config build.threads=$BUILD_THREADS command: buck test ReactAndroid/src/test/... --config build.threads=$BUILD_THREADS --xml ~/react-native/reports/buck/all-results-raw.xml
- &run-android-instrumentation-tests - &run-android-instrumentation-tests
name: Run Instrumentation Tests name: Run Instrumentation Tests
@ -250,15 +258,19 @@ aliases:
- &collect-android-test-results - &collect-android-test-results
name: Collect Test Results name: Collect Test Results
command: | command: |
find . -type f -regex ".*/build/test-results/debug/.*xml" -exec cp {} ~/react-native/reports/junit/ \; find . -type f -regex ".*/build/test-results/debug/.*xml" -exec cp {} ~/react-native/reports/build/ \;
find . -type f -regex ".*/outputs/androidTest-results/connected/.*xml" -exec cp {} ~/react-native/reports/junit/ \; find . -type f -regex ".*/outputs/androidTest-results/connected/.*xml" -exec cp {} ~/react-native/reports/outputs/ \;
find . -type f -regex ".*/buck-out/gen/ReactAndroid/src/test/.*/.*xml" -exec cp {} ~/react-native/reports/junit/ \; find . -type f -regex ".*/buck-out/gen/ReactAndroid/src/test/.*/.*xml" -exec cp {} ~/react-native/reports/buck/ \;
./tooling/junit/buck_to_junit.sh ~/react-native/reports/buck/all-results-raw.xml ~/react-native/reports/junit/all-results-junit.xml
when: always when: always
- &setup-artifacts - &setup-artifacts
name: Initial Setup name: Initial Setup
command: | command: |
mkdir -p ~/react-native/reports/buck/
mkdir -p ~/react-native/reports/build/
mkdir -p ~/react-native/reports/junit/ mkdir -p ~/react-native/reports/junit/
mkdir -p ~/react-native/reports/outputs/
- &run-objc-ios-tests - &run-objc-ios-tests
name: iOS Test Suite name: iOS Test Suite
@ -289,7 +301,7 @@ js_defaults: &js_defaults
android_defaults: &android_defaults android_defaults: &android_defaults
<<: *defaults <<: *defaults
docker: docker:
- image: circleci/android:api-26-alpha - image: circleci/android:api-26-node8-alpha
resource_class: "large" resource_class: "large"
environment: environment:
- TERM: "dumb" - TERM: "dumb"
@ -457,8 +469,6 @@ jobs:
- run: *gradle-download-deps - run: *gradle-download-deps
- save-cache: *save-cache-gradle-downloads - save-cache: *save-cache-gradle-downloads
- run: *install-node
- run: *install-yarn
- restore-cache: *restore-cache-yarn - restore-cache: *restore-cache-yarn
- run: *yarn - run: *yarn
- save-cache: *save-cache-yarn - save-cache: *save-cache-yarn
@ -529,7 +539,6 @@ jobs:
- run: *compile-native-libs - run: *compile-native-libs
# Build JavaScript Bundle for instrumentation tests # Build JavaScript Bundle for instrumentation tests
- run: *install-node
- run: *build-js-bundle - run: *build-js-bundle
# Wait for AVD to finish booting before running tests # Wait for AVD to finish booting before running tests
@ -539,12 +548,11 @@ jobs:
- run: *run-android-unit-tests - run: *run-android-unit-tests
- run: *run-android-instrumentation-tests - run: *run-android-instrumentation-tests
# post (always runs) # Collect Results
- run: *collect-android-test-results - run: *collect-android-test-results
- store_test_results: - store_test_results:
path: ~/react-native/reports/junit path: ~/react-native/reports/junit
# Analyze pull request and raise any lint/flow issues. # Analyze pull request and raise any lint/flow issues.
# Issues will be posted to the PR itself via GitHub bots. # Issues will be posted to the PR itself via GitHub bots.
# This workflow should only fail if the bots fail to run. # This workflow should only fail if the bots fail to run.

View File

@ -41,14 +41,11 @@ function getAndroidNDK {
if [ ! -e $DEPS ]; then if [ ! -e $DEPS ]; then
cd $NDK_HOME cd $NDK_HOME
echo "Downloading NDK..." echo "Downloading NDK..."
curl -o ndk.zip https://dl.google.com/android/repository/android-ndk-r10e-linux-x86.zip curl -o ndk.zip https://dl.google.com/android/repository/android-ndk-r10e-linux-x86_64.zip
curl -o ndk_64.zip https://dl.google.com/android/repository/android-ndk-r10e-linux-x86_64.zip
unzip -o -q ndk.zip unzip -o -q ndk.zip
unzip -o -q ndk_64.zip
echo "Installed Android NDK at $NDK_HOME" echo "Installed Android NDK at $NDK_HOME"
touch $DEPS touch $DEPS
rm ndk.zip rm ndk.zip
rm ndk_64.zip
fi fi
} }