mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix circle config:
One more deploy fix Circle fixes Fix deployment Improve CI config Update alias Fix Buck and tests on master Hardcode Buck version Fix Buck cache keys
This commit is contained in:
+140
-121
@@ -52,6 +52,10 @@ aliases:
|
||||
keys:
|
||||
- v1-android-ndk-{{ arch }}-r10e-32-64
|
||||
|
||||
- &install-ndk
|
||||
|
|
||||
source scripts/circle-ci-android-setup.sh && getAndroidNDK
|
||||
|
||||
- &save-cache-ndk
|
||||
paths:
|
||||
- /opt/ndk
|
||||
@@ -69,11 +73,11 @@ aliases:
|
||||
|
||||
- &restore-cache-buck
|
||||
keys:
|
||||
- v1-buck-{{ arch }}-v2017.09.04.02
|
||||
- v1-buck-{{ arch }}-v2017.11.16
|
||||
- &save-cache-buck
|
||||
paths:
|
||||
- ~/buck
|
||||
key: v1-buck-{{ arch }}-v2017.09.04.02
|
||||
key: v1-buck-{{ arch }}-v2017.11.16
|
||||
|
||||
- &restore-cache-watchman
|
||||
keys:
|
||||
@@ -87,6 +91,22 @@ aliases:
|
||||
|
|
||||
npm install --no-package-lock --no-spin --no-progress
|
||||
|
||||
# Install Buck version of 12b972d50a517290b2a4c1776744d4cbb7c3dda2 which
|
||||
# happens to be "latest" as of 16.11.2017. Waiting for a new release.
|
||||
- &install-buck
|
||||
|
|
||||
if [[ ! -e ~/buck ]]; then
|
||||
git clone https://github.com/facebook/buck.git ~/buck --depth=1
|
||||
(cd ~/buck && git reset --hard 12b972d50a517290b2a4c1776744d4cbb7c3dda2)
|
||||
fi
|
||||
cd ~/buck && ant
|
||||
buck --version
|
||||
|
||||
- &install-node
|
||||
|
|
||||
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
|
||||
sudo apt-get install -y nodejs
|
||||
|
||||
- &run-node-tests
|
||||
|
|
||||
npm test -- --maxWorkers=2
|
||||
@@ -99,6 +119,11 @@ aliases:
|
||||
- /.*-stable/
|
||||
- master
|
||||
|
||||
- &filter-only-stable
|
||||
branches:
|
||||
only:
|
||||
- /.*-stable/
|
||||
|
||||
- &filter-ignore-gh-pages
|
||||
branches:
|
||||
ignore: gh-pages
|
||||
@@ -110,9 +135,52 @@ aliases:
|
||||
- /.*-stable/
|
||||
- gh-pages
|
||||
|
||||
- &create-ndk-directory
|
||||
|
|
||||
if [[ ! -e /opt/ndk ]]; then
|
||||
sudo mkdir /opt/ndk
|
||||
fi
|
||||
sudo chown ${USER:=$(/usr/bin/id -run)}:$USER /opt/ndk
|
||||
|
||||
# CircleCI does not support interpolating env variables in the environment
|
||||
# https://circleci.com/docs/2.0/env-vars/#interpolating-environment-variables-to-set-other-environment-variables
|
||||
- &configure-android-path
|
||||
|
|
||||
echo 'export PATH=${ANDROID_NDK}:~/react-native/gradle-2.9/bin:~/buck/bin:$PATH' >> $BASH_ENV
|
||||
source $BASH_ENV
|
||||
|
||||
- &install-android-packages
|
||||
|
|
||||
source scripts/circle-ci-android-setup.sh && getAndroidSDK
|
||||
|
||||
- &install-build-dependencies
|
||||
|
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install ant autoconf automake g++ gcc libqt5widgets5 lib32z1 lib32stdc++6 make maven python-dev python3-dev qml-module-qtquick-controls qtdeclarative5-dev -y
|
||||
|
||||
- &install-android-app-dependencies
|
||||
|
|
||||
buck fetch ReactAndroid/src/test/java/com/facebook/react/modules
|
||||
buck fetch ReactAndroid/src/main/java/com/facebook/react
|
||||
buck fetch ReactAndroid/src/main/java/com/facebook/react/shell
|
||||
buck fetch ReactAndroid/src/test/...
|
||||
buck fetch ReactAndroid/src/androidTest/...
|
||||
./gradlew :ReactAndroid:downloadBoost :ReactAndroid:downloadDoubleConversion :ReactAndroid:downloadFolly :ReactAndroid:downloadGlog :ReactAndroid:downloadJSCHeaders
|
||||
|
||||
defaults: &defaults
|
||||
working_directory: ~/react-native
|
||||
|
||||
android_defaults: &android_defaults
|
||||
<<: *defaults
|
||||
docker:
|
||||
- image: circleci/android:api-26-alpha
|
||||
environment:
|
||||
- TERM: "dumb"
|
||||
- ADB_INSTALL_TIMEOUT: 10
|
||||
- GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx512m -XX:+HeapDumpOnOutOfMemoryError"'
|
||||
- ANDROID_NDK: '/opt/ndk/android-ndk-r10e'
|
||||
- BUILD_THREADS: 2
|
||||
|
||||
version: 2
|
||||
jobs:
|
||||
# Runs JavaScript tests on Node 8
|
||||
@@ -208,6 +276,7 @@ jobs:
|
||||
- save-cache: *save-node-cache
|
||||
- run: ./scripts/process-podspecs.sh
|
||||
|
||||
# Tests website
|
||||
test-website:
|
||||
<<: *defaults
|
||||
docker:
|
||||
@@ -228,6 +297,7 @@ jobs:
|
||||
name: Test Build Static Website
|
||||
command: cd website && node ./server/generate.js
|
||||
|
||||
# Deploys website
|
||||
deploy-website:
|
||||
<<: *defaults
|
||||
docker:
|
||||
@@ -252,6 +322,46 @@ jobs:
|
||||
echo "Skipping deploy."
|
||||
fi
|
||||
|
||||
# Publishes new version onto npm
|
||||
publish-npm:
|
||||
<<: *android_defaults
|
||||
steps:
|
||||
- checkout
|
||||
|
||||
# Configure Android dependencies
|
||||
- run: *configure-android-path
|
||||
- run: *install-build-dependencies
|
||||
- restore-cache: *restore-cache-android-packages
|
||||
- run: *install-android-packages
|
||||
- save-cache: *save-cache-android-packages
|
||||
- run: *create-ndk-directory
|
||||
- restore-cache: *restore-cache-ndk
|
||||
- run: *install-ndk
|
||||
- save-cache: *save-cache-ndk
|
||||
- restore-cache: *restore-cache-buck
|
||||
- run: *install-buck
|
||||
- save-cache: *save-cache-buck
|
||||
- run: *install-node
|
||||
- restore-cache: *restore-node-cache
|
||||
- run: *install-node-dependencies
|
||||
- save-cache: *save-node-cache
|
||||
- restore-cache: *restore-cache-buck-downloads
|
||||
- run: *install-android-app-dependencies
|
||||
- save-cache: *save-cache-buck-downloads
|
||||
|
||||
- run:
|
||||
name: Publish React Native Package
|
||||
command: |
|
||||
if [ -z "$CIRCLE_PULL_REQUEST" ]; then
|
||||
echo "//registry.npmjs.org/:_authToken=${CIRCLE_NPM_TOKEN}" > ~/.npmrc
|
||||
git config --global user.email "reactjs-bot@users.noreply.github.com"
|
||||
git config --global user.name "Website Deployment Script"
|
||||
echo "machine github.com login reactjs-bot password $GITHUB_TOKEN" > ~/.netrc
|
||||
node ./scripts/publish-npm.js
|
||||
else
|
||||
echo "Skipping deploy."
|
||||
fi
|
||||
|
||||
# Build JavaScript bundle for Android tests
|
||||
build-js-bundle:
|
||||
<<: *defaults
|
||||
@@ -274,116 +384,55 @@ jobs:
|
||||
|
||||
# Runs unit tests tests on Android
|
||||
test-android:
|
||||
<<: *defaults
|
||||
docker:
|
||||
- image: circleci/android:api-26-alpha
|
||||
environment:
|
||||
- TERM: "dumb"
|
||||
- ADB_INSTALL_TIMEOUT: 10
|
||||
- GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx512m -XX:+HeapDumpOnOutOfMemoryError"'
|
||||
- ANDROID_NDK: '/opt/ndk/android-ndk-r10e'
|
||||
- BUILD_THREADS: 2
|
||||
<<: *android_defaults
|
||||
steps:
|
||||
- checkout
|
||||
# CircleCI does not support interpolating env variables in the environment: step above.
|
||||
# https://circleci.com/docs/2.0/env-vars/#interpolating-environment-variables-to-set-other-environment-variables
|
||||
- run:
|
||||
name: Configure PATH
|
||||
command: |
|
||||
echo 'export PATH=${ANDROID_NDK}:~/react-native/gradle-2.9/bin:~/buck/bin:$PATH' >> $BASH_ENV
|
||||
source $BASH_ENV
|
||||
# Configure dependencies
|
||||
- run:
|
||||
name: Install Build Dependencies
|
||||
command: |
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install ant autoconf automake g++ gcc libqt5widgets5 lib32z1 lib32stdc++6 make maven python-dev python3-dev qml-module-qtquick-controls qtdeclarative5-dev -y
|
||||
|
||||
# Configure Android dependencies
|
||||
- run: *configure-android-path
|
||||
- run: *install-build-dependencies
|
||||
- restore-cache: *restore-cache-android-packages
|
||||
- run:
|
||||
name: Install Android Packages
|
||||
command: source scripts/circle-ci-android-setup.sh && getAndroidSDK
|
||||
- run: *install-android-packages
|
||||
- save-cache: *save-cache-android-packages
|
||||
|
||||
# Starting emulator in advance as it takes some time to boot.
|
||||
- run:
|
||||
name: Create Android Virtual Device
|
||||
command: source scripts/circle-ci-android-setup.sh && createAVD
|
||||
# Starting emulator in advance as it takes some time to boot.
|
||||
- run:
|
||||
name: Launch Android Virtual Device in Background
|
||||
command: source scripts/circle-ci-android-setup.sh && launchAVD
|
||||
background: true
|
||||
# Continue configuring dependencies while AVD boots.
|
||||
- run:
|
||||
name: Create Android NDK Directory
|
||||
command: |
|
||||
if [[ ! -e /opt/ndk ]]; then
|
||||
sudo mkdir /opt/ndk
|
||||
fi
|
||||
sudo chown ${USER:=$(/usr/bin/id -run)}:$USER /opt/ndk
|
||||
|
||||
# Keep configuring Android dependencies while AVD boots up
|
||||
- run: *create-ndk-directory
|
||||
- restore-cache: *restore-cache-ndk
|
||||
- run:
|
||||
name: Install Android NDK
|
||||
command: source scripts/circle-ci-android-setup.sh && getAndroidNDK
|
||||
- run: *install-ndk
|
||||
- save-cache: *save-cache-ndk
|
||||
- restore-cache: *restore-cache-buck
|
||||
- run:
|
||||
name: Install Buck
|
||||
command: |
|
||||
if [[ ! -e ~/buck ]]; then
|
||||
git clone https://github.com/facebook/buck.git ~/buck --branch v2017.09.04.02 --depth=1
|
||||
fi
|
||||
cd ~/buck && ant
|
||||
buck --version
|
||||
- run: *install-buck
|
||||
- save-cache: *save-cache-buck
|
||||
- run:
|
||||
name: Install Node
|
||||
command: |
|
||||
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
|
||||
sudo apt-get install -y nodejs
|
||||
- run: *install-node
|
||||
- restore-cache: *restore-node-cache
|
||||
- run: *install-node-dependencies
|
||||
- save-cache: *save-node-cache
|
||||
# TODO: Install and use watchman to speed up builds
|
||||
# - restore-cache: *restore-cache-watchman
|
||||
# - run:
|
||||
# name: Install Watchman Dependencies
|
||||
# command: |
|
||||
# sudo apt-get update -y
|
||||
# sudo apt-get install libtool pkg-config -y
|
||||
# - run:
|
||||
# name: Install Watchman
|
||||
# command: |
|
||||
# if [[ ! -e ~/watchman ]]; then
|
||||
# mkdir ~/watchman
|
||||
# git clone https://github.com/facebook/watchman.git ~/watchman --branch v4.9.0 --depth=1
|
||||
# cd ~/watchman
|
||||
# ./autogen.sh
|
||||
# ./configure
|
||||
# make
|
||||
# fi
|
||||
# cd ~/watchman
|
||||
# sudo make install
|
||||
# - save-cache: *save-cache-watchman
|
||||
- restore-cache: *restore-cache-buck-downloads
|
||||
- run:
|
||||
name: Download Android App Dependencies
|
||||
command: |
|
||||
buck fetch ReactAndroid/src/test/java/com/facebook/react/modules
|
||||
buck fetch ReactAndroid/src/main/java/com/facebook/react
|
||||
buck fetch ReactAndroid/src/main/java/com/facebook/react/shell
|
||||
buck fetch ReactAndroid/src/test/...
|
||||
buck fetch ReactAndroid/src/androidTest/...
|
||||
./gradlew :ReactAndroid:downloadBoost :ReactAndroid:downloadDoubleConversion :ReactAndroid:downloadFolly :ReactAndroid:downloadGlog :ReactAndroid:downloadJSCHeaders
|
||||
- run: *install-android-app-dependencies
|
||||
- save-cache: *save-cache-buck-downloads
|
||||
|
||||
- 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
|
||||
# Wait for AVD to finish booting before running tests
|
||||
|
||||
# Wait for AVD to finish booting before running tests
|
||||
- run:
|
||||
name: Wait for Android Virtual Device
|
||||
command: source scripts/circle-ci-android-setup.sh && waitForAVD
|
||||
# The JavaScript Bundle is built as part of the build-js-bundle workflow, and is required for instrumentation tests.
|
||||
|
||||
# The JavaScript Bundle is built as part of the build-js-bundle workflow,
|
||||
# and is required for instrumentation tests.
|
||||
- attach_workspace:
|
||||
at: ReactAndroid/src/androidTest/assets/
|
||||
- run:
|
||||
@@ -394,7 +443,8 @@ jobs:
|
||||
else
|
||||
echo "JavaScript bundle found.";
|
||||
fi
|
||||
# Tests
|
||||
|
||||
# Tests
|
||||
- run:
|
||||
name: Compile Native Libs for Unit and Integration Tests
|
||||
command: ./gradlew :ReactAndroid:packageReactNdkLibsForBuck -Pjobs=$BUILD_THREADS -Pcom.android.build.threadPoolSize=1
|
||||
@@ -402,28 +452,19 @@ jobs:
|
||||
- run:
|
||||
name: Unit Tests
|
||||
command: buck test ReactAndroid/src/test/... --config build.threads=$BUILD_THREADS
|
||||
# Integration Tests
|
||||
|
||||
# Integration Tests
|
||||
- run:
|
||||
name: Build and Install Test APK
|
||||
command: source scripts/circle-ci-android-setup.sh && NO_BUCKD=1 retry3 buck install ReactAndroid/src/androidTest/buck-runner:instrumentation-tests --config build.threads=$BUILD_THREADS
|
||||
# TODO: Uncomment, test was already failing on Circle 1.0
|
||||
# - run:
|
||||
# name: Run Installed APK with Tests
|
||||
# command: node ./scripts/run-android-ci-instrumentation-tests.js --retries 3 --path ./ReactAndroid/src/androidTest/java/com/facebook/react/tests --package com.facebook.react.tests
|
||||
# TODO: Should be disabled, pending on https://our.intern.facebook.com/intern/tasks?t=16912142
|
||||
# - run:
|
||||
# name: Run Android End to End Tests
|
||||
# command: source scripts/circle-ci-android-setup.sh && retry3 node ./scripts/run-ci-e2e-tests.js --android --js --retries 2
|
||||
|
||||
# post (always runs)
|
||||
|
||||
# post (always runs)
|
||||
- run:
|
||||
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/ \;
|
||||
# TODO: Circle does not understand Buck's report, maybe need to transform xml slightly
|
||||
# find . -type f -regex ".*/buck-out/gen/ReactAndroid/src/test/.*/.*xml" -exec cp {} ~/junit/ \;
|
||||
when: always
|
||||
- store_test_results:
|
||||
path: ~/junit
|
||||
@@ -449,7 +490,6 @@ jobs:
|
||||
echo "Skipping dependency installation."
|
||||
fi
|
||||
- save-cache: *save-cache-analysis
|
||||
# Run Danger
|
||||
- run:
|
||||
name: Analyze Pull Request
|
||||
command: |
|
||||
@@ -459,7 +499,6 @@ jobs:
|
||||
echo "Skipping pull request analysis."
|
||||
fi
|
||||
when: always
|
||||
# Run eslint
|
||||
- run:
|
||||
name: Analyze Code
|
||||
command: |
|
||||
@@ -469,26 +508,6 @@ jobs:
|
||||
echo "Skipping code analysis."
|
||||
fi
|
||||
|
||||
publish-npm:
|
||||
<<: *defaults
|
||||
docker:
|
||||
- image: circleci/node:8
|
||||
steps:
|
||||
- checkout
|
||||
- run: *install-node-dependencies
|
||||
- run:
|
||||
name: Publish React Native Package
|
||||
command: |
|
||||
if [ -z "$CIRCLE_PULL_REQUEST" ]; then
|
||||
echo "//registry.npmjs.org/:_authToken=${CIRCLE_NPM_TOKEN}" > ~/.npmrc
|
||||
git config --global user.email "reactjs-bot@users.noreply.github.com"
|
||||
git config --global user.name "Website Deployment Script"
|
||||
echo "machine github.com login reactjs-bot password $GITHUB_TOKEN" > ~/.netrc
|
||||
node ./scripts/publish-npm.js
|
||||
else
|
||||
echo "Skipping publication."
|
||||
fi
|
||||
|
||||
# Workflows enables us to run multiple jobs in parallel
|
||||
workflows:
|
||||
version: 2
|
||||
@@ -546,4 +565,4 @@ workflows:
|
||||
- publish-npm:
|
||||
requires:
|
||||
- hold
|
||||
filters: *filter-only-master-stable
|
||||
filters: *filter-only-stable
|
||||
|
||||
Reference in New Issue
Block a user