Skip to content

Commit

Permalink
Cache apt dependencies in test_android
Browse files Browse the repository at this point in the history
Summary: Closes facebook#18576

Differential Revision: D7415216

Pulled By: hramos

fbshipit-source-id: 9b7199fe5fb91a26ba0881e426a85395b2923f26
  • Loading branch information
hramos authored and macdoum1 committed Jun 28, 2018
1 parent e1a69c3 commit 49e5975
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 6 deletions.
46 changes: 40 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,31 @@ aliases:
- /opt/android/sdk
key: v1-android-sdkmanager-packages-{{ arch }}-{{ .Branch }}-api-26-alpha-{{ checksum "scripts/circle-ci-android-setup.sh" }}

- &restore-cache-gradle
keys:
- v1-gradle-{{ arch }}-{{ .Branch }}-{{ checksum "build.gradle" }}-{{ checksum "ReactAndroid/build.gradle" }}
# Fallback in case checksum fails
- v1-gradle-{{ arch }}-{{ .Branch }}-{{ checksum "build.gradle" }}-
- v1-gradle-{{ arch }}-{{ .Branch }}-
# Fallback in case this is a first-time run on a fork
- v1-gradle-{{ arch }}-master-
- &save-cache-gradle
paths:
- ~/.gradle
key: v1-gradle-{{ arch }}-{{ .Branch }}-{{ checksum "build.gradle" }}-{{ checksum "ReactAndroid/build.gradle" }}

- &restore-cache-apt
keys:
- v1-apt-{{ arch }}-{{ .Branch }}-{{ checksum "scripts/circleci/apt-get-android-deps.sh" }}
# Fallback in case checksum fails
- v1-apt-{{ arch }}-{{ .Branch }}-
# Fallback in case this is a first-time run on a fork
- v1-apt-{{ arch }}-master-
- &save-cache-apt
paths:
- ~/vendor/apt
key: v1-apt-{{ arch }}-{{ .Branch }}-{{ checksum "scripts/circleci/apt-get-android-deps.sh" }}

- &restore-cache-ndk
keys:
- v2-android-ndk-{{ arch }}-r10e-32-64-{{ checksum "scripts/circle-ci-android-setup.sh" }}
Expand Down Expand Up @@ -97,7 +122,8 @@ aliases:
yarn install --non-interactive --cache-folder ~/.cache/yarn

- &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
Expand All @@ -107,15 +133,17 @@ aliases:
npm install --no-package-lock --no-spin --no-progress

- &install-buck
|
name: Install BUCK
command: |
if [[ ! -e ~/buck ]]; then
git clone https://github.com/facebook/buck.git ~/buck --branch v2018.02.16.01 --depth=1
fi
cd ~/buck && ant
buck --version
- &install-node
|
name: Install Node
command: |
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
Expand All @@ -141,9 +169,7 @@ aliases:

- &install-android-build-dependencies
name: Install Android 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 file -y
command: ./scripts/circleci/apt-get-android-deps.sh

- &validate-android-sdk
name: Validate Android SDK Install
Expand Down Expand Up @@ -400,6 +426,7 @@ jobs:
# 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
- save-cache: *save-cache-android-packages
Expand Down Expand Up @@ -450,7 +477,10 @@ jobs:

# Configure Android SDK and related dependencies
- run: *configure-android-path
- restore-cache: *restore-cache-apt
- run: *install-android-build-dependencies
- save-cache: *save-cache-apt

- restore-cache: *restore-cache-android-packages
- run: *install-android-packages
- save-cache: *save-cache-android-packages
Expand Down Expand Up @@ -481,7 +511,11 @@ jobs:
- run: buck fetch ReactAndroid/src/main/java/com/facebook/react/shell
- run: buck fetch ReactAndroid/src/test/...
- run: buck fetch ReactAndroid/src/androidTest/...

# Gradle
- restore-cache: *restore-cache-gradle
- run: ./gradlew :ReactAndroid:downloadBoost :ReactAndroid:downloadDoubleConversion :ReactAndroid:downloadFolly :ReactAndroid:downloadGlog :ReactAndroid:downloadJSCHeaders
- save-cache: *save-cache-gradle

# Build and compile
- run: *build-android-app
Expand Down
25 changes: 25 additions & 0 deletions scripts/circleci/apt-get-android-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

set -e

echo "Downloading package lists..."
sudo apt-get update -y

if ! [[ -d ~/vendor/apt ]]; then
mkdir -p ~/vendor/apt
fi

# First check for archives cache
if ! [[ -d ~/vendor/apt/archives ]]; then
# It doesn't so download the packages
echo "Downloading build dependencies..."
sudo apt-get install --download-only ant autoconf automake g++ gcc libqt5widgets5 lib32z1 lib32stdc++6 make maven python-dev python3-dev qml-module-qtquick-controls qtdeclarative5-dev file -y
# Then move them to our cache directory
sudo cp -R /var/cache/apt ~/vendor/
# Making sure our user has ownership, in order to cache
sudo chown -R ${USER:=$(/usr/bin/id -run)}:$USER ~/vendor/apt
fi

# Install all packages in the cache
echo "Installing build dependencies..."
sudo dpkg -i ~/vendor/apt/archives/*.deb

0 comments on commit 49e5975

Please sign in to comment.