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