diff --git a/.circleci/config.yml b/.circleci/config.yml index 60b83785764046..ac77c3d7d2c3ae 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -47,7 +47,6 @@ references: # Anchors for the cache keys cache_keys: - buck_cache_key: &buck_cache_key v3-buck-v2019.01.10.01-{{ checksum "scripts/circleci/buck_fetch.sh" }}} checkout_cache_key: &checkout_cache_key v1-checkout gems_cache_key: &gems_cache_key v1-gems-{{ checksum "Gemfile.lock" }} gradle_cache_key: &gradle_cache_key v1-gradle-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "ReactAndroid/gradle.properties" }} @@ -177,25 +176,6 @@ commands: - ~/.cache/yarn key: << parameters.yarn_base_cache_key >>-{{ arch }}-{{ checksum "yarn.lock" }} - install_buck_tooling: - steps: - - restore_cache: - keys: - - *buck_cache_key - - run: - name: Install BUCK - command: | - buck --version - # Install related tooling - if [[ ! -e ~/okbuck ]]; then - git clone https://github.com/uber/okbuck.git ~/okbuck --depth=1 - fi - - save_cache: - paths: - - ~/buck - - ~/okbuck - key: *buck_cache_key - install_github_bot_deps: steps: - run: @@ -247,12 +227,6 @@ commands: - ReactAndroid/build/third-party-ndk key: *gradle_cache_key - download_buck_dependencies: - steps: - - run: - name: Download Dependencies Using Buck - command: ./scripts/circleci/buck_fetch.sh - run_e2e: parameters: platform: @@ -560,6 +534,58 @@ jobs: - store_test_results: path: ./reports/junit + # ------------------------- + # JOBS: Test Buck + # ------------------------- + test_buck: + executor: reactnativeandroid + environment: + KOTLIN_HOME=third-party/kotlin + steps: + - checkout + - setup_artifacts + - run_yarn + + - run: + name: Download Dependencies Using Buck + command: ./scripts/circleci/buck_fetch.sh + + - run: + name: Build & Test React Native using Buck + command: | + buck build ReactAndroid/src/main/java/com/facebook/react + buck build ReactAndroid/src/main/java/com/facebook/react/shell + + - run: + name: Validate Android Test Environment + command: ./scripts/validate-android-test-env.sh + + - run: + name: Run Tests - Android Unit Tests with Buck + command: buck test ReactAndroid/src/test/... --config build.threads=$BUILD_THREADS --xml ./reports/buck/all-results-raw.xml + + - run: + name: Build Tests - Android Instrumentation Tests with Buck + # Here, just build the instrumentation tests. There is a known issue with installing the APK to android-21+ emulator. + command: | + if [[ ! -e ReactAndroid/src/androidTest/assets/AndroidTestBundle.js ]]; then + echo "JavaScript bundle missing, cannot run instrumentation tests. Verify Build JavaScript Bundle step completed successfully."; exit 1; + fi + source scripts/android-setup.sh && NO_BUCKD=1 retry3 timeout 300 buck build ReactAndroid/src/androidTest/buck-runner:instrumentation-tests --config build.threads=$BUILD_THREADS + + - run: + name: Collect Test Results + command: | + find . -type f -regex ".*/build/test-results/debug/.*xml" -exec cp {} ./reports/build/ \; + find . -type f -regex ".*/outputs/androidTest-results/connected/.*xml" -exec cp {} ./reports/outputs/ \; + find . -type f -regex ".*/buck-out/gen/ReactAndroid/src/test/.*/.*xml" -exec cp {} ./reports/buck/ \; + if [ -f ~/react-native/reports/buck/all-results-raw.xml ]; then + ~/react-native/scripts/circleci/buckToJunit/buckToJunit.sh ~/react-native/reports/buck/all-results-raw.xml ~/react-native/reports/junit/results.xml + fi + when: always + + - store_test_results: + path: ./reports/junit # ------------------------- # JOBS: Test Android @@ -570,14 +596,11 @@ jobs: run_disabled_tests: type: boolean default: false - environment: - KOTLIN_HOME=third-party/kotlin steps: - checkout - setup_artifacts - run_yarn - # Validate Android SDK installation and packages - run: name: Validate Android SDK Install command: ./scripts/validate-android-sdk.sh @@ -591,24 +614,8 @@ jobs: command: source scripts/android-setup.sh && launchAVD background: true - # Install Buck - - install_buck_tooling - - # Validate Android test environment (including Buck) - - run: - name: Validate Android Test Environment - command: ./scripts/validate-android-test-env.sh - - - download_buck_dependencies - download_gradle_dependencies - # Build and compile - - run: - name: Build & Test React Native using Buck - command: | - buck build ReactAndroid/src/main/java/com/facebook/react - buck build ReactAndroid/src/main/java/com/facebook/react/shell - - run: name: Build & Test React Native using Gradle command: ./gradlew buildAll @@ -622,9 +629,8 @@ jobs: name: Build RN Tester for Release using Gradle command: ./gradlew packages:rn-tester:android:app:assembleRelease - # Build JavaScript Bundle for instrumentation tests - run: - name: Build JavaScript Bundle + name: Build JavaScript Bundle for instrumentation tests command: node cli.js bundle --max-workers 2 --platform android --dev true --entry-file ReactAndroid/src/androidTest/js/TestBundle.js --bundle-output ReactAndroid/src/androidTest/assets/AndroidTestBundle.js # Wait for AVD to finish booting before running tests @@ -632,19 +638,8 @@ jobs: name: Wait for Android Virtual Device command: source scripts/android-setup.sh && waitForAVD - # ------------------------- - # Run Android tests - - run: - name: Run Tests - Android Unit Tests with Buck - command: buck test ReactAndroid/src/test/... --config build.threads=$BUILD_THREADS --xml ./reports/buck/all-results-raw.xml - - run: - name: Build Tests - Android Instrumentation Tests with Buck - # Here, just build the instrumentation tests. There is a known issue with installing the APK to android-21+ emulator. - command: | - if [[ ! -e ReactAndroid/src/androidTest/assets/AndroidTestBundle.js ]]; then - echo "JavaScript bundle missing, cannot run instrumentation tests. Verify Build JavaScript Bundle step completed successfully."; exit 1; - fi - source scripts/android-setup.sh && NO_BUCKD=1 retry3 timeout 300 buck build ReactAndroid/src/androidTest/buck-runner:instrumentation-tests --config build.threads=$BUILD_THREADS + - report_bundle_size: + platform: android # Optionally, run disabled tests - when: @@ -653,24 +648,6 @@ jobs: - run: echo "Failing tests may be moved here temporarily." - run_e2e: platform: android - # ------------------------- - - # Collect Results - - report_bundle_size: - platform: android - - run: - name: Collect Test Results - command: | - find . -type f -regex ".*/build/test-results/debug/.*xml" -exec cp {} ./reports/build/ \; - find . -type f -regex ".*/outputs/androidTest-results/connected/.*xml" -exec cp {} ./reports/outputs/ \; - find . -type f -regex ".*/buck-out/gen/ReactAndroid/src/test/.*/.*xml" -exec cp {} ./reports/buck/ \; - if [ -f ~/react-native/reports/buck/all-results-raw.xml ]; then - cd ~/okbuck - ./tooling/junit/buck_to_junit.sh ~/react-native/reports/buck/all-results-raw.xml ~/react-native/reports/junit/results.xml - fi - when: always - - store_test_results: - path: ./reports/junit # ------------------------- # JOBS: Test Android Template @@ -1183,8 +1160,6 @@ jobs: cp -r $HERMES_WS_DIR/linux64-bin/* ./sdks/hermesc/linux64-bin/. - run_yarn - - install_buck_tooling - - download_buck_dependencies - download_gradle_dependencies # START: Stables and nightlies @@ -1337,6 +1312,7 @@ workflows: parameters: newarchitecture: [true, false] flavor: ["Debug", "Release"] + - test_buck - test_ios_template: requires: - build_npm_package diff --git a/scripts/circleci/buckToJunit/buckToJunit.sh b/scripts/circleci/buckToJunit/buckToJunit.sh new file mode 100755 index 00000000000000..039ad48125dfd2 --- /dev/null +++ b/scripts/circleci/buckToJunit/buckToJunit.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# Get script directory +prog="$0" +while [ -h "${prog}" ]; do + newProg=`/bin/ls -ld "${prog}"` + newProg=`expr "${newProg}" : ".* -> \(.*\)$"` + if expr "x${newProg}" : 'x/' >/dev/null; then + prog="${newProg}" + else + progdir=`dirname "${prog}"` + prog="${progdir}/${newProg}" + fi +done +DIR=`dirname $prog` + +# We download saxon from Maven Central rather than copying it over. +curl https://repo1.maven.org/maven2/net/sf/saxon/Saxon-HE/9.7.0-11/Saxon-HE-9.7.0-11.jar --output $DIR/saxon.jar + +saxonJar="$DIR/saxon.jar" +buckToJunitXsl="$DIR/buckToJunit.xsl" + +# Perform conversion +java -jar $saxonJar -xsl:$buckToJunitXsl -s:$1 -o:$2 \ No newline at end of file diff --git a/scripts/circleci/buckToJunit/buckToJunit.xsl b/scripts/circleci/buckToJunit/buckToJunit.xsl new file mode 100644 index 00000000000000..bf01ebcf144e86 --- /dev/null +++ b/scripts/circleci/buckToJunit/buckToJunit.xsl @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file