Skip to content

Commit 46556de

Browse files
committed
test(e2e, ios): use ccache, cache metro, skip firebase-tools install
- ccache merged ivsoverlay support and beats buildcache now, use it - metro cache handles bundler so bundle precompile is lightning - firebase-tools is installed by yarn, no need to install it separately + slowly via npm
1 parent 9d6fbd2 commit 46556de

File tree

3 files changed

+91
-90
lines changed

3 files changed

+91
-90
lines changed

.github/workflows/tests_e2e_android.yml

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,40 @@ jobs:
3737
with:
3838
fetch-depth: 50
3939

40+
# Set up tool versions
4041
- uses: actions/setup-node@v2
4142
with:
4243
node-version: '14'
43-
- name: Install firebase CLI
44+
45+
- name: Configure JDK 1.11
46+
uses: actions/setup-java@v2
47+
with:
48+
distribution: 'adopt'
49+
java-version: '11' # ubuntu-latest is about to default to 11, force it everywhere
50+
51+
# Set path variables needed for caches
52+
- name: Set workflow variables
53+
id: workflow-variables
54+
run: |
55+
echo "::set-output name=metro-cache::$HOME/.metro"
56+
echo "::set-output name=yarn-cache-dir::$(yarn cache dir)"
57+
echo "::set-output name=tempdir::$TMPDIR"
58+
59+
- uses: actions/cache@v2
60+
name: Yarn Cache
61+
id: yarn-cache
62+
with:
63+
path: ${{ steps.workflow-variables.outputs.yarn-cache-dir }}
64+
key: ${{ runner.os }}-yarn-v1-${{ hashFiles('**/package.json') }}
65+
restore-keys: ${{ runner.os }}-yarn-v1
66+
67+
- name: Yarn Install
4468
uses: nick-invision/retry@v2
4569
with:
4670
timeout_minutes: 10
4771
retry_wait_seconds: 60
4872
max_attempts: 3
49-
command: npm i -g firebase-tools
73+
command: DETOX_DISABLE_POSTINSTALL=1 yarn --no-audit --prefer-offline
5074

5175
- name: Cache Firestore Emulator
5276
uses: actions/cache@v2
@@ -58,45 +82,13 @@ jobs:
5882
- name: Start Firestore Emulator
5983
run: yarn tests:emulator:start-ci
6084

61-
- name: Get yarn cache directory path
62-
id: yarn-cache-dir-path
63-
run: echo "::set-output name=dir::$(yarn cache dir)"
64-
65-
- uses: actions/cache@v2
66-
name: Yarn Cache
67-
id: yarn-cache
68-
with:
69-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
70-
key: ${{ runner.os }}-yarn-v1-${{ hashFiles('**/package.json') }}
71-
restore-keys: ${{ runner.os }}-yarn-v1
72-
7385
- uses: actions/cache@v2
7486
name: Gradle Cache
7587
with:
7688
path: ~/.gradle/caches
7789
key: ${{ runner.os }}-gradle-v1-${{ hashFiles('**/*.gradle*') }}
7890
restore-keys: ${{ runner.os }}-gradle-v1
7991

80-
- name: Yarn Install
81-
uses: nick-invision/retry@v2
82-
with:
83-
timeout_minutes: 10
84-
retry_wait_seconds: 60
85-
max_attempts: 3
86-
command: DETOX_DISABLE_POSTINSTALL=1 yarn --no-audit --prefer-offline
87-
88-
- name: Configure JDK 1.11
89-
uses: actions/setup-java@v2
90-
with:
91-
distribution: 'adopt'
92-
java-version: '11' # ubuntu-latest is about to default to 11, force it everywhere
93-
94-
- name: Verify JDK11
95-
# Default JDK varies depending on different runner flavors, make sure we are on 11
96-
# Run a check that exits with error unless it is 11 version to future-proof against unexpected upgrades
97-
run: java -fullversion 2>&1 | grep '11.0'
98-
shell: bash
99-
10092
- name: Build Android App
10193
uses: nick-invision/retry@v2
10294
with:
@@ -105,10 +97,17 @@ jobs:
10597
max_attempts: 3
10698
command: cd tests/android && ./gradlew assembleDebug assembleAndroidTest lintDebug -DtestBuildType=debug -Dorg.gradle.daemon=false
10799

100+
- name: Metro Bundler Cache
101+
uses: actions/cache@v2
102+
with:
103+
path: ${{ steps.workflow-variables.outputs.metro-cache }}
104+
key: ${{ runner.os }}-metro-v1-${{ github.run_id }}
105+
restore-keys: ${{ runner.os }}-metro-v1
106+
108107
- name: Pre-fetch Javascript bundle
109108
# Prebuild the bundle so that's fast when the app starts.
110109
run: |
111-
nohup yarn tests:packager:jet &
110+
nohup yarn tests:packager:jet-ci &
112111
printf 'Waiting for packager to come online'
113112
until curl --output /dev/null --silent --head --fail http://localhost:8081/status; do
114113
printf '.'

.github/workflows/tests_e2e_ios.yml

Lines changed: 56 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,7 @@ jobs:
3232
with:
3333
all_but_latest: true
3434

35-
- uses: actions/checkout@v2
36-
with:
37-
fetch-depth: 50
38-
39-
- uses: mikehardy/buildcache-action@v1
40-
name: Buildcache
41-
with:
42-
cache_key: ${{ runner.os }}-v1
43-
upload_buildcache_log: true
44-
35+
# Set up tool versions
4536
- uses: actions/setup-node@v2
4637
with:
4738
node-version: 14
@@ -50,54 +41,39 @@ jobs:
5041
with:
5142
xcode-version: latest-stable
5243

53-
- name: Get Xcode version
54-
id: xcode-version
55-
run: echo "::set-output name=xcode-version::$(xcodebuild -version|tail -1|cut -f3 -d' ')"
56-
57-
- name: Install firebase CLI
58-
uses: nick-invision/retry@v2
59-
with:
60-
timeout_minutes: 10
61-
retry_wait_seconds: 60
62-
max_attempts: 3
63-
command: npm i -g firebase-tools
64-
65-
- name: Cache Firestore Emulator
66-
uses: actions/cache@v2
44+
- uses: actions/checkout@v2
6745
with:
68-
path: ~/.cache/firebase/emulators
69-
key: firebase-emulators-v1-${{ github.run_id }}
70-
restore-keys: firebase-emulators-v1
71-
72-
- name: Start Firestore Emulator
73-
run: yarn tests:emulator:start-ci
46+
fetch-depth: 50
7447

75-
- name: Get yarn cache directory path
76-
id: yarn-cache-dir-path
77-
run: echo "::set-output name=dir::$(yarn cache dir)"
48+
# Set path variables needed for caches
49+
- name: Set workflow variables
50+
id: workflow-variables
51+
run: |
52+
echo "::set-output name=metro-cache::$HOME/.metro"
53+
echo "::set-output name=xcode-version::$(xcodebuild -version|tail -1|cut -f3 -d' ')"
54+
echo "::set-output name=yarn-cache-dir::$(yarn cache dir)"
7855
7956
- uses: actions/cache@v2
8057
name: Yarn Cache
8158
id: yarn-cache
8259
with:
83-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
60+
path: ${{ steps.workflow-variables.outputs.yarn-cache-dir }}
8461
key: ${{ runner.os }}-yarn-v1-${{ hashFiles('**/package.json') }}
8562
restore-keys: ${{ runner.os }}-yarn-v1
8663

87-
- uses: actions/cache@v2
88-
name: Cache Pods
89-
id: pods-cache
90-
with:
91-
path: tests/ios/Pods
92-
key: ${{ runner.os }}-pods-v2-${{ hashFiles('**/Podfile.lock') }}
93-
restore-keys: ${{ runner.os }}-pods-v2
94-
9564
- uses: actions/cache@v2
9665
name: Detox Framework Cache
9766
id: detox-cache
9867
with:
9968
path: ~/Library/Detox/ios
100-
key: ${{ runner.os }}-detox-framework-cache-${{ steps.xcode-version.outputs.xcode-version }}
69+
key: ${{ runner.os }}-detox-framework-cache-${{ steps.workflow-variables.outputs.xcode-version }}
70+
71+
# Detox is compiled during yarn install, using Xcode, set up cache first
72+
- uses: hendrikmuhs/ccache-action@v1
73+
name: Xcode Compile Cache
74+
with:
75+
key: ${{ runner.os }}-v2 # makes a unique key w/related restore key internally
76+
max-size: 400M
10177

10278
- name: Yarn Install
10379
uses: nick-invision/retry@v2
@@ -110,39 +86,71 @@ jobs:
11086
- name: Update Ruby build tools
11187
uses: nick-invision/retry@v2
11288
with:
113-
timeout_minutes: 10
89+
timeout_minutes: 2
11490
retry_wait_seconds: 60
11591
max_attempts: 3
11692
command: gem update cocoapods xcodeproj
11793

94+
- uses: actions/cache@v2
95+
name: Cache Pods
96+
id: pods-cache
97+
with:
98+
path: tests/ios/Pods
99+
key: ${{ runner.os }}-pods-v2-${{ hashFiles('**/Podfile.lock') }}
100+
restore-keys: ${{ runner.os }}-pods-v2
101+
118102
- name: Pod Install
119103
uses: nick-invision/retry@v2
120104
with:
121-
timeout_minutes: 10
105+
timeout_minutes: 2
122106
retry_wait_seconds: 60
123107
max_attempts: 3
124108
command: yarn tests:ios:pod:install
125109

110+
- name: Cache Firestore Emulator
111+
uses: actions/cache@v2
112+
with:
113+
path: ~/.cache/firebase/emulators
114+
key: firebase-emulators-v1-${{ github.run_id }}
115+
restore-keys: firebase-emulators-v1
116+
117+
- name: Start Firestore Emulator
118+
run: yarn tests:emulator:start-ci
119+
126120
- name: Build iOS App
127121
run: |
122+
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
123+
export CCACHE_SLOPPINESS=clang_index_store,file_stat_matches,include_file_ctime,include_file_mtime,ivfsoverlay,pch_defines,modules,system_headers,time_macros
124+
export CCACHE_FILECLONE=true
125+
export CCACHE_DEPEND=true
126+
export CCACHE_INODECACHE=true
127+
ccache -s
128128
export SKIP_BUNDLING=1
129129
export RCT_NO_LAUNCH_PACKAGER=1
130130
cd tests
131131
set -o pipefail
132132
./node_modules/.bin/detox build --configuration ios.sim.debug
133+
ccache -s
133134
shell: bash
134135

135136
- name: Install applesimutils
136137
uses: nick-invision/retry@v2
137138
with:
138-
timeout_minutes: 10
139+
timeout_minutes: 5
139140
retry_wait_seconds: 60
140141
max_attempts: 3
141142
command: HOMEBREW_NO_AUTO_UPDATE=1 brew tap wix/brew && HOMEBREW_NO_AUTO_UPDATE=1 brew install applesimutils && applesimutils --list
142143

144+
- name: Metro Bundler Cache
145+
uses: actions/cache@v2
146+
with:
147+
path: ${{ steps.workflow-variables.outputs.metro-cache }}
148+
key: ${{ runner.os }}-metro-v1-${{ github.run_id }}
149+
restore-keys: ${{ runner.os }}-metro-v1
150+
143151
- name: Pre-fetch Javascript bundle
144152
run: |
145-
nohup yarn tests:packager:jet &
153+
nohup yarn tests:packager:jet-ci &
146154
printf 'Waiting for packager to come online'
147155
until curl --output /dev/null --silent --head --fail http://localhost:8081/status; do
148156
printf '.'
@@ -159,18 +167,11 @@ jobs:
159167
run: nohup sh -c "sleep 30 && xcrun simctl spawn booted log stream --level debug --style compact > simulator.log 2>&1 &"
160168

161169
- name: Detox Test
162-
timeout-minutes: 40
170+
timeout-minutes: 10
163171
run: |
164172
cd tests
165173
./node_modules/.bin/nyc ./node_modules/.bin/detox test --debug-synchronization 200 --configuration ios.sim.debug
166174
167-
- name: Upload Buildcache Log
168-
uses: actions/upload-artifact@v2
169-
if: always()
170-
with:
171-
name: buildcache_log
172-
path: ./.buildcache/buildcache.log
173-
174175
- name: Compress Simulator Log
175176
if: always()
176177
run: gzip -9 simulator.log

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"tests:jest-coverage": "jest --coverage",
2121
"tests:packager:chrome": "cd tests && node_modules/.bin/react-native start --reset-cache",
2222
"tests:packager:jet": "cd tests && cross-env REACT_DEBUGGER=\"echo nope\" node_modules/.bin/react-native start --no-interactive",
23+
"tests:packager:jet-ci": "cd tests && cross-env TMPDIR=$HOME/.metro REACT_DEBUGGER=\"echo nope\" node_modules/.bin/react-native start --no-interactive",
2324
"tests:packager:jet-reset-cache": "cd tests && cross-env REACT_DEBUGGER=\"echo nope\" node_modules/.bin/react-native start --reset-cache --no-interactive",
2425
"tests:emulator:start": "cd ./.github/workflows/scripts && ./start-firebase-emulator.sh --no-daemon",
2526
"tests:emulator:start-ci": "cd ./.github/workflows/scripts && ./start-firebase-emulator.sh",

0 commit comments

Comments
 (0)