7
7
branches : [master]
8
8
9
9
jobs :
10
+ prepare :
11
+ runs-on : macos-latest
12
+ name : " Prepare"
13
+ steps :
14
+ - name : Checkout code
15
+ uses : actions/checkout@v2
16
+
17
+ - name : Use Node.js 14
18
+ uses : actions/setup-node@v1
19
+ with :
20
+ node-version : 14
21
+
22
+ - name : Cache node_modules
23
+ uses : actions/cache@v2
24
+ with :
25
+ path : ~/.npm
26
+ key : node_modules-${{ hashFiles('**/package-lock.json') }}
27
+ restore-keys : node_modules-
28
+
29
+ - name : Install node_modules
30
+ run : |
31
+ npm ci --prefer-offline --no-audit
32
+
10
33
android :
34
+ needs : prepare
11
35
runs-on : macos-latest
12
36
env :
13
- CI : 1
14
- strategy :
15
- matrix :
16
- android-api : [28]
17
- android-target : [default]
18
- node-version : [12, 14]
19
- name : " Matrix: Node v${{ matrix.node-version }}; Android API ${{ matrix.android-api }}"
37
+ REACT_NATIVE_VERSION : " 0.63.4"
38
+ name : " Android"
20
39
steps :
21
40
- name : Checkout code
22
41
uses : actions/checkout@v2
23
42
24
- - name : Set up Node.js ${{ matrix.node-version }}
43
+ - name : Set up Node.js 14
25
44
uses : actions/setup-node@v1
26
45
with :
27
- node-version : ${{ matrix.node-version }}
46
+ node-version : 14
28
47
29
48
- name : Cache node_modules
30
49
uses : actions/cache@v2
31
50
with :
32
51
path : ~/.npm
33
- key : ${{ runner.os }}-npm-${{ matrix.node-version }} -${{ hashFiles('**/package-lock.json') }}
34
- restore-keys : ${{ runner.os }}-npm -
52
+ key : node_modules -${{ hashFiles('**/package-lock.json') }}
53
+ restore-keys : node_modules -
35
54
36
55
- name : Install node_modules
37
56
run : |
@@ -41,41 +60,58 @@ jobs:
41
60
run : |
42
61
npm run lint
43
62
63
+ - name : Cache Android build
64
+ uses : actions/cache@v2
65
+ with :
66
+ path : |
67
+ ~/.gradle/caches
68
+ ~/.gradle/wrapper
69
+ ~/.android/build-cache
70
+ key : ${{ runner.os }}-gradle-rn-${{ env.REACT_NATIVE_VERSION }}
71
+
72
+ - name : Inject test app path into a job-wide environment variable
73
+ run : |
74
+ DIR=~/rn-android-test-app
75
+ echo "REACT_NATIVE_TEST_APP=$DIR" >> $GITHUB_ENV
76
+
77
+ - name : Cache React Native test app
78
+ uses : actions/cache@v2
79
+ with :
80
+ path : ${{ env.REACT_NATIVE_TEST_APP }}
81
+ key : ${{ runner.os }}-rn-android-${{ env.REACT_NATIVE_VERSION }}
82
+
44
83
- name : Run Android tests
45
84
uses : reactivecircus/android-emulator-runner@v2
46
85
with :
47
- api-level : ${{ matrix.android-api }}
48
- target : ${{ matrix.android-target }}
86
+ api-level : 28
87
+ target : default
49
88
arch : x86_64
50
89
profile : pixel
51
- avd-name : pixel-${{ matrix.android-api }}
90
+ avd-name : google-pixel
52
91
script : |
53
- ./run-tests.js --platform android --emulator pixel-${{ matrix.android-api }} test/index.js"
92
+ ./run-tests.js --platform android test/index.js
54
93
55
94
ios :
95
+ needs : prepare
56
96
runs-on : macos-latest
57
97
env :
58
- CI : 1
59
- strategy :
60
- matrix :
61
- apple-runtime : ["iOS 14.2"]
62
- node-version : [12, 14]
63
- name : " Matrix: Node v${{ matrix.node-version }}; ${{ matrix.apple-runtime }}"
98
+ REACT_NATIVE_VERSION : " 0.62.0"
99
+ name : " iOS"
64
100
steps :
65
101
- name : Checkout code
66
102
uses : actions/checkout@v2
67
103
68
- - name : Set up Node.js ${{ matrix.node-version }}
104
+ - name : Set up Node.js 14
69
105
uses : actions/setup-node@v1
70
106
with :
71
- node-version : ${{ matrix.node-version }}
107
+ node-version : 14
72
108
73
109
- name : Cache node_modules
74
110
uses : actions/cache@v2
75
111
with :
76
112
path : ~/.npm
77
- key : ${{ runner.os }}-npm-${{ matrix.node-version }} -${{ hashFiles('**/package-lock.json') }}
78
- restore-keys : ${{ runner.os }}-npm -
113
+ key : node_modules -${{ hashFiles('**/package-lock.json') }}
114
+ restore-keys : node_modules -
79
115
80
116
- name : Install node_modules
81
117
run : |
@@ -85,17 +121,50 @@ jobs:
85
121
run : |
86
122
npm run lint
87
123
124
+ # - name: List environment capabilities
125
+ # run: |
126
+ # xcversion --version
127
+ # xcodebuild -version
128
+ # xcrun simctl list
129
+ # xcversion select 12.1
130
+
88
131
- name : Create and run iOS simulator
132
+ id : setup-ios-simulator
89
133
run : |
90
- SIMULATOR_RUNTIME=$(echo "${{ matrix.apple-runtime }} " | sed 's/[ \.]/-/g')
134
+ SIMULATOR_RUNTIME=$(echo "iOS 14.4 " | sed 's/[ \.]/-/g')
91
135
SIMULATOR_ID=$(xcrun simctl create "iPhone 11" com.apple.CoreSimulator.SimDeviceType.iPhone-11 com.apple.CoreSimulator.SimRuntime.$SIMULATOR_RUNTIME)
92
- echo "IOS_SIMULATOR= $SIMULATOR_ID" >> $GITHUB_ENV
136
+ echo "::set-output name=simulator_id:: $SIMULATOR_ID"
93
137
xcrun simctl boot $SIMULATOR_ID &
94
138
139
+ - name : Cache iOS build
140
+ uses : actions/cache@v2
141
+ with :
142
+ path : ~/Library/Developer/Xcode/DerivedData/Test-*
143
+ key : ${{ runner.os }}-xcodebuild-rn-${{ env.REACT_NATIVE_VERSION }}
144
+
145
+ - name : Cache pods and repositories
146
+ uses : actions/cache@v2
147
+ with :
148
+ path : |
149
+ ~/Library/Caches/CocoaPods
150
+ ~/.cocoapods
151
+ key : ${{ runner.os }}-cocoapods-rn-${{ env.REACT_NATIVE_VERSION }}
152
+
153
+ - name : Inject test app path into a job-wide environment variable
154
+ run : |
155
+ DIR=~/rn-ios-test-app
156
+ echo "REACT_NATIVE_TEST_APP=$DIR" >> $GITHUB_ENV
157
+
158
+ - name : Cache React Native test app
159
+ uses : actions/cache@v2
160
+ with :
161
+ path : ${{ env.REACT_NATIVE_TEST_APP }}
162
+ key : ${{ runner.os }}-rn-ios-${{ env.REACT_NATIVE_VERSION }}
163
+
95
164
- name : Run iOS tests
96
165
run : |
97
- ./run-tests.js --platform ios --simulator $IOS_SIMULATOR test/index.js
166
+ ./run-tests.js --platform ios --rn ${{ env.REACT_NATIVE_VERSION }} test/index.js
98
167
99
168
- name : Shutdown iOS simulator
100
169
run : |
101
- xcrun simctl shutdown $IOS_SIMULATOR
170
+ xcrun simctl shutdown ${{ steps.setup-ios-simulator.outputs.simulator_id }}
0 commit comments