Skip to content

Commit

Permalink
Merge pull request #5462 from wordpress-mobile/improve-order-of-ci-jobs
Browse files Browse the repository at this point in the history
CircleCI - Update configuration to make builds once and share between jobs
  • Loading branch information
geriux committed Feb 15, 2023
2 parents a3b9884 + 26fbf22 commit 3a3f91a
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 46 deletions.
141 changes: 99 additions & 42 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,64 @@ version: 2.1

commands:
npm-install:
parameters:
steps:
- restore_cache:
name: Restore NPM Cache
keys:
- npm-i18n-v5-cache-v{{ .Environment.CACHE_TRIGGER_VERSION }}-job-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package-lock.json" }}
- npm-i18n-v5-cache-v{{ .Environment.CACHE_TRIGGER_VERSION }}-job-{{ .Environment.CIRCLE_JOB }}-
- npm-install-cache-{{ .Environment.CACHE_TRIGGER_VERSION }}-{{ arch }}-{{ checksum "package-lock.json" }}
- npm-install-cache-{{ .Environment.CACHE_TRIGGER_VERSION }}-{{ arch }}-
- run:
name: NPM Install
command: |
echo "Node version: $(node --version)"
npm ci --prefer-offline --no-audit
- save_cache:
name: Save NPM Cache
key: npm-i18n-v5-cache-v{{ .Environment.CACHE_TRIGGER_VERSION }}-job-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package-lock.json" }}
key: npm-install-cache-{{ .Environment.CACHE_TRIGGER_VERSION }}-{{ arch }}-{{ checksum "package-lock.json" }}
paths:
- ~/.npm
- src/i18n-cache
- ~/.local/share/pnpm/store/v3
- ~/Library/pnpm/store/v3
npm-install-full:
parameters:
additional-flags:
type: string
default: ""
steps:
- restore_cache:
name: Restore NPM Cache
keys:
- npm-i18n-v5-cache-v{{ .Environment.CACHE_TRIGGER_VERSION }}-job-{{ .Environment.CIRCLE_JOB }}-{{ checksum "gutenberg/package-lock.json" }}
- npm-i18n-v5-cache-v{{ .Environment.CACHE_TRIGGER_VERSION }}-job-{{ .Environment.CIRCLE_JOB }}-
- npm-install-full-cache-{{ .Environment.CACHE_TRIGGER_VERSION }}-{{ arch }}-{{ checksum "gutenberg/package-lock.json" }}
- npm-install-full-cache-{{ .Environment.CACHE_TRIGGER_VERSION }}-{{ arch }}-
- run:
name: NPM Install Full
command: |
echo "Node version: $(node --version)"
npm install --no-audit
- save_cache:
name: Save NPM Cache
key: npm-i18n-v5-cache-v{{ .Environment.CACHE_TRIGGER_VERSION }}-job-{{ .Environment.CIRCLE_JOB }}-{{ checksum "gutenberg/package-lock.json" }}
key: npm-install-full-cache-{{ .Environment.CACHE_TRIGGER_VERSION }}-{{ arch }}-{{ checksum "gutenberg/package-lock.json" }}
paths:
- ~/.npm
- src/i18n-cache
- ~/.local/share/pnpm/store/v3
- ~/Library/pnpm/store/v3
npm-install-e2e-tests:
parameters:
steps:
- restore_cache:
name: Restore NPM Cache
keys:
- npm-install-cache-{{ .Environment.CACHE_TRIGGER_VERSION }}-{{ arch }}-{{ checksum "package-lock.json" }}
- npm-install-cache-{{ .Environment.CACHE_TRIGGER_VERSION }}-{{ arch }}-
- run:
name: NPM Install (E2E Tests)
command: |
echo "Node version: $(node --version)"
npm ci --prefer-offline --no-audit --ignore-scripts
npm ci --prefix gutenberg --prefer-offline --no-audit
checkout-shallow:
steps:
- run:
Expand Down Expand Up @@ -114,7 +137,7 @@ commands:
- run:
name: Install newer nvm
command: |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
if [ -z "${NVM_DIR}" ] ; then
echo 'Default NVM_DIR to .nvm in home'
echo 'export NVM_DIR="$HOME/.nvm"' >> $BASH_ENV
Expand All @@ -137,7 +160,7 @@ parameters:
linux-machine-image:
type: string
# Latest supported ubuntu image from https://circleci.com/docs/2.0/configuration-reference/#available-machine-images
default: "ubuntu-2004:202010-01"
default: "ubuntu-2004:2022.10.1"

jobs:
checks:
Expand Down Expand Up @@ -179,15 +202,7 @@ jobs:
JEST_JUNIT_OUTPUT_FILE: "reports/test-results/android-test-results.xml"
- store_test_results:
path: ./reports/test-results
android-device-checks:
parameters:
post-to-slack:
description: Post to Slack when tests fail. SLACK_WEBHOOK ENV variable must be set.
type: boolean
default: false
is-canary:
type: string
default: ""
android-build:
machine:
image: << pipeline.parameters.linux-machine-image >>
steps:
Expand Down Expand Up @@ -216,6 +231,23 @@ jobs:
--form 'payload=@"./gutenberg/packages/react-native-editor/android/app/build/outputs/apk/debug/app-debug.apk"' \
--form "name=Gutenberg-$SAUCE_FILENAME.apk" \
--form 'description="Gutenberg"'
android-device-checks:
parameters:
post-to-slack:
description: Post to Slack when tests fail. SLACK_WEBHOOK ENV variable must be set.
type: boolean
default: false
is-canary:
type: string
default: ""
machine:
image: << pipeline.parameters.linux-machine-image >>
steps:
- checkout-shallow
- checkout-submodules
- install-node-version
- run: node -v
- npm-install-e2e-tests
- run: mkdir /home/circleci/test-results
- run:
name: Run Device Tests
Expand Down Expand Up @@ -246,23 +278,14 @@ jobs:
- run:
name: Run Android native-bridge unit tests
command: cd gutenberg/packages/react-native-bridge/android && ./gradlew test
ios-device-checks:
parameters:
post-to-slack:
description: Post to Slack when tests fail. SLACK_WEBHOOK ENV variable must be set.
type: boolean
default: false
is-canary:
type: string
default: ""
ios-build:
macos:
xcode: "13.4.1"
steps:
- checkout-shallow
- checkout-submodules
- install-node-version
- npm-install
- add-jest-reporter-dir
- run:
name: Set Environment Variables
command: |
Expand All @@ -278,16 +301,16 @@ jobs:
- restore_cache:
name: Restore Dependencies Cache
keys:
- dependencies-v5-{{ checksum "gutenberg/packages/react-native-editor/ios/Gemfile.lock" }}-{{ checksum "gutenberg/packages/react-native-editor/ios/Podfile.lock" }}-{{ checksum "gutenberg/package-lock.json" }}
- dependencies-v5-{{ checksum "gutenberg/packages/react-native-editor/ios/Gemfile.lock" }}-{{ checksum "gutenberg/packages/react-native-editor/ios/Podfile.lock" }}
- dependencies-v5-{{ checksum "gutenberg/packages/react-native-editor/ios/Gemfile.lock" }}
- dependencies-v5-
- dependencies-v6-{{ checksum "gutenberg/packages/react-native-editor/ios/Gemfile.lock" }}-{{ checksum "gutenberg/packages/react-native-editor/ios/Podfile.lock" }}-{{ checksum "gutenberg/package-lock.json" }}
- dependencies-v6-{{ checksum "gutenberg/packages/react-native-editor/ios/Gemfile.lock" }}-{{ checksum "gutenberg/packages/react-native-editor/ios/Podfile.lock" }}
- dependencies-v6-{{ checksum "gutenberg/packages/react-native-editor/ios/Gemfile.lock" }}
- dependencies-v6-
- run:
name: Build (if needed)
command: test -e gutenberg/packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app || npm run core test:e2e:build-app:ios
- save_cache:
name: Save Dependencies Cache
key: dependencies-v5-{{ checksum "gutenberg/packages/react-native-editor/ios/Gemfile.lock" }}-{{ checksum "gutenberg/packages/react-native-editor/ios/Podfile.lock" }}-{{ checksum "gutenberg/package-lock.json" }}
key: dependencies-v6-{{ checksum "gutenberg/packages/react-native-editor/ios/Gemfile.lock" }}-{{ checksum "gutenberg/packages/react-native-editor/ios/Podfile.lock" }}-{{ checksum "gutenberg/package-lock.json" }}
paths:
- gutenberg/packages/react-native-editor/ios/Pods
- ~/Library/Caches/CocoaPods
Expand All @@ -308,6 +331,36 @@ jobs:
--form 'payload=@"./gutenberg/packages/react-native-editor/ios/GutenbergDemo.app.zip"' \
--form "name=Gutenberg-$SAUCE_FILENAME.app.zip" \
--form 'description="Gutenberg"'
- run:
name: Prepare build cache
command: rm gutenberg/packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app/main.jsbundle
- save_cache:
name: Save Build Cache
key: ios-build-cache-{{ checksum "ios-checksums.txt" }}
paths:
- gutenberg/packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app
ios-device-checks:
parameters:
post-to-slack:
description: Post to Slack when tests fail. SLACK_WEBHOOK ENV variable must be set.
type: boolean
default: false
is-canary:
type: string
default: ""
macos:
xcode: "13.4.1"
steps:
- checkout-shallow
- checkout-submodules
- install-node-version
- npm-install-e2e-tests
- add-jest-reporter-dir
- run:
name: Set Environment Variables
command: |
echo 'export TEST_RN_PLATFORM=ios' >> $BASH_ENV
echo 'export TEST_ENV=sauce' >> $BASH_ENV
- run:
name: Run Device Tests
command: |
Expand All @@ -317,14 +370,6 @@ jobs:
JEST_JUNIT_OUTPUT_FILE: "reports/test-results/ios-test-results.xml"
- store_test_results:
path: ./reports/test-results
- run:
name: Prepare build cache
command: rm gutenberg/packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app/main.jsbundle
- save_cache:
name: Save Build Cache
key: ios-build-cache-{{ checksum "ios-checksums.txt" }}
paths:
- gutenberg/packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app

workflows:
gutenberg-mobile:
Expand All @@ -340,12 +385,18 @@ workflows:
name: Test Android
platform: android
check-tests: true
- ios-build:
name: iOS Build
- android-build:
name: Android Build
- ios-device-checks:
name: Test iOS on Device - Canaries
is-canary: "-canary"
requires: [ "Test iOS", "iOS Build" ]
- android-device-checks:
name: Test Android on Device - Canaries
is-canary: "-canary"
requires: [ "Test Android", "Android Native Unit Tests", "Android Build" ]
- Optional UI Tests:
type: approval
filters:
Expand All @@ -356,48 +407,54 @@ workflows:
- /^release.*/
- ios-device-checks:
name: Test iOS on Device - Full
requires: [ "Optional UI Tests" ]
requires: [ "Optional UI Tests", "Test iOS", "iOS Build" ]
- android-device-checks:
name: Test Android on Device - Full
requires: [ "Optional UI Tests" ]
requires: [ "Optional UI Tests", "Test Android", "Android Native Unit Tests", "Android Build" ]
- android-native-unit-tests:
name: Android Native Unit Tests
- ios-device-checks:
name: Test iOS on Device - Full (Submodule Update)
post-to-slack: true
requires: [ "Test iOS", "iOS Build" ]
filters:
branches:
only: /^dependabot/submodules/.*/
- android-device-checks:
name: Test Android on Device - Full (Submodule Update)
post-to-slack: true
requires: [ "Test Android", "Android Native Unit Tests", "Android Build" ]
filters:
branches:
only: /^dependabot/submodules/.*/
- ios-device-checks:
name: Test iOS on Device - Full (On Trunk)
post-to-slack: true
requires: [ "Test iOS", "iOS Build" ]
filters:
branches:
only:
- trunk
- android-device-checks:
name: Test Android on Device - Full (On Trunk)
post-to-slack: true
requires: [ "Test Android", "Android Native Unit Tests", "Android Build" ]
filters:
branches:
only:
- trunk
- ios-device-checks:
name: Test iOS on Device - Full (Release)
post-to-slack: true
requires: [ "Test iOS", "iOS Build" ]
filters:
branches:
only:
- /^release.*/
- android-device-checks:
name: Test Android on Device - Full (Release)
post-to-slack: true
requires: [ "Test Android", "Android Native Unit Tests", "Android Build" ]
filters:
branches:
only:
Expand Down
2 changes: 1 addition & 1 deletion gutenberg
Submodule gutenberg updated 31 files
+4 −0 packages/block-editor/CHANGELOG.md
+2 −0 packages/block-editor/src/components/block-types-list/index.native.js
+45 −0 packages/block-editor/src/components/global-styles/hooks.js
+1 −0 packages/block-editor/src/components/global-styles/index.js
+34 −101 packages/block-editor/src/components/global-styles/typography-panel.js
+2 −0 packages/block-editor/src/components/inserter/block-types-tab.native.js
+2 −0 packages/block-editor/src/components/inserter/reusable-blocks-tab.native.js
+2 −0 packages/block-editor/src/components/inserter/search-results.native.js
+7 −1 packages/block-editor/src/components/link-control/style.scss
+52 −22 packages/block-editor/src/hooks/typography.js
+1 −0 packages/components/src/autocomplete/autocompleter-ui.native.js
+14 −5 packages/edit-site/src/components/global-styles/context-menu.js
+12 −8 packages/edit-site/src/components/global-styles/screen-block-list.js
+10 −3 packages/edit-site/src/components/global-styles/typography-panel.js
+1 −0 packages/editor/src/components/post-title/index.native.js
+0 −38 packages/react-native-editor/__device-tests__/gutenberg-editor-audio.test.js
+93 −2 packages/react-native-editor/__device-tests__/gutenberg-editor-block-insertion-@canary.test.js
+0 −119 packages/react-native-editor/__device-tests__/gutenberg-editor-block-insertion.test.js
+0 −62 packages/react-native-editor/__device-tests__/gutenberg-editor-cover.test.js
+45 −1 packages/react-native-editor/__device-tests__/gutenberg-editor-device-actions.test.js
+5 −5 packages/react-native-editor/__device-tests__/gutenberg-editor-drag-and-drop.test.js
+0 −38 packages/react-native-editor/__device-tests__/gutenberg-editor-file-@canary.test.js
+0 −44 packages/react-native-editor/__device-tests__/gutenberg-editor-image-@canary.test.js
+0 −0 packages/react-native-editor/__device-tests__/gutenberg-editor-initial-html-@canary.test.js
+165 −0 packages/react-native-editor/__device-tests__/gutenberg-editor-media-blocks-@canary.test.js
+11 −6 packages/react-native-editor/__device-tests__/gutenberg-editor-paragraph.test.js
+0 −49 packages/react-native-editor/__device-tests__/gutenberg-editor-rotation.test.js
+4 −8 packages/react-native-editor/__device-tests__/gutenberg-editor-search.test.js
+2 −6 packages/react-native-editor/__device-tests__/helpers/test-data.js
+85 −34 packages/react-native-editor/__device-tests__/pages/editor-page.js
+1 −1 packages/react-native-editor/package.json
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@
"wpandroid": "cd gutenberg && react-native run-android --root $TMPDIR/gbmobile-wpandroidfakernroot --variant wasabiDebug --appIdSuffix beta --appFolder WordPress --main-activity=ui.WPLaunchActivity",
"test": "cross-env NODE_ENV=test jest --verbose --config ./jest.config.js",
"test:debug": "cross-env NODE_ENV=test node --inspect-brk node_modules/.bin/jest --runInBand --verbose --config jest.config.js",
"device-tests": "cross-env NODE_ENV=test jest --no-cache --maxWorkers=3 --testPathIgnorePatterns=@canary --verbose --config jest_ui.config.js",
"device-tests-canary": "cross-env NODE_ENV=test jest --no-cache --maxWorkers=2 --testPathPattern=@canary --verbose --config jest_ui.config.js",
"device-tests:local": "IOS_APP_PATH='./gutenberg/packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app' WDA_PATH='./gutenberg/packages/react-native-editor/ios/build/WDA' ANDROID_APP_PATH='./gutenberg/packages/react-native-editor/android/app/build/outputs/apk/debug/app-debug.apk' cross-env NODE_ENV=test jest --runInBand --detectOpenHandles --verbose --config jest_ui.config.js",
"device-tests": "cross-env NODE_ENV=test jest --maxWorkers=2 --testPathIgnorePatterns='canary|gutenberg-editor-rendering' --verbose --config jest_ui.config.js",
"device-tests-canary": "cross-env NODE_ENV=test jest --maxWorkers=2 --testPathPattern=@canary --verbose --config jest_ui.config.js",
"device-tests:local": "IOS_APP_PATH='./gutenberg/packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app' WDA_PATH='./gutenberg/packages/react-native-editor/ios/build/WDA' ANDROID_APP_PATH='./gutenberg/packages/react-native-editor/android/app/build/outputs/apk/debug/app-debug.apk' NODE_ENV=test jest --maxWorkers=2 --detectOpenHandles --verbose --config jest_ui.config.js",
"device-tests:debug": "IOS_APP_PATH='./gutenberg/packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app' WDA_PATH='./gutenberg/packages/react-native-editor/ios/build/WDA' ANDROID_APP_PATH='./gutenberg/packages/react-native-editor/android/app/build/outputs/apk/debug/app-debug.apk' cross-env NODE_ENV=test node $NODE_DEBUG_OPTION --inspect-brk node_modules/jest/bin/jest --runInBand --detectOpenHandles --verbose --config jest_ui.config.js",
"test:e2e:bundle:android": "npm run test:e2e:bundle:android:text && npm run test:e2e:bundle:android:bytecode",
"test:e2e:bundle:android:text": "mkdir -p gutenberg/packages/react-native-editor/android/app/src/main/assets && npm run rn-bundle -- --reset-cache --platform android --dev false --minify false --entry-file index.js --bundle-output gutenberg/packages/react-native-editor/android/app/src/main/assets/index.android.text.bundle --assets-dest gutenberg/packages/react-native-editor/android/app/src/main/res",
Expand Down

0 comments on commit 3a3f91a

Please sign in to comment.