Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 43 additions & 32 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,28 @@ commands:
name: Yarn bundle Android
working_directory: libs/gutenberg-mobile
command: yarn bundle:android
save-gutenberg-bundle-cache:
steps:
- run:
name: Save Gutenberg-Mobile Submodule Hash
command: |
git rev-parse @:./libs/gutenberg-mobile > gutenberg_submodule_hash
cat gutenberg_submodule_hash
- save_cache:
name: Cache JS Bundle
key: android-js-bundle-{{ checksum "gutenberg_submodule_hash" }}
paths:
- libs/gutenberg-mobile/react-native-gutenberg-bridge/android/build/assets/index.android.bundle
restore-gutenberg-bundle-cache:
steps:
- run:
name: Save Gutenberg-Mobile Submodule Hash
command: |
git rev-parse @:./libs/gutenberg-mobile > gutenberg_submodule_hash
cat gutenberg_submodule_hash
- restore_cache:
name: Restore JS Bundle From Cache
key: android-js-bundle-{{ checksum "gutenberg_submodule_hash" }}

version: 2.1
jobs:
Expand All @@ -51,17 +73,26 @@ jobs:
- image: circleci/node:10
steps:
- git/shallow-checkout
- restore-gutenberg-bundle-cache
- run:
name: Abort If JS Bundle Exists
command: |
if [ -f "libs/gutenberg-mobile/react-native-gutenberg-bridge/android/build/assets/index.android.bundle" ]; then
echo "Gutenberg-Mobile bundle already in cache, no need to create a new one."
circleci-agent step halt
else
echo "Gutenberg-Mobile bundle not found in cache. Proceeding to generate new bundle"
fi
- checkout-submodules
- yarn-install
- yarn-bundle-android
- run:
name: Rename the JS bundle
working_directory: libs/gutenberg-mobile
command: mv bundle/android/App.js bundle/android/index.android.bundle
- persist_to_workspace:
root: libs/gutenberg-mobile/bundle/android
paths:
- index.android.bundle
name: Ensure assets folder exists
command: mkdir -p libs/gutenberg-mobile/react-native-gutenberg-bridge/android/build/assets
- run:
name: Move bundle to assets folder
command: mv libs/gutenberg-mobile/bundle/android/App.js libs/gutenberg-mobile/react-native-gutenberg-bridge/android/build/assets/index.android.bundle
- save-gutenberg-bundle-cache
test:
executor:
name: android/default
Expand All @@ -71,11 +102,7 @@ jobs:
- checkout-gutenberg-mobile-submodule-only
- android/restore-gradle-cache
- copy-gradle-properties
- run:
name: Ensure assets folder exists
command: mkdir libs/gutenberg-mobile/react-native-gutenberg-bridge/android/src/main/assets
- attach_workspace:
at: libs/gutenberg-mobile/react-native-gutenberg-bridge/android/src/main/assets
- restore-gutenberg-bundle-cache
- run:
name: Test WordPress
environment:
Expand All @@ -97,11 +124,7 @@ jobs:
- checkout-gutenberg-mobile-submodule-only
- android/restore-gradle-cache
- copy-gradle-properties
- run:
name: Ensure assets folder exists
command: mkdir libs/gutenberg-mobile/react-native-gutenberg-bridge/android/src/main/assets
- attach_workspace:
at: libs/gutenberg-mobile/react-native-gutenberg-bridge/android/src/main/assets
- restore-gutenberg-bundle-cache
- run:
name: Checkstyle
environment:
Expand Down Expand Up @@ -143,11 +166,7 @@ jobs:
name: Copy Secrets
command: bundle exec fastlane run configure_apply
- android/restore-gradle-cache
- run:
name: Ensure assets folder exists
command: mkdir libs/gutenberg-mobile/react-native-gutenberg-bridge/android/src/main/assets
- attach_workspace:
at: libs/gutenberg-mobile/react-native-gutenberg-bridge/android/src/main/assets
- restore-gutenberg-bundle-cache
- run:
name: Build APK
environment:
Expand Down Expand Up @@ -187,11 +206,7 @@ jobs:
- checkout-gutenberg-mobile-submodule-only
- android/restore-gradle-cache
- copy-gradle-properties
- run:
name: Ensure assets folder exists
command: mkdir libs/gutenberg-mobile/react-native-gutenberg-bridge/android/src/main/assets
- attach_workspace:
at: libs/gutenberg-mobile/react-native-gutenberg-bridge/android/src/main/assets
- restore-gutenberg-bundle-cache
- run:
name: Build
environment:
Expand Down Expand Up @@ -229,11 +244,7 @@ jobs:
- checkout-gutenberg-mobile-submodule-only
- android/restore-gradle-cache
- copy-gradle-properties
- run:
name: Ensure assets folder exists
command: mkdir libs/gutenberg-mobile/react-native-gutenberg-bridge/android/src/main/assets
- attach_workspace:
at: libs/gutenberg-mobile/react-native-gutenberg-bridge/android/src/main/assets
- restore-gutenberg-bundle-cache
- run:
name: Build
environment:
Expand Down
17 changes: 12 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
buildscript {
ext.kotlinVersion = '1.3.61'
ext.navComponenVersion = '2.0.0'
ext.buildGutenbergMobileJSBundle = 1

repositories {
google()
Expand All @@ -21,13 +20,21 @@ plugins {
id 'com.gradle.build-scan' version '2.0.2'
}

ext {
buildGutenbergMobileJSBundle = 1
}

apply plugin: 'com.automattic.android.fetchstyle'

project.ext.buildGutenbergFromSource = project.properties.getOrDefault('wp.BUILD_GUTENBERG_FROM_SOURCE', false).toBoolean()
def suppressJSBundle = System.getenv('SUPPRESS_GUTENBERG_MOBILE_JS_BUNDLE_BUILD').asBoolean()
project.ext.buildGutenbergMobileJSBundle = !(suppressJSBundle || project.ext.buildGutenbergFromSource)

if (project.ext.buildGutenbergFromSource) {
def nodeModulesDir = new File('libs/gutenberg-mobile/node_modules')
if (!nodeModulesDir.exists()) {
def message = "Attempting to build Gutenberg from source without a libs/gutenberg-mobile/node_modules directory. \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

definitely appreciate this message as a reminder! 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing like tripping over something multiple times yourself to make you think, "Hmmm, maybe I should give a helpful message here." 😆

Either run `yarn install` manually within libs/gutenberg-mobile or disable building Gutenberg from source by \
setting wp.BUILD_GUTENBERG_FROM_SOURCE to false."
throw new GradleException(message)
}
}

allprojects {
apply plugin: 'checkstyle'
Expand Down
2 changes: 1 addition & 1 deletion libs/gutenberg-mobile