From 9f1a5aedbb00000233a823a7bde451061c3808a1 Mon Sep 17 00:00:00 2001 From: Hawken Rives Date: Tue, 24 Jan 2023 08:02:27 -0500 Subject: [PATCH 01/12] add (and use) "cache npm" jobs for each platform --- .github/workflows/check.yml | 193 ++++++++++++++++++++++++++++++------ 1 file changed, 165 insertions(+), 28 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 2016c1042e..7dba59f38a 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -13,8 +13,71 @@ env: xcode_version: 'Xcode_13.1' jobs: + cache-npm-linux: + name: Cache npm for Linux + runs-on: ubuntu-22.04 + outputs: + cache-key: ${{ steps.node-cache.outputs.cache-primary-key }} + steps: + - uses: actions/checkout@v3.3.0 + + - name: Extract job definition + run: yq '.jobs.${{ github.job }}' .github/workflows/check.yml > .github/job.yml + + - uses: actions/cache/restore@v3 + id: node-cache + with: + path: node_modules/ + key: ${{ runner.os }}-npm-node@${{ env.node_version }}-${{ hashFiles('package-lock.json', '.github/job.yml') }} + + - if: steps.node-cache.outputs.cache-hit != 'true' + uses: actions/setup-node@v3 + with: + node-version: ${{ env.node_version }} + cache: npm + + - if: steps.node-cache.outputs.cache-hit != 'true' + run: npm ci + + - uses: actions/cache/save@v3 + with: + path: node_modules/ + key: ${{ steps.node-cache.outputs.cache-primary-key }} + + cache-npm-macos: + name: Cache npm for macOS + runs-on: macos-11 + outputs: + cache-key: ${{ steps.node-cache.outputs.cache-primary-key }} + steps: + - uses: actions/checkout@v3.3.0 + + - name: Extract job definition + run: yq '.jobs.${{ github.job }}' .github/workflows/check.yml > .github/job.yml + + - uses: actions/cache/restore@v3 + id: node-cache + with: + path: node_modules/ + key: ${{ runner.os }}-npm-node@${{ env.node_version }}-${{ hashFiles('package-lock.json', '.github/job.yml') }} + + - if: steps.node-cache.outputs.cache-hit != 'true' + uses: actions/setup-node@v3 + with: + node-version: ${{ env.node_version }} + cache: npm + + - if: steps.node-cache.outputs.cache-hit != 'true' + run: npm ci + + - uses: actions/cache/save@v3 + with: + path: node_modules/ + key: ${{ steps.node-cache.outputs.cache-primary-key }} + prettier: name: Prettier + needs: [cache-npm-linux] runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3.3.0 @@ -22,14 +85,22 @@ jobs: - uses: actions/setup-node@v3 with: node-version: ${{ env.node_version }} - cache: npm - - run: npm ci + - name: Restore node_modules cache + uses: actions/cache/restore@v3 + id: node-cache + with: + path: node_modules/ + key: ${{ needs.cache-npm-linux.outputs.cache-key }} + + - if: steps.node-cache.outputs.cache-hit != 'true' + run: exit 1 - run: npm run pretty -- --no-write --list-different eslint: name: ESLint + needs: [cache-npm-linux] runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3.3.0 @@ -37,14 +108,22 @@ jobs: - uses: actions/setup-node@v3 with: node-version: ${{ env.node_version }} - cache: npm - - run: npm ci + - name: Restore node_modules cache + uses: actions/cache/restore@v3 + id: node-cache + with: + path: node_modules/ + key: ${{ needs.cache-npm-linux.outputs.cache-key }} + + - if: steps.node-cache.outputs.cache-hit != 'true' + run: exit 1 - run: npm run lint jest: name: Jest + needs: [cache-npm-linux] runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3.3.0 @@ -52,9 +131,16 @@ jobs: - uses: actions/setup-node@v3 with: node-version: ${{ env.node_version }} - cache: npm - - run: npm ci + - name: Restore node_modules cache + uses: actions/cache/restore@v3 + id: node-cache + with: + path: node_modules/ + key: ${{ needs.cache-npm-linux.outputs.cache-key }} + + - if: steps.node-cache.outputs.cache-hit != 'true' + run: exit 1 - run: npm run bundle-data @@ -66,6 +152,7 @@ jobs: tsc: name: TypeScript + needs: [cache-npm-linux] runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3.3.0 @@ -73,9 +160,16 @@ jobs: - uses: actions/setup-node@v3 with: node-version: ${{ env.node_version }} - cache: npm - - run: npm ci + - name: Restore node_modules cache + uses: actions/cache/restore@v3 + id: node-cache + with: + path: node_modules/ + key: ${{ needs.cache-npm-linux.outputs.cache-key }} + + - if: steps.node-cache.outputs.cache-hit != 'true' + run: exit 1 - run: npm run bundle-data @@ -83,6 +177,7 @@ jobs: data: name: Data + needs: [cache-npm-linux] runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3.3.0 @@ -90,9 +185,16 @@ jobs: - uses: actions/setup-node@v3 with: node-version: ${{ env.node_version }} - cache: npm - - run: npm ci + - name: Restore node_modules cache + uses: actions/cache/restore@v3 + id: node-cache + with: + path: node_modules/ + key: ${{ needs.cache-npm-linux.outputs.cache-key }} + + - if: steps.node-cache.outputs.cache-hit != 'true' + run: exit 1 - run: npm run validate-data @@ -100,6 +202,7 @@ jobs: ios-pods: name: iOS Cocoapods + needs: [cache-npm-macos] runs-on: macos-11 steps: - uses: actions/checkout@v3.3.0 @@ -107,7 +210,16 @@ jobs: - uses: actions/setup-node@v3 with: node-version: ${{ env.node_version }} - cache: npm + + - name: Restore node_modules cache + uses: actions/cache/restore@v3 + id: node-cache + with: + path: node_modules/ + key: ${{ needs.cache-npm-macos.outputs.cache-key }} + + - if: steps.node-cache.outputs.cache-hit != 'true' + run: exit 1 - uses: ruby/setup-ruby@v1 with: @@ -124,14 +236,12 @@ jobs: - run: sudo xcode-select -s /Applications/${{ env.xcode_version }}.app - - run: npm ci - env: {SKIP_POSTINSTALL: '1'} - - run: bundle exec pod install --deployment working-directory: ./ios ios-bundle: name: iOS Bundle + needs: [cache-npm-linux] runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3.3.0 @@ -139,9 +249,16 @@ jobs: - uses: actions/setup-node@v3 with: node-version: ${{ env.node_version }} - cache: npm - - run: npm ci + - name: Restore node_modules cache + uses: actions/cache/restore@v3 + id: node-cache + with: + path: node_modules/ + key: ${{ needs.cache-npm-linux.outputs.cache-key }} + + - if: steps.node-cache.outputs.cache-hit != 'true' + run: exit 1 - run: npm run bundle-data @@ -149,6 +266,7 @@ jobs: android-bundle: name: Android Bundle + needs: [cache-npm-linux] runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3.3.0 @@ -156,9 +274,16 @@ jobs: - uses: actions/setup-node@v3 with: node-version: ${{ env.node_version }} - cache: npm - - run: npm ci + - name: Restore node_modules cache + uses: actions/cache/restore@v3 + id: node-cache + with: + path: node_modules/ + key: ${{ needs.cache-npm-linux.outputs.cache-key }} + + - if: steps.node-cache.outputs.cache-hit != 'true' + run: exit 1 - run: npm run bundle-data @@ -168,15 +293,24 @@ jobs: android: name: Build for Android + needs: [jest, eslint, android-bundle, cache-npm-linux] runs-on: ubuntu-22.04 - needs: [jest, eslint, android-bundle] steps: - uses: actions/checkout@v3.3.0 - uses: actions/setup-node@v3 with: node-version: ${{ env.node_version }} - cache: npm + + - name: Restore node_modules cache + uses: actions/cache/restore@v3 + id: node-cache + with: + path: node_modules/ + key: ${{ needs.cache-npm-linux.outputs.cache-key }} + + - if: steps.node-cache.outputs.cache-hit != 'true' + run: exit 1 - uses: ruby/setup-ruby@v1 with: @@ -193,8 +327,6 @@ jobs: restore-keys: | ${{ runner.os }}-gradle- - - run: npm ci - - name: Raise the fs.inotify ulimits to 524288 watches/queued events/user instances run: | echo 524288 | sudo tee -a /proc/sys/fs/inotify/max_user_watches @@ -220,15 +352,24 @@ jobs: ios: name: Build for iOS + needs: [jest, eslint, ios-bundle, ios-pods, cache-npm-macos] runs-on: macos-11 - needs: [jest, eslint, ios-bundle, ios-pods] steps: - uses: actions/checkout@v3.3.0 - uses: actions/setup-node@v3 with: node-version: ${{ env.node_version }} - cache: npm + + - name: Restore node_modules cache + uses: actions/cache/restore@v3 + id: node-cache + with: + path: node_modules/ + key: ${{ needs.cache-npm-macos.outputs.cache-key }} + + - if: steps.node-cache.outputs.cache-hit != 'true' + run: exit 1 - uses: ruby/setup-ruby@v1 with: @@ -249,10 +390,6 @@ jobs: - run: sudo xcode-select -s /Applications/${{ env.xcode_version }}.app - - run: npm ci - env: - SKIP_POSTINSTALL: '1' - - run: bundle exec pod install --deployment working-directory: ./ios From c9824f53c5676e8c9275dc02ff34f4790ada8a14 Mon Sep 17 00:00:00 2001 From: Hawken Rives Date: Tue, 24 Jan 2023 08:04:16 -0500 Subject: [PATCH 02/12] create "cache bundler" jobs for each platform --- .github/workflows/check.yml | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 7dba59f38a..f59deaeb6f 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -75,6 +75,28 @@ jobs: path: node_modules/ key: ${{ steps.node-cache.outputs.cache-primary-key }} + cache-bundler-linux: + name: Cache bundler for Linux + runs-on: macos-11 + steps: + - uses: actions/checkout@v3.3.0 + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ env.ruby_version }} + bundler-cache: true + + cache-bundler-macos: + name: Cache bundler for macOS + runs-on: macos-11 + steps: + - uses: actions/checkout@v3.3.0 + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ env.ruby_version }} + bundler-cache: true + prettier: name: Prettier needs: [cache-npm-linux] @@ -202,7 +224,7 @@ jobs: ios-pods: name: iOS Cocoapods - needs: [cache-npm-macos] + needs: [cache-npm-macos, cache-bundler-macos] runs-on: macos-11 steps: - uses: actions/checkout@v3.3.0 @@ -293,7 +315,7 @@ jobs: android: name: Build for Android - needs: [jest, eslint, android-bundle, cache-npm-linux] + needs: [jest, eslint, android-bundle, cache-npm-linux, cache-bundler-linux] runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3.3.0 @@ -352,7 +374,7 @@ jobs: ios: name: Build for iOS - needs: [jest, eslint, ios-bundle, ios-pods, cache-npm-macos] + needs: [jest, eslint, ios-bundle, ios-pods, cache-npm-macos, cache-bundler-macos] runs-on: macos-11 steps: - uses: actions/checkout@v3.3.0 From 782c7de6c3d3b2f63316cf1d792c3c769b172879 Mon Sep 17 00:00:00 2001 From: Hawken Rives Date: Tue, 24 Jan 2023 08:07:37 -0500 Subject: [PATCH 03/12] rework the "cache cocoapods" job --- .github/workflows/check.yml | 103 +++++++++++++++++++++--------------- 1 file changed, 60 insertions(+), 43 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index f59deaeb6f..b0842d6011 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -97,6 +97,58 @@ jobs: ruby-version: ${{ env.ruby_version }} bundler-cache: true + cache-cocoapods: + name: iOS Cocoapods + needs: [cache-npm-macos, cache-bundler-macos] + runs-on: macos-11 + outputs: + cache-key: ${{ steps.cocoapods-cache.outputs.cache-primary-key }} + steps: + - run: sudo xcode-select -s /Applications/${{ env.xcode_version }}.app + + - uses: actions/checkout@v3.3.0 + + - name: Extract job definition + run: yq '.jobs.${{ github.job }}' .github/workflows/check.yml > .github/job.yml + + - name: Restore Cocoapods cache + uses: actions/cache/restore@v3 + id: cocoapods-cache + with: + path: ios/Pods + key: ${{ runner.os }}-cocoapods-ruby@${{ env.ruby_version }}-xcode@${{ env.xcode_version }}-${{ hashFiles('**/Podfile.lock', 'package-lock.json', '.github/job.yml') }} + + - if: steps.cocoapods-cache.outputs.cache-hit != 'true' + uses: actions/setup-node@v3 + with: + node-version: ${{ env.node_version }} + + - if: steps.cocoapods-cache.outputs.cache-hit != 'true' + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ env.ruby_version }} + bundler-cache: true + + - name: Restore node_modules cache + if: steps.cocoapods-cache.outputs.cache-hit != 'true' + uses: actions/cache/restore@v3 + id: node-cache + with: + path: node_modules/ + key: ${{ needs.cache-npm-macos.outputs.cache-key }} + + - if: steps.cocoapods-cache.outputs.cache-hit != 'true' && steps.node-cache.outputs.cache-hit != 'true' + run: exit 1 + + - if: steps.cocoapods-cache.outputs.cache-hit != 'true' + run: bundle exec pod install --deployment + working-directory: ./ios + + - uses: actions/cache/save@v3 + with: + path: ios/Pods + key: ${{ steps.cocoapods-cache.outputs.cache-primary-key }} + prettier: name: Prettier needs: [cache-npm-linux] @@ -222,45 +274,6 @@ jobs: - run: npm run bundle-data - ios-pods: - name: iOS Cocoapods - needs: [cache-npm-macos, cache-bundler-macos] - runs-on: macos-11 - steps: - - uses: actions/checkout@v3.3.0 - - - uses: actions/setup-node@v3 - with: - node-version: ${{ env.node_version }} - - - name: Restore node_modules cache - uses: actions/cache/restore@v3 - id: node-cache - with: - path: node_modules/ - key: ${{ needs.cache-npm-macos.outputs.cache-key }} - - - if: steps.node-cache.outputs.cache-hit != 'true' - run: exit 1 - - - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ env.ruby_version }} - bundler-cache: true - - - name: Restore Pods cache - uses: actions/cache@v3 - with: - path: ios/Pods - key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }} - restore-keys: | - ${{ runner.os }}-pods- - - - run: sudo xcode-select -s /Applications/${{ env.xcode_version }}.app - - - run: bundle exec pod install --deployment - working-directory: ./ios - ios-bundle: name: iOS Bundle needs: [cache-npm-linux] @@ -398,12 +411,16 @@ jobs: ruby-version: ${{ env.ruby_version }} bundler-cache: true - - name: Restore Pods cache - uses: actions/cache@v3 + - name: Restore Cocoapods cache + uses: actions/cache/restore@v3 + id: pods-cache with: path: ios/Pods - key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }} - restore-keys: ${{ runner.os }}-pods- + key: ${{ needs.cache-cocoapods.outputs.cache-key }} + + - name: exit if the Cocoapods cache did not load + if: steps.pods-cache.outputs.cache-hit != 'true' + run: exit 1 - uses: mikehardy/buildcache-action@v2 continue-on-error: true From 301f07235a7a56de0c4940ac6485b86402d234b2 Mon Sep 17 00:00:00 2001 From: Hawken Rives Date: Tue, 24 Jan 2023 08:14:24 -0500 Subject: [PATCH 04/12] generate the iOS jsbundle on macos, and cache it for later use --- .github/workflows/check.yml | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index b0842d6011..b6d93f4d88 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -276,11 +276,16 @@ jobs: ios-bundle: name: iOS Bundle - needs: [cache-npm-linux] - runs-on: ubuntu-22.04 + needs: [cache-npm-macos] + runs-on: macos-11 + outputs: + cache-key: ${{ steps.jsbundle-cache.outputs.cache-primary-key }} steps: - uses: actions/checkout@v3.3.0 + - name: Extract job definition + run: yq '.jobs.${{ github.job }}' .github/workflows/check.yml > .github/job.yml + - uses: actions/setup-node@v3 with: node-version: ${{ env.node_version }} @@ -290,14 +295,35 @@ jobs: id: node-cache with: path: node_modules/ - key: ${{ needs.cache-npm-linux.outputs.cache-key }} + key: ${{ needs.cache-npm-macos.outputs.cache-key }} - if: steps.node-cache.outputs.cache-hit != 'true' run: exit 1 - - run: npm run bundle-data + - name: Cache the jsbundle + uses: actions/cache/restore@v3 + id: jsbundle-cache + with: + path: | + ios/AllAboutOlaf/main.jsbundle + ios/AllAboutOlaf/main.jsbundle.map + ios/assets/ + key: ${{ runner.os }}-jsbundle-node@${{ env.node_version }}-${{ hashFiles('package.json', 'package-lock.json', '.github/job.yml','tsconfig.json', 'babel.config.js', 'index.js', 'data/**', 'images/**', 'modules/**.ts', 'modules/**.tsx', 'source/**.ts', 'source/**.tsx') }} - - run: npm run bundle:ios + - name: Generate jsbundle + if: steps.jsbundle-cache.outputs.cache-hit != 'true' + run: | + npm run bundle-data + npm run bundle:ios + + - uses: actions/cache/save@v3 + if: steps.jsbundle-cache.outputs.cache-hit != 'true' + with: + path: | + ios/AllAboutOlaf/main.jsbundle + ios/AllAboutOlaf/main.jsbundle.map + ios/assets/ + key: ${{ steps.jsbundle-cache.outputs.cache-primary-key }} android-bundle: name: Android Bundle From 704ad2d4f9eb67e734c2c9f11fb3bbd92a57316c Mon Sep 17 00:00:00 2001 From: Hawken Rives Date: Tue, 24 Jan 2023 08:15:26 -0500 Subject: [PATCH 05/12] make android-bundle step cache itself like the iOS one does --- .github/workflows/check.yml | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index b6d93f4d88..937b0c4f93 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -329,9 +329,14 @@ jobs: name: Android Bundle needs: [cache-npm-linux] runs-on: ubuntu-22.04 + outputs: + cache-key: ${{ steps.jsbundle-cache.outputs.cache-primary-key }} steps: - uses: actions/checkout@v3.3.0 + - name: Extract job definition + run: yq '.jobs.${{ github.job }}' .github/workflows/check.yml > .github/job.yml + - uses: actions/setup-node@v3 with: node-version: ${{ env.node_version }} @@ -346,11 +351,31 @@ jobs: - if: steps.node-cache.outputs.cache-hit != 'true' run: exit 1 - - run: npm run bundle-data + - name: Restore the jsbundle + uses: actions/cache/restore@v3 + id: jsbundle-cache + with: + path: | + ./android/app/src/main/assets/index.android.bundle + ./android/app/src/main/assets/index.android.bundle.map + ./android/app/src/main/res/ + key: ${{ runner.os }}-npm-node@${{ env.node_version }}-pkg@${{ hashFiles('package.json', 'package-lock.json', '.github/job.yml') }}-files@${{ hashFiles('tsconfig.json', 'babel.config.js', 'index.js', 'data/**', 'images/**', 'modules/**.ts', 'modules/**.tsx', 'source/**.ts', 'source/**.tsx') }} - - run: mkdir -p ./android/app/src/main/assets/ + - name: Generate jsbundle + if: steps.jsbundle-cache.outputs.cache-hit != 'true' + run: | + mkdir -p ./android/app/src/main/assets/ + npm run bundle-data + npm run bundle:android - - run: npm run bundle:android + - name: Cache the jsbundle + uses: actions/cache/restore@v3 + with: + path: | + ./android/app/src/main/assets/index.android.bundle + ./android/app/src/main/assets/index.android.bundle.map + ./android/app/src/main/res/ + key: ${{ steps.jsbundle-cache.outputs.cache-primary-key }} android: name: Build for Android From c4f0333332fdf999b8b95916433a108165d3bcb9 Mon Sep 17 00:00:00 2001 From: Hawken Rives Date: Tue, 24 Jan 2023 08:19:05 -0500 Subject: [PATCH 06/12] rework the iOS build phase 1. split up the "build app" and "detox app" tasks into two jobs 2. during detox, insert the cached jsbundle into the compiled app 3. only recompile the app on an Xcode, project, package-lock, or podfile.lock change --- .github/workflows/check.yml | 98 +++++++++++++++++++++++++++++++++---- 1 file changed, 89 insertions(+), 9 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 937b0c4f93..82e1a7cc7d 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -436,33 +436,52 @@ jobs: SENTRY_AUTH_TOKEN: ${{ secrets.HOSTED_SENTRY_AUTH_TOKEN }} GITHUB_KEYS_REPOSITORY_TOKEN: ${{ secrets.GITHUB_KEYS_REPOSITORY_TOKEN }} - ios: + ios-build: name: Build for iOS - needs: [jest, eslint, ios-bundle, ios-pods, cache-npm-macos, cache-bundler-macos] + needs: [jest, eslint, cache-cocoapods, cache-npm-macos, cache-bundler-macos] runs-on: macos-11 + outputs: + cache-key: ${{ steps.app-cache.outputs.cache-primary-key }} steps: + - run: sudo xcode-select -s /Applications/${{ env.xcode_version }}.app + - uses: actions/checkout@v3.3.0 + - name: Extract job definition + run: yq '.jobs.${{ github.job }}' .github/workflows/check.yml > .github/job.yml + + - name: Check for cached iOS app + id: app-cache + uses: actions/cache/restore@v3 + with: + path: ios/build/Build/Products/ + key: ${{ runner.os }}-ios-xcode@${{ env.xcode_version }}-${{ hashFiles('**/project.pbxproj', '**/Podfile.lock', 'package-lock.json', '.github/job.yml') }} + - uses: actions/setup-node@v3 + if: steps.app-cache.outputs.cache-hit != 'true' with: node-version: ${{ env.node_version }} - name: Restore node_modules cache + if: steps.app-cache.outputs.cache-hit != 'true' uses: actions/cache/restore@v3 id: node-cache with: path: node_modules/ key: ${{ needs.cache-npm-macos.outputs.cache-key }} - - if: steps.node-cache.outputs.cache-hit != 'true' + - name: exit if the node_modules cache did not load + if: steps.app-cache.outputs.cache-hit != 'true' && steps.node-cache.outputs.cache-hit != 'true' run: exit 1 - uses: ruby/setup-ruby@v1 + if: steps.app-cache.outputs.cache-hit != 'true' with: ruby-version: ${{ env.ruby_version }} bundler-cache: true - name: Restore Cocoapods cache + if: steps.app-cache.outputs.cache-hit != 'true' uses: actions/cache/restore@v3 id: pods-cache with: @@ -470,23 +489,84 @@ jobs: key: ${{ needs.cache-cocoapods.outputs.cache-key }} - name: exit if the Cocoapods cache did not load - if: steps.pods-cache.outputs.cache-hit != 'true' + if: steps.app-cache.outputs.cache-hit != 'true' && steps.pods-cache.outputs.cache-hit != 'true' run: exit 1 - uses: mikehardy/buildcache-action@v2 + if: steps.app-cache.outputs.cache-hit != 'true' continue-on-error: true with: cache_key: ${{ matrix.os }} + - name: Build the iOS app + if: steps.app-cache.outputs.cache-hit != 'true' + run: npx detox build e2e --configuration ios.sim.release + + - name: Cache the iOS app + uses: actions/cache/save@v3 + with: + path: ios/build/Build/Products/ + key: ${{ steps.app-cache.outputs.cache-primary-key }} + + ios-detox: + name: Detox E2E for iOS + needs: [cache-npm-macos, ios-build, ios-bundle] + runs-on: macos-11 + steps: - run: sudo xcode-select -s /Applications/${{ env.xcode_version }}.app - - run: bundle exec pod install --deployment - working-directory: ./ios + - uses: actions/checkout@v3.3.0 + + - # load the app before reinstalling detox, so that the package-lock cannot change + name: Load the cached iOS app + uses: actions/cache/restore@v3 + id: app-cache + with: + path: ios/build/Build/Products/ + key: ${{ needs.ios-build.outputs.cache-key }} + + - if: steps.app-cache.outputs.cache-hit != 'true' + run: exit 1 + + - # load the jsbundle before reinstalling detox, so that the package-lock cannot change + name: Load the cached iOS jsbundle + uses: actions/cache/restore@v3 + id: jsbundle-cache + with: + path: | + ios/AllAboutOlaf/main.jsbundle + ios/AllAboutOlaf/main.jsbundle.map + ios/assets/ + key: ${{ needs.ios-bundle.outputs.cache-key }} + + - if: steps.jsbundle-cache.outputs.cache-hit != 'true' + run: exit 1 + + - name: Move cached jsbundle into place + run: | + mv ios/AllAboutOlaf/main.jsbundle ios/build/Build/Products/Release-iphonesimulator/AllAboutOlaf.app/ + mv ios/AllAboutOlaf/main.jsbundle.map ios/build/Build/Products/Release-iphonesimulator/AllAboutOlaf.app/ + rm -rf ios/build/Build/Products/Release-iphonesimulator/AllAboutOlaf.app/assets + mv ios/assets ios/build/Build/Products/Release-iphonesimulator/AllAboutOlaf.app/ + + - uses: actions/setup-node@v3 + with: + node-version: ${{ env.node_version }} + + - name: Restore node_modules cache + uses: actions/cache/restore@v3 + id: node-cache + with: + path: node_modules/ + key: ${{ needs.cache-npm-macos.outputs.cache-key }} + + - # We have to poke Detox because it installs things outside of node_modules/detox/… + name: Re-install Detox + run: npx detox clean-framework-cache && npx detox build-framework-cache - run: brew tap wix/brew - run: brew install applesimutils - - run: npx detox build e2e --configuration ios.sim.release - - - run: npx detox test e2e --configuration ios.sim.release --cleanup --debug-synchronization 500 + - name: Run the Detox tests + run: npx detox test e2e --configuration ios.sim.release --cleanup --debug-synchronization 500 From 916374c757c96191ab75c442fd370d353a435ba6 Mon Sep 17 00:00:00 2001 From: Hawken Rives Date: Tue, 24 Jan 2023 09:25:26 -0500 Subject: [PATCH 07/12] fix caching of the android jsbundle --- .github/workflows/check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 82e1a7cc7d..c3ad20b9da 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -369,7 +369,7 @@ jobs: npm run bundle:android - name: Cache the jsbundle - uses: actions/cache/restore@v3 + uses: actions/cache/save@v3 with: path: | ./android/app/src/main/assets/index.android.bundle From 11f8928579d898b685956b114823f98213a17971 Mon Sep 17 00:00:00 2001 From: Hawken Rives Date: Tue, 24 Jan 2023 09:25:33 -0500 Subject: [PATCH 08/12] add some better job names to the jsbundle tasks --- .github/workflows/check.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index c3ad20b9da..a24dba54d0 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -300,7 +300,7 @@ jobs: - if: steps.node-cache.outputs.cache-hit != 'true' run: exit 1 - - name: Cache the jsbundle + - name: Load the cached jsbundle uses: actions/cache/restore@v3 id: jsbundle-cache with: @@ -316,7 +316,8 @@ jobs: npm run bundle-data npm run bundle:ios - - uses: actions/cache/save@v3 + - name: Cache the jsbundle + uses: actions/cache/save@v3 if: steps.jsbundle-cache.outputs.cache-hit != 'true' with: path: | @@ -351,7 +352,7 @@ jobs: - if: steps.node-cache.outputs.cache-hit != 'true' run: exit 1 - - name: Restore the jsbundle + - name: Load the cached jsbundle uses: actions/cache/restore@v3 id: jsbundle-cache with: From 6c4bdd441dc8ba568cec1c071173150779f8129a Mon Sep 17 00:00:00 2001 From: Hawken Rives Date: Tue, 24 Jan 2023 18:00:59 -0500 Subject: [PATCH 09/12] remove --debug-synchronization flag from detox-test --- .github/workflows/check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index a24dba54d0..0df5e51788 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -570,4 +570,4 @@ jobs: - run: brew install applesimutils - name: Run the Detox tests - run: npx detox test e2e --configuration ios.sim.release --cleanup --debug-synchronization 500 + run: npx detox test e2e --configuration ios.sim.release --cleanup From f3558cf877811b4682b322b0a54efe0c83fc3db0 Mon Sep 17 00:00:00 2001 From: Hawken Rives Date: Tue, 24 Jan 2023 18:06:54 -0500 Subject: [PATCH 10/12] upload detox stuff as artifacts --- .github/workflows/check.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 0df5e51788..6ab61a6ad1 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -570,4 +570,10 @@ jobs: - run: brew install applesimutils - name: Run the Detox tests - run: npx detox test e2e --configuration ios.sim.release --cleanup + run: npx detox test e2e --configuration ios.sim.release --cleanup --record-logs failing --record-videos failing --record-performance all --capture-view-hierarchy enabled --take-screenshots failing + + - uses: actions/upload-artifact@v3 + if: always() + with: + name: detox-ios + path: artifacts/ From 5e4d3a4e8a53cf7d7e385b12b7083044d98b8431 Mon Sep 17 00:00:00 2001 From: Hawken Rives Date: Tue, 24 Jan 2023 18:12:40 -0500 Subject: [PATCH 11/12] add a missing space in the function call --- .github/workflows/check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 6ab61a6ad1..199a0d6346 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -308,7 +308,7 @@ jobs: ios/AllAboutOlaf/main.jsbundle ios/AllAboutOlaf/main.jsbundle.map ios/assets/ - key: ${{ runner.os }}-jsbundle-node@${{ env.node_version }}-${{ hashFiles('package.json', 'package-lock.json', '.github/job.yml','tsconfig.json', 'babel.config.js', 'index.js', 'data/**', 'images/**', 'modules/**.ts', 'modules/**.tsx', 'source/**.ts', 'source/**.tsx') }} + key: ${{ runner.os }}-jsbundle-node@${{ env.node_version }}-${{ hashFiles('package.json', 'package-lock.json', '.github/job.yml', 'tsconfig.json', 'babel.config.js', 'index.js', 'data/**', 'images/**', 'modules/**.ts', 'modules/**.tsx', 'source/**.ts', 'source/**.tsx') }} - name: Generate jsbundle if: steps.jsbundle-cache.outputs.cache-hit != 'true' From 6f0469494c099705dcbbfd6d3ec6b4a6844e71ad Mon Sep 17 00:00:00 2001 From: Hawken Rives Date: Tue, 24 Jan 2023 18:19:43 -0500 Subject: [PATCH 12/12] don't save to the cache if we downloaded from the cache --- .github/workflows/check.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 199a0d6346..b029eddc56 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -40,6 +40,7 @@ jobs: run: npm ci - uses: actions/cache/save@v3 + if: steps.node-cache.outputs.cache-hit != 'true' with: path: node_modules/ key: ${{ steps.node-cache.outputs.cache-primary-key }} @@ -71,6 +72,7 @@ jobs: run: npm ci - uses: actions/cache/save@v3 + if: steps.node-cache.outputs.cache-hit != 'true' with: path: node_modules/ key: ${{ steps.node-cache.outputs.cache-primary-key }} @@ -144,7 +146,9 @@ jobs: run: bundle exec pod install --deployment working-directory: ./ios - - uses: actions/cache/save@v3 + - name: Save Cocoapods cache + uses: actions/cache/save@v3 + if: steps.cocoapods-cache.outputs.cache-hit != 'true' with: path: ios/Pods key: ${{ steps.cocoapods-cache.outputs.cache-primary-key }} @@ -370,6 +374,7 @@ jobs: npm run bundle:android - name: Cache the jsbundle + if: steps.jsbundle-cache.outputs.cache-hit != 'true' uses: actions/cache/save@v3 with: path: |