Annotate our CircleCI config (#23606)

Summary:
Inspired by [react-native-netinfo's config](https://github.com/react-native-community/react-native-netinfo/blob/master/.circleci/config.yml). Annotate each of the major sections in our Circle CI config to reduce friction when contributing to our open source test infrastructure.

I've also removed all single-use aliases. While the old layout improved readability when looking at a particular job, it also obscured the actual command being run, as well as introduced unnecessary friction (contributors would need to understand how aliases work, syntax is finicky).

I've also moved the oss sanity checks to the analysis job, as we don't want this test to block the checkout_code job from succeeding, which would block all other downstream jobs.

There should be no other material changes to the actual jobs.

[General] [Changed] - Updated open source test configuration
Pull Request resolved: https://github.com/facebook/react-native/pull/23606

Differential Revision: D14199783

Pulled By: hramos

fbshipit-source-id: 61072eec5c05b8731916a9d8f6bc09ae5191fbb5
This commit is contained in:
Héctor Ramos
2019-02-23 17:01:34 -08:00
committed by Facebook Github Bot
parent 0b4f74176c
commit 39ecd5642d

View File

@@ -1,82 +1,108 @@
# -------------------------
# ALIASES
# -------------------------
aliases:
# Cache Management
# -------------------------
# ALIASES: Caches
# -------------------------
- &restore-yarn-cache
keys:
- v1-yarn-cache-{{ arch }}-{{ checksum "package.json" }}
- v1-yarn-cache-{{ arch }}-{{ checksum "package.json" }}{{ checksum "bots/package.json" }}
- v1-yarn-cache-{{ arch }}
- &save-yarn-cache
paths:
- ~/.cache/yarn
key: v1-yarn-cache-{{ arch }}-{{ checksum "package.json" }}
key: v1-yarn-cache-{{ arch }}-{{ checksum "package.json" }}{{ checksum "bots/package.json" }}
- &restore-node-modules
- &restore-brew-cache
keys:
- v2-node-modules-{{ arch }}-{{ checksum "package.json" }}
- &save-node-modules
paths:
- node_modules
key: v2-node-modules-{{ arch }}-{{ checksum "package.json" }}
- v1-brew
- &restore-cache-analysis
keys:
- v1-analysis-dependencies-{{ arch }}-{{ checksum "package.json" }}{{ checksum "bots/package.json" }}
- &save-cache-analysis
- &save-brew-cache
paths:
- bots/node_modules
- node_modules
key: v1-analysis-dependencies-{{ arch }}-{{ checksum "package.json" }}{{ checksum "bots/package.json" }}
- /usr/local/Homebrew
- ~/Library/Caches/Homebrew
key: v1-brew
- &restore-cache-gradle
keys:
- v1-gradle-{{ .Branch }}-{{ checksum "build.gradle" }}-{{ checksum "ReactAndroid/build.gradle" }}
# Fallback in case checksum fails
- v1-gradle-{{ .Branch }}-{{ checksum "build.gradle" }}-
- v1-gradle-{{ .Branch }}-
# Fallback in case this is a first-time run on a fork
- v1-gradle-master-
- &save-cache-gradle
paths:
- ~/.gradle
key: v1-gradle-{{ .Branch }}-{{ checksum "build.gradle" }}-{{ checksum "ReactAndroid/build.gradle" }}
- &restore-cache-downloads-buck
# Android
- &restore-buck-downloads-cache
keys:
- v3-buck-v2019.01.10.01-{{ checksum "scripts/circleci/buck_fetch.sh" }}}
- v3-buck-v2019.01.10.01-
- &save-cache-downloads-buck
- &save-buck-downloads-cache
paths:
- ~/buck
- ~/okbuck
key: v3-buck-v2019.01.10.01-{{ checksum "scripts/circleci/buck_fetch.sh" }}
- &restore-cache-watchman
keys:
- v1-watchman-{{ arch }}-v4.9.0
- &save-cache-watchman
paths:
- ~/watchman
key: v1-watchman-{{ arch }}-v4.9.0
- &restore-cache-downloads-gradle
- &restore-gradle-downloads-cache
keys:
- v1-gradle-{{ checksum "ReactAndroid/build.gradle" }}-{{ checksum "scripts/circleci/gradle_download_deps.sh" }}
- v1-gradle-
- &save-cache-downloads-gradle
- &save-gradle-downloads-cache
paths:
- ~/.gradle
- ReactAndroid/build/downloads
- ReactAndroid/build/third-party-ndk
key: v1-gradle-{{ checksum "ReactAndroid/build.gradle" }}-{{ checksum "scripts/circleci/gradle_download_deps.sh" }}
- &restore-cache-homebrew
keys:
- v1-homebrew
- &save-cache-homebrew
paths:
- /usr/local/Homebrew
key: v1-homebrew
# -------------------------
# ALIASES: Shared Commands
# -------------------------
- &yarn
name: Run Yarn
command: |
# Skip yarn install on metro bump commits as the package is not yet
# available on npm
if [[ $(echo "$GIT_COMMIT_DESC" | grep -c "Bump metro@") -eq 0 ]]; then
yarn install --non-interactive --cache-folder ~/.cache/yarn
fi
- &setup-artifacts
name: Initial Setup
command: |
mkdir -p ~/react-native/reports/buck/
mkdir -p ~/react-native/reports/build/
mkdir -p ~/react-native/reports/junit/
mkdir -p ~/react-native/reports/outputs/
# Android
- &download-dependencies-buck
name: Download Dependencies Using Buck
command: ./scripts/circleci/buck_fetch.sh
- &download-dependencies-gradle
name: Download Dependencies Using Gradle
command: ./scripts/circleci/gradle_download_deps.sh
# JavaScript
- &run-js-tests
name: JavaScript Test Suite
command: yarn test-ci
# -------------------------
# ALIASES: Disabled Tests
# -------------------------
- &run-podspec-tests
name: Test CocoaPods
command: ./scripts/process-podspecs.sh
- &run-e2e-tests
name: End-to-End Test Suite
command: ./scripts/run-ci-e2e-tests.js --android --ios --js --retries 3;
- &run-android-e2e-tests
name: Android End-to-End Test Suite
command: node ./scripts/run-ci-e2e-tests.js --android --retries 3;
# -------------------------
# ALIASES: Branch Filters
# -------------------------
- &filter-only-master
branches:
only: master
# Branch Filtering
- &filter-only-master-stable
branches:
only:
@@ -92,184 +118,42 @@ aliases:
branches:
ignore: gh-pages
- &filter-ignore-master-stable
- &filter-only-version-tags
# Both of the following conditions must be included!
# Ignore any commit on any branch by default.
branches:
ignore:
- master
- /.*-stable/
- gh-pages
ignore: /.*/
# Only act on version tags.
tags:
only: /v[0-9]+(\.[0-9]+)*(\-rc(\.[0-9]+)?)?/
- &yarn
name: Run Yarn
command: |
# Skip yarn install on metro bump commits as the package is not yet
# available on npm
if [[ $(echo "$GIT_COMMIT_DESC" | grep -c "Bump metro@") -eq 0 ]]; then
yarn install --non-interactive --cache-folder ~/.cache/yarn
fi
- &filter-only-forked-pull-requests
branches:
only: /^pull\/.*$/
- &install-buck
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
mkdir -p ~/react-native/tooling/junit
cp -R ~/okbuck/tooling/junit/* ~/react-native/tooling/junit/.
- &validate-android-sdk
name: Validate Android SDK Install
command: ./scripts/validate-android-sdk.sh
- &validate-android-test-env
name: Validate Android Test Environment
command: ./scripts/validate-android-test-env.sh
# Test Definitions
- &run-js-tests
name: JavaScript Test Suite
command: yarn test-ci
# eslint sometimes runs into trouble generating the reports
- &run-lint-checks
name: Lint code
command: scripts/circleci/exec_swallow_error.sh yarn lint --format junit -o ~/react-native/reports/junit/eslint/results.xml
- &run-flow-checks-ios
name: Check for errors in code using Flow (iOS)
command: yarn flow-check-ios
- &run-flow-checks-android
name: Check for errors in code using Flow (Android)
command: yarn flow-check-android
- &run-sanity-checks
name: Sanity checks
command: |
./scripts/circleci/check_license.sh
./scripts/circleci/validate_yarn_lockfile.sh
when: always
- &js-coverage
name: Test coverage
command: |
yarn test --coverage --maxWorkers=2
cat ./coverage/lcov.info | ./node_modules/.bin/coveralls
when: always
- &download-dependencies-gradle
name: Download Dependencies Using Gradle
command: ./scripts/circleci/gradle_download_deps.sh
- &download-dependencies-buck
name: Download Dependencies Using Buck
command: ./scripts/circleci/buck_fetch.sh
- &build-android-app
name: Build Android App
command: |
buck build ReactAndroid/src/main/java/com/facebook/react
buck build ReactAndroid/src/main/java/com/facebook/react/shell
- &create-avd
name: Create Android Virtual Device
command: source scripts/android-setup.sh && createAVD
- &launch-avd
name: Launch Android Virtual Device in Background
command: source scripts/android-setup.sh && launchAVD
background: true
- &wait-for-avd
name: Wait for Android Virtual Device
command: source scripts/android-setup.sh && waitForAVD
- &build-js-bundle
name: Build JavaScript Bundle
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
- &compile-native-libs
name: Compile Native Libs for Unit and Integration Tests
command: ./gradlew :ReactAndroid:packageReactNdkLibsForBuck -Pjobs=$BUILD_THREADS
no_output_timeout: 6m
- &run-android-unit-tests
name: Run Unit Tests
command: buck test ReactAndroid/src/test/... --config build.threads=$BUILD_THREADS --xml ~/react-native/reports/buck/all-results-raw.xml
- &run-android-instrumentation-tests
name: Run Instrumentation Tests
command: |
if [[ ! -e ReactAndroid/src/androidTest/assets/AndroidTestBundle.js ]]; then
echo "JavaScript bundle missing, cannot run instrumentation tests. Verify build-js-bundle step completed successfully."; exit 1;
fi
source scripts/android-setup.sh && NO_BUCKD=1 retry3 timeout 300 buck install ReactAndroid/src/androidTest/buck-runner:instrumentation-tests --config build.threads=$BUILD_THREADS
- &build-android-rntester-app
name: Build Android RNTester App
command: ./gradlew RNTester:android:app:assembleRelease
- &collect-android-test-results
name: Collect Test Results
command: |
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/outputs/ \;
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
- &setup-artifacts
name: Initial Setup
command: |
mkdir -p ~/react-native/reports/buck/
mkdir -p ~/react-native/reports/build/
mkdir -p ~/react-native/reports/junit/
mkdir -p ~/react-native/reports/outputs/
- &brew-install-watchman
name: Install Watchman
command: |
brew install watchman
touch .watchmanconfig
- &boot-simulator-iphone
name: Boot iPhone Simulator
command: source scripts/.tests.env && xcrun simctl boot "$IOS_DEVICE" || true
- &run-objc-ios-tests
name: iOS Test Suite
command: ./scripts/objc-test-ios.sh test
- &run-objc-ios-e2e-tests
name: iOS End-to-End Test Suite
command: node ./scripts/run-ci-e2e-tests.js --ios --retries 3;
- &run-js-e2e-tests
name: JavaScript End-to-End Test Suite
command: node ./scripts/run-ci-e2e-tests.js --js --retries 3;
# DISABLED TESTS
- &run-podspec-tests
name: Test CocoaPods
command: ./scripts/process-podspecs.sh
- &run-e2e-tests
name: End-to-End Test Suite
command: ./scripts/run-ci-e2e-tests.js --android --ios --js --retries 3;
- &run-android-e2e-tests
name: Android End-to-End Test Suite
command: node ./scripts/run-ci-e2e-tests.js --android --retries 3;
# -------------------------
# ALIASES: Workflows
# -------------------------
- &run-after-checkout
filters: *filter-ignore-gh-pages
requires:
- checkout_code
# -------------------------
# DEFAULTS
# -------------------------
defaults: &defaults
working_directory: ~/react-native
environment:
- GIT_COMMIT_DESC: git log --format=oneline -n 1 $CIRCLE_SHA1
# JavaScript
js_defaults: &js_defaults
<<: *defaults
docker:
- image: node:8
# Android
android_defaults: &android_defaults
<<: *defaults
docker:
@@ -282,11 +166,15 @@ android_defaults: &android_defaults
- GRADLE_OPTS: '-Dorg.gradle.daemon=false -Dorg.gradle.jvmargs="-XX:+HeapDumpOnOutOfMemoryError"'
- BUILD_THREADS: 2
# iOS
macos_defaults: &macos_defaults
<<: *defaults
macos:
xcode: "10.1.0"
# -------------------------
# JOBS
# -------------------------
version: 2
jobs:
# Set up a Node environment for downstream jobs
@@ -300,164 +188,21 @@ jobs:
- run: *yarn
- save-cache: *save-yarn-cache
# Basic checks against the checkout, cache...
- run: *run-sanity-checks
- persist_to_workspace:
root: .
paths: .
# Runs JavaScript lint and flow checks.
# Currently will fail a PR if lint/flow raises issues.
analyze:
<<: *js_defaults
steps:
- attach_workspace:
at: ~/react-native
- run: *run-lint-checks
- run: *run-flow-checks-ios
- run: *run-flow-checks-android
- store_test_results:
path: ~/react-native/reports/junit
- store_artifacts:
path: ~/react-native/yarn.lock
# Runs JavaScript tests on Node 8
test_javascript:
<<: *js_defaults
steps:
- attach_workspace:
at: ~/react-native
- run: *run-js-tests
- run: *run-js-e2e-tests
- store_test_results:
path: ~/react-native/reports/junit
# Run JavaScript tests on Node LTS
test_node_lts:
<<: *defaults
docker:
- image: node:lts
steps:
- checkout
- run: *setup-artifacts
- run: *yarn
- run: *run-js-tests
- run: yarn run format-check
- store_test_results:
path: ~/react-native/reports/junit
# Runs unit tests on iOS devices
test_ios:
<<: *macos_defaults
steps:
- attach_workspace:
at: ~/react-native
- run: *boot-simulator-iphone
- restore-cache: *restore-cache-homebrew
- run: *brew-install-watchman
- save-cache: *save-cache-homebrew
- run: *run-objc-ios-e2e-tests
- run: *run-objc-ios-tests
- store_test_results:
path: ~/react-native/reports/junit
# Runs end to end tests (Detox)
test_detox_end_to_end:
<<: *macos_defaults
steps:
- attach_workspace:
at: ~/react-native
- run: xcrun simctl boot "iPhone 5s" || true
- run:
name: Configure Environment Variables
command: |
echo 'export PATH=/usr/local/opt/node@8/bin:$PATH' >> $BASH_ENV
source $BASH_ENV
- run:
name: Install Node 8
command: |
brew install node@8
brew link node@8
brew tap wix/brew
brew install applesimutils
node -v
- run: *yarn
- run:
name: Build iOS app for simulator
command: yarn run build-ios-e2e
- run:
name: Run Detox Tests
command: yarn run test-ios-e2e
# Set up an Android environment for downstream jobs
test_android:
<<: *android_defaults
steps:
- attach_workspace:
at: ~/react-native
# Validate Android SDK installation and packages
- run: *validate-android-sdk
# Starting emulator in advance as it takes some time to boot.
- run: *create-avd
- run: *launch-avd
# Keep configuring Android dependencies while AVD boots up
# Install Buck
- restore-cache: *restore-cache-downloads-buck
- run: *install-buck
- save-cache: *save-cache-downloads-buck
# Validate Android test environment (including Buck)
- run: *validate-android-test-env
# Download dependencies using Buck
- run: *download-dependencies-buck
# Download dependencies using Gradle
- restore-cache: *restore-cache-downloads-gradle
- run: *download-dependencies-gradle
- save-cache: *save-cache-downloads-gradle
# Build and compile
- run: *build-android-app
- run: *compile-native-libs
# Build JavaScript Bundle for instrumentation tests
- run: *build-js-bundle
# Wait for AVD to finish booting before running tests
- run: *wait-for-avd
# Test Suite
- run: *run-android-unit-tests
- run: *run-android-instrumentation-tests
- run: *build-android-rntester-app
# Collect Results
- run: *collect-android-test-results
- store_test_results:
path: ~/react-native/reports/junit
# -------------------------
# JOBS: Analyze PR
# -------------------------
# Analyze pull request and raise any lint/flow issues.
# Issues will be posted to the PR itself via GitHub bots.
# This workflow should only fail if the bots fail to run.
# The public github tokens are publicly visible by design
analyze_pr:
<<: *defaults
docker:
- image: node:lts
# The public github tokens are publicly visible by design
environment:
- PUBLIC_PULLBOT_GITHUB_TOKEN_A: "a6edf8e8d40ce4e8b11a"
- PUBLIC_PULLBOT_GITHUB_TOKEN_B: "150e1341f4dd9c944d2a"
@@ -468,14 +213,14 @@ jobs:
- checkout
- run: *setup-artifacts
- restore-cache: *restore-cache-analysis
- restore-cache: *restore-yarn-cache
- run: *yarn
- run:
name: Analyze Shell Scripts
command: |
echo -e "\\x1B[36mInstalling additional dependencies\\x1B[0m"
apt update && apt install -y shellcheck
apt update && apt install -y shellcheck jq
yarn add @octokit/rest@15.18.0
echo -e "\\x1B[36mAnalyzing shell scripts\\x1B[0m"; \
GITHUB_TOKEN="$PUBLIC_ANALYSISBOT_GITHUB_TOKEN_A""$PUBLIC_ANALYSISBOT_GITHUB_TOKEN_B" \
@@ -507,9 +252,267 @@ jobs:
DANGER_GITHUB_API_TOKEN="$PUBLIC_PULLBOT_GITHUB_TOKEN_A""$PUBLIC_PULLBOT_GITHUB_TOKEN_B" \
yarn danger ci --use-github-checks
when: always
- save-cache: *save-cache-analysis
- save-cache: *save-yarn-cache
# Test Coverage
# -------------------------
# JOBS: Analyze Code
# -------------------------
analyze:
<<: *js_defaults
steps:
- attach_workspace:
at: ~/react-native
- run:
name: Lint code
command: scripts/circleci/exec_swallow_error.sh yarn lint --format junit -o ~/react-native/reports/junit/eslint/results.xml
- run:
name: Check for errors in code using Flow (iOS)
command: yarn flow-check-ios
when: always
- run:
name: Check for errors in code using Flow (Android)
command: yarn flow-check-android
when: always
- run:
name: Sanity checks
command: |
./scripts/circleci/check_license.sh
./scripts/circleci/validate_yarn_lockfile.sh
when: always
- store_test_results:
path: ~/react-native/reports/junit
- store_artifacts:
path: ~/react-native/yarn.lock
# -------------------------
# JOBS: Test JavaScript
# -------------------------
# Runs JavaScript tests on Node 8
test_javascript:
<<: *js_defaults
steps:
- attach_workspace:
at: ~/react-native
- run: *run-js-tests
- run:
name: JavaScript End-to-End Test Suite
command: node ./scripts/run-ci-e2e-tests.js --js --retries 3;
- store_test_results:
path: ~/react-native/reports/junit
# Run JavaScript tests on Node LTS
test_node_lts:
<<: *defaults
docker:
- image: node:lts
steps:
- checkout
- run: *setup-artifacts
- run: *yarn
- run: *run-js-tests
- run: yarn run format-check
- store_test_results:
path: ~/react-native/reports/junit
# -------------------------
# JOBS: Test iOS
# -------------------------
# Runs unit tests on iOS devices
test_ios:
<<: *macos_defaults
steps:
- attach_workspace:
at: ~/react-native
- run:
name: Boot iPhone Simulator
command: source scripts/.tests.env && xcrun simctl boot "$IOS_DEVICE" || true
- restore-cache: *restore-brew-cache
- run:
name: Install Watchman
command: |
HOMEBREW_NO_AUTO_UPDATE=1 brew install watchman >/dev/null
touch .watchmanconfig
- save-cache: *save-brew-cache
- run:
name: iOS Test Suite
command: ./scripts/objc-test-ios.sh test
- run:
name: iOS End-to-End Test Suite
command: node ./scripts/run-ci-e2e-tests.js --ios --retries 3;
- store_test_results:
path: ~/react-native/reports/junit
# Runs end to end tests (Detox)
test_detox_end_to_end:
<<: *macos_defaults
steps:
- attach_workspace:
at: ~/react-native
- run:
name: Start iPhone 5s simulator
background: true
command: xcrun simctl boot "iPhone 5s" || true
- run:
name: Configure Environment Variables
command: |
echo 'export PATH=/usr/local/opt/node@8/bin:$PATH' >> $BASH_ENV
source $BASH_ENV
# Brew
- restore-cache: *restore-brew-cache
- run:
name: Configure Detox Environment
command: |
HOMEBREW_NO_AUTO_UPDATE=1 brew install node@8 >/dev/null
HOMEBREW_NO_AUTO_UPDATE=1 brew tap wix/brew >/dev/null
HOMEBREW_NO_AUTO_UPDATE=1 brew install applesimutils >/dev/null
touch .watchmanconfig
node -v
- save-cache: *save-brew-cache
# Yarn install
- restore-cache: *restore-yarn-cache
- run: *yarn
- save-cache: *save-yarn-cache
# Xcode build
- run:
name: Build iOS app for simulator
command: yarn run build-ios-e2e
# Test
- run:
name: Run Detox Tests
command: yarn run test-ios-e2e
# -------------------------
# JOBS: Test Android
# -------------------------
# Run Android tests
test_android:
<<: *android_defaults
steps:
- attach_workspace:
at: ~/react-native
# Validate Android SDK installation and packages
- run:
name: Validate Android SDK Install
command: ./scripts/validate-android-sdk.sh
# Starting emulator in advance as it takes some time to boot.
- run:
name: Create Android Virtual Device
command: source scripts/android-setup.sh && createAVD
- run:
name: Launch Android Virtual Device in Background
command: source scripts/android-setup.sh && launchAVD
background: true
# Keep configuring Android dependencies while AVD boots up
# Install Buck
- restore-cache: *restore-buck-downloads-cache
- 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
mkdir -p ~/react-native/tooling/junit
cp -R ~/okbuck/tooling/junit/* ~/react-native/tooling/junit/.
- save-cache: *save-buck-downloads-cache
# Validate Android test environment (including Buck)
- run:
name: Validate Android Test Environment
command: ./scripts/validate-android-test-env.sh
# Download dependencies using Buck
- run: *download-dependencies-buck
# Download dependencies using Gradle
- restore-cache: *restore-gradle-downloads-cache
- run: *download-dependencies-gradle
- save-cache: *save-gradle-downloads-cache
# Build and compile
- run:
name: Build Android App
command: |
buck build ReactAndroid/src/main/java/com/facebook/react
buck build ReactAndroid/src/main/java/com/facebook/react/shell
- run:
name: Compile Native Libs for Unit and Integration Tests
command: ./gradlew :ReactAndroid:packageReactNdkLibsForBuck -Pjobs=$BUILD_THREADS
no_output_timeout: 6m
# Build JavaScript Bundle for instrumentation tests
- run:
name: Build JavaScript Bundle
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
- run:
name: Wait for Android Virtual Device
command: source scripts/android-setup.sh && waitForAVD
# Test Suite
- run:
name: Run Unit Tests
command: buck test ReactAndroid/src/test/... --config build.threads=$BUILD_THREADS --xml ~/react-native/reports/buck/all-results-raw.xml
- run:
name: Run Instrumentation Tests
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 install ReactAndroid/src/androidTest/buck-runner:instrumentation-tests --config build.threads=$BUILD_THREADS
- run:
name: Build Android RNTester App
command: ./gradlew RNTester:android:app:assembleRelease
# Collect Results
- run:
name: Collect Test Results
command: |
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/outputs/ \;
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
- store_test_results:
path: ~/react-native/reports/junit
# -------------------------
# JOBS: Coverage
# -------------------------
# Collect JavaScript test coverage
js_coverage:
<<: *js_defaults
environment:
@@ -521,10 +524,18 @@ jobs:
- checkout
- restore-cache: *restore-yarn-cache
- run: *yarn
- run: *js-coverage
- run:
name: Test coverage
command: |
yarn test --coverage --maxWorkers=2
cat ./coverage/lcov.info | ./node_modules/.bin/coveralls
when: always
- store_artifacts:
path: ~/react-native/coverage/
# -------------------------
# JOBS: Releases
# -------------------------
# Publishes new version onto npm
# Only works on stable branches when a properly tagged commit is pushed
publish_npm_package:
@@ -536,11 +547,11 @@ jobs:
- run: *yarn
# Fetch dependencies using Buck
- restore-cache: *restore-cache-downloads-buck
- restore-cache: *restore-buck-downloads-cache
- run: *download-dependencies-buck
# Fetch dependencies using Gradle
- restore-cache: *restore-cache-downloads-gradle
- restore-cache: *restore-gradle-downloads-cache
- run: *download-dependencies-gradle
- restore-cache: *restore-yarn-cache
@@ -557,75 +568,42 @@ jobs:
git config --global user.name "npm Deployment Script"
echo "machine github.com login react-native-bot password $GITHUB_TOKEN" > ~/.netrc
# Build and publish release. Requires an Android environment.
- run:
name: Publish React Native Package
command: node ./scripts/publish-npm.js
# Workflows enables us to run multiple jobs in parallel
# -------------------------
# WORK FLOWS
# -------------------------
workflows:
version: 2
tests:
jobs:
# Checkout repo and run Yarn
- checkout_code:
filters: *filter-ignore-gh-pages
# Run lint, flow, and other checks
- analyze:
filters: *filter-ignore-gh-pages
requires:
- checkout_code
# Test JavaScript
- test_javascript:
filters: *filter-ignore-gh-pages
requires:
- checkout_code
# Test Android
- test_android:
filters: *filter-ignore-gh-pages
requires:
- checkout_code
# Test iOS
- test_ios:
filters: *filter-ignore-gh-pages
requires:
- checkout_code
- test_detox_end_to_end:
filters: *filter-ignore-gh-pages
requires:
- checkout_code
# Tooling Compatibility Checks
- test_node_lts:
filters: *filter-ignore-gh-pages
- checkout_code:
filters: *filter-ignore-gh-pages
- analyze: *run-after-checkout
- test_javascript: *run-after-checkout
- test_android: *run-after-checkout
- test_ios: *run-after-checkout
- test_detox_end_to_end: *run-after-checkout
releases:
jobs:
# Only runs on vX.X.X tags if all tests are green
- publish_npm_package:
filters:
# ignore any commit on any branch by default
branches:
ignore: /.*/
# only act on version tags
tags:
only: /v[0-9]+(\.[0-9]+)*(\-rc(\.[0-9]+)?)?/
filters: *filter-only-version-tags
analysis:
jobs:
# Run code checks on PRs from forks
- analyze_pr:
filters:
branches:
only: /^pull\/.*$/
filters: *filter-only-forked-pull-requests
# Gather coverage on master
- js_coverage:
filters:
branches:
only: master
filters: *filter-only-master