migrate ci to official docker (#21477)

Summary:
Simplify current build and offer it to community as official docker.
I have also created an [rfc](https://github.com/react-native-community/discussions-and-proposals/pull/36).
pass all current ci.
none
 [GENERAL] [INTERNAL] [CI] - migrate ci to official docker
Pull Request resolved: https://github.com/facebook/react-native/pull/21477

Differential Revision: D13801696

Pulled By: cpojer

fbshipit-source-id: fa235cf21ab5af2c87eb3c1a14788fab01c71ccf
This commit is contained in:
gengjiawen
2019-01-24 06:22:28 -08:00
committed by Facebook Github Bot
parent 988366a417
commit 9351dd6c69
5 changed files with 4 additions and 198 deletions

View File

@@ -26,14 +26,6 @@ aliases:
- node_modules
key: v1-analysis-dependencies-{{ arch }}-{{ checksum "package.json" }}{{ checksum "bots/package.json" }}
- &restore-cache-android-packages
keys:
- v1-android-sdkmanager-packages-api-28-alpha-{{ checksum "scripts/.tests.env" }}
- &save-cache-android-packages
paths:
- /opt/android/sdk
key: v1-android-sdkmanager-packages-api-28-alpha-{{ checksum "scripts/.tests.env" }}
- &restore-cache-gradle
keys:
- v1-gradle-{{ .Branch }}-{{ checksum "build.gradle" }}-{{ checksum "ReactAndroid/build.gradle" }}
@@ -47,14 +39,6 @@ aliases:
- ~/.gradle
key: v1-gradle-{{ .Branch }}-{{ checksum "build.gradle" }}-{{ checksum "ReactAndroid/build.gradle" }}
- &restore-cache-ndk
keys:
- v3-android-ndk-r17c-{{ checksum "scripts/android-setup.sh" }}
- &save-cache-ndk
paths:
- /opt/ndk
key: v3-android-ndk-r17c-{{ checksum "scripts/android-setup.sh" }}
- &restore-cache-downloads-buck
keys:
- v3-buck-v2019.01.10.01-{{ checksum "scripts/circleci/buck_fetch.sh" }}}
@@ -115,11 +99,6 @@ aliases:
- /.*-stable/
- gh-pages
# Dependency Management
- &install-ndk
name: Install Android NDK
command: source scripts/android-setup.sh && getAndroidNDK
- &yarn
name: Run Yarn
command: |
@@ -129,20 +108,9 @@ aliases:
yarn install --non-interactive --cache-folder ~/.cache/yarn
fi
- &install-yarn
name: Install Yarn
command: |
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn
- &install-buck
name: Install BUCK
command: |
if [[ ! -e ~/buck ]]; then
git clone https://github.com/facebook/buck.git ~/buck --branch v2019.01.10.01 --depth=1
fi
cd ~/buck && ant
buck --version
# Install related tooling
if [[ ! -e ~/okbuck ]]; then
@@ -150,31 +118,6 @@ aliases:
fi
mkdir -p ~/react-native/tooling/junit
cp -R ~/okbuck/tooling/junit/* ~/react-native/tooling/junit/.
- &create-ndk-directory
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
# 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
name: Configure Environment Variables
command: |
echo 'export PATH=${ANDROID_NDK}:~/buck/bin:$PATH' >> $BASH_ENV
source $BASH_ENV
- &install-android-packages
name: Install Android SDK Packages
command: source scripts/android-setup.sh && getAndroidPackages
- &install-android-build-dependencies
name: Install Android Build Dependencies
command: ./scripts/circleci/apt-get-android-deps.sh
- &validate-android-sdk
name: Validate Android SDK Install
command: ./scripts/validate-android-sdk.sh
@@ -265,7 +208,7 @@ aliases:
- &build-android-rntester-app
name: Build Android RNTester App
command: ./gradlew RNTester:android:app:assembleRelease -Pjobs=$BUILD_THREADS
command: ./gradlew RNTester:android:app:assembleRelease
- &collect-android-test-results
name: Collect Test Results
@@ -340,14 +283,13 @@ js_defaults: &js_defaults
android_defaults: &android_defaults
<<: *defaults
docker:
- image: circleci/android:api-28-node8-alpha
- image: reactnativecommunity/react-native-android
resource_class: "large"
environment:
- TERM: "dumb"
- ADB_INSTALL_TIMEOUT: 10
- _JAVA_OPTIONS: "-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap"
- GRADLE_OPTS: '-Dorg.gradle.daemon=false -Dorg.gradle.jvmargs="-XX:+HeapDumpOnOutOfMemoryError"'
- ANDROID_NDK: '/opt/ndk/android-ndk-r17c'
- BUILD_THREADS: 2
macos_defaults: &macos_defaults
@@ -472,15 +414,6 @@ jobs:
- attach_workspace:
at: ~/react-native
# Configure Android SDK and related dependencies
- run: *configure-android-path
# Android build deps install from the network faster than cache
- run: *install-android-build-dependencies
- restore-cache: *restore-cache-android-packages
- run: *install-android-packages
- save-cache: *save-cache-android-packages
# Validate Android SDK installation and packages
- run: *validate-android-sdk
@@ -490,12 +423,6 @@ jobs:
# Keep configuring Android dependencies while AVD boots up
# Install Android NDK
- run: *create-ndk-directory
- restore-cache: *restore-cache-ndk
- run: *install-ndk
- save-cache: *save-cache-ndk
# Install Buck
- restore-cache: *restore-cache-downloads-buck
- run: *install-buck
@@ -623,21 +550,8 @@ jobs:
- restore-cache: *restore-yarn-cache
- run: *yarn
# Configure Android SDK and related dependencies
- run: *configure-android-path
- run: *install-android-build-dependencies
- restore-cache: *restore-cache-android-packages
- run: *install-android-packages
# Install Android NDK
- run: *create-ndk-directory
- restore-cache: *restore-cache-ndk
- run: *install-ndk
# Fetch dependencies using Buck
- restore-cache: *restore-cache-downloads-buck
- run: *install-buck
- run: *download-dependencies-buck
# Fetch dependencies using Gradle

View File

@@ -9,7 +9,7 @@
# image. Ideally, this image would be rebuilt with any new commit to the master
# branch. Doing so will catch issues such as BUCK failing to fetch dependencies
# or run tests, as well as unit test failures.
FROM reactnativeci/android-base:latest
FROM react-native-community/react-native
LABEL Description="This image prepares and runs React Native's Android tests."
LABEL maintainer="Héctor Ramos <hector@fb.com>"

View File

@@ -1,83 +0,0 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
# React Native Base Android Development Environment
#
# This image provides a base Android development environment for React Native,
# including, but not limited to, the Android SDK, Android NDK, Node, and BUCK.
# These are required in order to run React Native's Android unit and integration
# tests.
#
# This image is not currently built automatically as part of React Native's CI
# infrastructure. It should not be necessary to rebuild this image while the
# Android dependencies (Android SDK version, build tools version, etc) remain
# equal. The operations performed to build this image are those that tend to
# remain stable across commits in any given React Native release.
FROM library/ubuntu:16.04
LABEL Description="This image provides a base Android development environment for React Native, and may be used to run tests."
LABEL maintainer="Héctor Ramos <hector@fb.com>"
# set default build arguments
ARG SDK_VERSION=sdk-tools-linux-3859397.zip
ARG ANDROID_BUILD_VERSION=28
ARG ANDROID_TOOLS_VERSION=28.0.3
ARG BUCK_VERSION=v2019.01.10.01
ARG NDK_VERSION=17c
ARG NODE_VERSION=8.10.0
ARG WATCHMAN_VERSION=4.9.0
# set default environment variables
ENV ADB_INSTALL_TIMEOUT=10
ENV PATH=${PATH}:/opt/buck/bin/
ENV ANDROID_HOME=/opt/android
ENV ANDROID_SDK_HOME=${ANDROID_HOME}
ENV PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools
ENV ANDROID_NDK=/opt/ndk/android-ndk-r$NDK_VERSION
ENV PATH=${PATH}:${ANDROID_NDK}
# install system dependencies
RUN apt-get update && apt-get install ant autoconf automake curl g++ gcc git libqt5widgets5 lib32z1 lib32stdc++6 make maven npm openjdk-8* python-dev python3-dev qml-module-qtquick-controls qtdeclarative5-dev unzip -y
# configure npm
RUN npm config set spin=false && \
npm config set progress=false
# install node
RUN npm install n -g
RUN n $NODE_VERSION
# download buck
RUN git clone https://github.com/facebook/buck.git /opt/buck --branch $BUCK_VERSION --depth=1
WORKDIR /opt/buck
# build buck
RUN ant
# Full reference at https://dl.google.com/android/repository/repository2-1.xml
# download and unpack android
RUN mkdir /opt/android && \
cd /opt/android && \
curl --silent https://dl.google.com/android/repository/${SDK_VERSION} > android.zip && \
unzip android.zip && \
rm android.zip
# download and unpack NDK
RUN mkdir /opt/ndk && \
cd /opt/ndk && \
curl --silent https://dl.google.com/android/repository/android-ndk-r$NDK_VERSION-linux-x86_64.zip > ndk.zip && \
unzip ndk.zip && \
rm ndk.zip
# Add android SDK tools
RUN sdkmanager "system-images;android-19;google_apis;armeabi-v7a" \
"platforms;android-$ANDROID_BUILD_VERSION" \
"build-tools;$ANDROID_TOOLS_VERSION" \
"add-ons;addon-google_apis-google-23" \
"extras;android;m2repository"
# clean up unnecessary directories
RUN rm -rf /opt/android/system-images/android-19/default/x86

View File

@@ -1,24 +0,0 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
FROM library/node:6.9.2
ENV YARN_VERSION=0.27.5
# install dependencies
RUN apt-get update && apt-get install ocaml libelf-dev -y
RUN npm install yarn@$YARN_VERSION -g
# add code
RUN mkdir /app
ADD . /app
WORKDIR /app
RUN yarn install --ignore-engines
WORKDIR website
RUN yarn install --ignore-engines --ignore-platform
WORKDIR /app

View File

@@ -140,8 +140,7 @@
"flow-check-android": "flow check --flowconfig-name .flowconfig.android",
"lint": "eslint .",
"prettier": "prettier \"./**/*.js\" --write",
"docker-setup-android": "docker pull reactnativeci/android-base:latest",
"docker-build-android-base": "docker build -t reactnativeci/android-base -f ContainerShip/Dockerfile.android-base .",
"docker-setup-android": "docker pull reactnativecommunity/react-native-android",
"docker-build-android": "docker build -t reactnativeci/android -f ContainerShip/Dockerfile.android .",
"test-android-run-instrumentation": "docker run --cap-add=SYS_ADMIN -it reactnativeci/android bash ContainerShip/scripts/run-android-docker-instrumentation-tests.sh",
"test-android-run-unit": "docker run --cap-add=SYS_ADMIN -it reactnativeci/android bash ContainerShip/scripts/run-android-docker-unit-tests.sh",