Skip to content

Commit 8903bb7

Browse files
committed
chore: fix iOS workflow and add cache to CI
1 parent 42c5bc5 commit 8903bb7

File tree

5 files changed

+20712
-1376
lines changed

5 files changed

+20712
-1376
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ insert_final_newline = true
1313
indent_size = 2
1414

1515
[{*.md,*.snap}]
16-
trim_trailing_whitespace = false
16+
trim_trailing_whitespace = false

.github/workflows/node-ci.yml

Lines changed: 98 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,50 @@ on:
77
branches: [master]
88

99
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+
1033
android:
34+
needs: prepare
1135
runs-on: macos-latest
1236
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"
2039
steps:
2140
- name: Checkout code
2241
uses: actions/checkout@v2
2342

24-
- name: Set up Node.js ${{ matrix.node-version }}
43+
- name: Set up Node.js 14
2544
uses: actions/setup-node@v1
2645
with:
27-
node-version: ${{ matrix.node-version }}
46+
node-version: 14
2847

2948
- name: Cache node_modules
3049
uses: actions/cache@v2
3150
with:
3251
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-
3554

3655
- name: Install node_modules
3756
run: |
@@ -41,41 +60,58 @@ jobs:
4160
run: |
4261
npm run lint
4362
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+
4483
- name: Run Android tests
4584
uses: reactivecircus/android-emulator-runner@v2
4685
with:
47-
api-level: ${{ matrix.android-api }}
48-
target: ${{ matrix.android-target }}
86+
api-level: 28
87+
target: default
4988
arch: x86_64
5089
profile: pixel
51-
avd-name: pixel-${{ matrix.android-api }}
90+
avd-name: google-pixel
5291
script: |
53-
./run-tests.js --platform android --emulator pixel-${{ matrix.android-api }} test/index.js"
92+
./run-tests.js --platform android test/index.js
5493
5594
ios:
95+
needs: prepare
5696
runs-on: macos-latest
5797
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"
64100
steps:
65101
- name: Checkout code
66102
uses: actions/checkout@v2
67103

68-
- name: Set up Node.js ${{ matrix.node-version }}
104+
- name: Set up Node.js 14
69105
uses: actions/setup-node@v1
70106
with:
71-
node-version: ${{ matrix.node-version }}
107+
node-version: 14
72108

73109
- name: Cache node_modules
74110
uses: actions/cache@v2
75111
with:
76112
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-
79115

80116
- name: Install node_modules
81117
run: |
@@ -85,17 +121,50 @@ jobs:
85121
run: |
86122
npm run lint
87123
124+
# - name: List environment capabilities
125+
# run: |
126+
# xcversion --version
127+
# xcodebuild -version
128+
# xcrun simctl list
129+
# xcversion select 12.1
130+
88131
- name: Create and run iOS simulator
132+
id: setup-ios-simulator
89133
run: |
90-
SIMULATOR_RUNTIME=$(echo "${{ matrix.apple-runtime }}" | sed 's/[ \.]/-/g')
134+
SIMULATOR_RUNTIME=$(echo "iOS 14.4" | sed 's/[ \.]/-/g')
91135
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"
93137
xcrun simctl boot $SIMULATOR_ID &
94138
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+
95164
- name: Run iOS tests
96165
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
98167
99168
- name: Shutdown iOS simulator
100169
run: |
101-
xcrun simctl shutdown $IOS_SIMULATOR
170+
xcrun simctl shutdown ${{ steps.setup-ios-simulator.outputs.simulator_id }}

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
# Fetch
1+
# fetch
2+
3+
[![npm version][npm-image]][npm-url] [![ci][github-ci-image]][github-ci-url]
4+
5+
[npm-url]:https://www.npmjs.com/package/react-native-fetch-api
6+
[npm-image]:https://img.shields.io/npm/v/react-native-fetch-api.svg
7+
[github-ci-url]:https://github.com/react-native-community/fetch/actions
8+
[github-ci-image]:https://github.com/react-native-community/fetch/workflows/Node%20CI/badge.svg
9+
10+
> A fetch API polyfill for React Native with text streaming support
211
312
This is a fork of GitHub's fetch [polyfill](https://github.com/github/fetch), the fetch implementation React Native currently [provides](https://github.com/facebook/react-native/blob/master/Libraries/Network/fetch.js). This project features an alternative fetch implementation directy built on top of React Native's [Networking API](https://github.com/facebook/react-native/tree/master/Libraries/Network) instead of `XMLHttpRequest` for performance gains. At the same time, it aims to fill in some gaps of the [WHATWG specification](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) for fetch, namely the support for text streaming.
413

0 commit comments

Comments
 (0)