Skip to content

Commit 380a42e

Browse files
committed
chore: add ci
1 parent 321d0d8 commit 380a42e

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed

.github/workflows/node-ci.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Node CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
android:
11+
runs-on: macos-latest
12+
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 }}"
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v2
23+
24+
- name: Set up Node.js ${{ matrix.node-version }}
25+
uses: actions/setup-node@v1
26+
with:
27+
node-version: ${{ matrix.node-version }}
28+
29+
- name: Cache node_modules
30+
uses: actions/cache@v2
31+
with:
32+
path: ~/.npm
33+
key: ${{ runner.os }}-npm-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
34+
restore-keys: ${{ runner.os }}-npm-
35+
36+
- name: Install node_modules
37+
run: |
38+
npm ci --prefer-offline --no-audit
39+
40+
- name: Lint
41+
run: |
42+
npm run lint
43+
44+
- name: Run Android tests
45+
uses: reactivecircus/android-emulator-runner@v2
46+
with:
47+
api-level: ${{ matrix.android-api }}
48+
target: ${{ matrix.android-target }}
49+
arch: x86_64
50+
profile: pixel
51+
avd-name: pixel-${{ matrix.android-api }}
52+
script: |
53+
./run-tests.js --platform android --emulator pixel-${{ matrix.android-api }} test/index.js"
54+
55+
ios:
56+
runs-on: macos-latest
57+
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 }}"
64+
steps:
65+
- name: Checkout code
66+
uses: actions/checkout@v2
67+
68+
- name: Set up Node.js ${{ matrix.node-version }}
69+
uses: actions/setup-node@v1
70+
with:
71+
node-version: ${{ matrix.node-version }}
72+
73+
- name: Cache node_modules
74+
uses: actions/cache@v2
75+
with:
76+
path: ~/.npm
77+
key: ${{ runner.os }}-npm-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
78+
restore-keys: ${{ runner.os }}-npm-
79+
80+
- name: Install node_modules
81+
run: |
82+
npm ci --prefer-offline --no-audit
83+
84+
- name: Lint
85+
run: |
86+
npm run lint
87+
88+
- name: Create and run iOS simulator
89+
run: |
90+
SIMULATOR_RUNTIME=$(echo "${{ matrix.apple-runtime }}" | sed 's/[ \.]/-/g')
91+
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
93+
xcrun simctl boot $SIMULATOR_ID &
94+
95+
- name: Run iOS tests
96+
run: |
97+
./run-tests.js --platform ios --simulator $IOS_SIMULATOR test/index.js
98+
99+
- name: Shutdown iOS simulator
100+
run: |
101+
xcrun simctl shutdown $IOS_SIMULATOR

0 commit comments

Comments
 (0)