Skip to content

Commit d0ee16e

Browse files
authored
feat: adding e2e tests, build automation and linting (Vydia#174)
* Added lint-staged with pre-commit hooks to have more consistent code styling. * Integrated the test app into this repository * Added simple end to end tests for the test app * Using Github Actions for CI/CD * Using semantic-release for fully automated version management and package publishing
1 parent 21dad7b commit d0ee16e

File tree

89 files changed

+16701
-36
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+16701
-36
lines changed

.eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
example/RNBackgroundExample/node_modules
2+
example/RNBackgroundExample/e2e

.eslintrc.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
root: true,
3+
extends: '@react-native-community',
4+
};

.github/PULL_REQUEST_TEMPLATE.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please follow the template so that the reviewers can easily understand what the code changes affect -->
2+
3+
# Summary
4+
5+
<!--
6+
Explain the **motivation** for making this change: here are some points to help you:
7+
8+
* What issues does the pull request solve? Please tag them so that they will get automatically closed once the PR is merged
9+
* What is the feature? (if applicable)
10+
* How did you implement the solution?
11+
* What areas of the library does it impact?
12+
-->
13+
14+
## Test Plan
15+
16+
<!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI. -->
17+
18+
### What's required for testing (prerequisites)?
19+
20+
### What are the steps to reproduce (after prerequisites)?
21+
22+
## Compatibility
23+
24+
| OS | Implemented |
25+
| ------- | :---------: |
26+
| iOS | ✅❌ |
27+
| Android | ✅❌ |
28+
29+
## Checklist
30+
31+
<!-- Check completed item, when applicable, via: [X] -->
32+
33+
- [ ] I have tested this on a device and a simulator
34+
- [ ] I added the documentation in `README.md`
35+
- [ ] I updated the typed files (TS and Flow)
36+
- [ ] I've added Detox End-to-End Test(s)
37+
- [ ] I've created a snack to demonstrate the changes: LINK HERE

.github/workflows/android.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Test Android Example App
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
react-native-android:
7+
runs-on: macos-latest
8+
if: "!contains(github.event.head_commit.message, '[skip ci]')"
9+
10+
steps:
11+
- name: Checkout project
12+
uses: actions/checkout@v1
13+
14+
- name: Specify node version
15+
uses: actions/setup-node@v1
16+
with:
17+
node-version: 12
18+
19+
- name: Use specific Java version for sdkmanager to work
20+
uses: joschi/setup-jdk@v1
21+
with:
22+
java-version: 'openjdk8'
23+
architecture: 'x64'
24+
25+
- name: Setup Android emulator
26+
run: |
27+
echo y | sudo $ANDROID_HOME/tools/bin/sdkmanager "system-images;android-28;google_apis;x86" > /dev/null
28+
$ANDROID_HOME/tools/bin/avdmanager -s create avd -n emu -k "system-images;android-28;google_apis;x86" -b "x86" -c 1G -d 7 -f
29+
30+
- name: Install node_modules
31+
working-directory: example/RNBackgroundExample/
32+
run:
33+
yarn install --frozen-lockfile
34+
35+
- name: Deploy
36+
working-directory: example/RNBackgroundExample/
37+
run:
38+
yarn e2e/deploy/android
39+
40+
- name: Start Emulator
41+
working-directory: example/RNBackgroundExample/
42+
timeout-minutes: 5
43+
run: |
44+
export PATH=$PATH:$ANDROID_HOME/platform-tools
45+
$ANDROID_HOME/emulator/emulator @emu -noaudio -no-boot-anim -netdelay none -accel on -no-snapshot &
46+
adb wait-for-device; adb shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;'; adb shell wm dismiss-keyguard
47+
48+
- name: Android test
49+
working-directory: example/RNBackgroundExample/
50+
timeout-minutes: 8
51+
run: |
52+
mkdir -p ./artifacts
53+
node e2e/start-server.js &
54+
adb reverse tcp:8080 tcp:8080
55+
yarn e2e/test/android --record-videos failing
56+
57+
- uses: actions/upload-artifact@master
58+
name: Provide videos of failed E2E tests
59+
if: failure()
60+
with:
61+
name: android-failing-e2e-videos
62+
path: example/RNBackgroundExample/artifacts

.github/workflows/deploy-release.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Deploy & Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
deploy-release:
10+
runs-on: macos-latest
11+
if: "!contains(github.event.head_commit.message, '[skip ci]')"
12+
13+
steps:
14+
- name: Checkout project
15+
uses: actions/checkout@v1
16+
17+
- name: Specify node version
18+
uses: actions/setup-node@v1
19+
with:
20+
node-version: 12
21+
22+
- name: Release to NPM
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
26+
run: |
27+
yarn install --frozen-lockfile
28+
npx semantic-release

.github/workflows/iOS.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Test iOS Example App
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
react-native-ios:
7+
runs-on: macos-latest
8+
if: "!contains(github.event.head_commit.message, '[skip ci]')"
9+
10+
steps:
11+
- name: Checkout project
12+
uses: actions/checkout@v1
13+
14+
- name: Specify node version
15+
uses: actions/setup-node@v1
16+
with:
17+
node-version: 12
18+
19+
- name: Setup Detox
20+
run: |
21+
brew tap wix/brew
22+
brew install applesimutils
23+
24+
- name: Install node_modules
25+
working-directory: example/RNBackgroundExample/
26+
run:
27+
yarn install --frozen-lockfile
28+
29+
- name: Deploy
30+
working-directory: example/RNBackgroundExample/
31+
run:
32+
yarn deploy/release/ios
33+
34+
- name: iOS test
35+
working-directory: example/RNBackgroundExample/
36+
timeout-minutes: 8
37+
run: |
38+
npx detox clean-framework-cache && npx detox build-framework-cache
39+
node e2e/start-server.js &
40+
yarn e2e/test/ios

.github/workflows/node.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Node Environment
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
node-lint-tests:
7+
runs-on: ubuntu-latest
8+
if: "!contains(github.event.head_commit.message, '[skip ci]')"
9+
10+
steps:
11+
- name: checkout
12+
uses: actions/checkout@v1
13+
14+
- name: setup node
15+
uses: actions/setup-node@v1
16+
with:
17+
node-version: 12
18+
19+
- name: install node_modules
20+
run: yarn install --frozen-lockfile
21+
22+
- name: node lint
23+
run:
24+
yarn lint:ci

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ DerivedData
3333
*.ipa
3434
*.xcuserstate
3535
project.xcworkspace
36+
Pods/
3637

3738
# Android/IntelliJ
3839
#

.prettierrc.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
bracketSpacing: true,
3+
jsxBracketSameLine: true,
4+
singleQuote: true,
5+
trailingComma: 'all',
6+
};

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Since Version > 5.3.0 we follow semantic versioning.
2+
3+
See the [releases](https://github.com/Vydia/react-native-background-upload/releases) page on GitHub for information regarding each release.

LICENSE.txt renamed to LICENSE

File renamed without changes.

README.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# react-native-background-upload [![npm version](https://badge.fury.io/js/react-native-background-upload.svg)](https://badge.fury.io/js/react-native-background-upload)
2+
3+
4+
![GitHub Actions status](https://github.com/Vydia/react-native-background-upload/workflows/iOS/badge.svg)
5+
6+
![GitHub Actions status](https://github.com/Vydia/react-native-background-upload/workflows/android/badge.svg)
7+
28
The only React Native http post file uploader with android and iOS background support. If you are uploading large files like videos, use this so your users can background your app during a long upload.
39

410
NOTE: Use major version 4 with RN 47.0 and greater. If you have RN less than 47, use 3.0. To view all available versions:
@@ -79,7 +85,7 @@ No further actions required.
7985
8086
## 3. Expo
8187
82-
To use this library with [Expo](https://expo.io) one must first detach (eject) the project and follow [step 2](#2-link-native-code) instructions. Additionally on iOS there is a must to add a Header Search Path to other dependencies which are managed using Pods. To do so one has to add `$(SRCROOT)/../../../ios/Pods/Headers/Public` to Header Search Path in `VydiaRNFileUploader` module using XCode.
88+
To use this library with [Expo](https://expo.io) one must first detach (eject) the project and follow [step 2](#2-link-native-code) instructions. Additionally on iOS there is a must to add a Header Search Path to other dependencies which are managed using Pods. To do so one has to add `$(SRCROOT)/../../../ios/Pods/Headers/Public` to Header Search Path in `VydiaRNFileUploader` module using XCode.
8389
8490
# Usage
8591
@@ -146,7 +152,7 @@ All top-level methods are available as named exports or methods on the default e
146152

147153
### startUpload(options)
148154

149-
The primary method you will use, this starts the upload process.
155+
The primary method you will use, this starts the upload process.
150156

151157
Returns a promise with the string ID of the upload. Will reject if there is a connection problem, the file doesn't exist, or there is some other problem.
152158

@@ -292,7 +298,7 @@ Is there an example/sandbox app to test out this package?
292298

293299
> Yes, there is a simple react native app that comes with an [express](https://github.com/expressjs/express) server where you can see react-native-background-upload in action and try things out in an isolated local environment.
294300
295-
[ReactNativeBackgroundUploadExample](https://github.com/Vydia/ReactNativeBackgroundUploadExample)
301+
[RNBackgroundExample](https://github.com/Vydia/react-native-background-upload/blob/master/example/RNBackgroundExample)
296302

297303
Does it support iOS camera roll assets?
298304

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
[android]
3+
target = Google Inc.:Google APIs:23
4+
5+
[maven_repositories]
6+
central = https://repo1.maven.org/maven2
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
root: true,
3+
extends: '@react-native-community',
4+
};
+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
[ignore]
2+
; We fork some components by platform
3+
.*/*[.]android.js
4+
5+
; Ignore "BUCK" generated dirs
6+
<PROJECT_ROOT>/\.buckd/
7+
8+
; Ignore polyfills
9+
node_modules/react-native/Libraries/polyfills/.*
10+
11+
; These should not be required directly
12+
; require from fbjs/lib instead: require('fbjs/lib/warning')
13+
node_modules/warning/.*
14+
15+
; Flow doesn't support platforms
16+
.*/Libraries/Utilities/LoadingView.js
17+
18+
[untyped]
19+
.*/node_modules/@react-native-community/cli/.*/.*
20+
21+
[include]
22+
23+
[libs]
24+
node_modules/react-native/Libraries/react-native/react-native-interface.js
25+
node_modules/react-native/flow/
26+
27+
[options]
28+
emoji=true
29+
30+
esproposal.optional_chaining=enable
31+
esproposal.nullish_coalescing=enable
32+
33+
module.file_ext=.js
34+
module.file_ext=.json
35+
module.file_ext=.ios.js
36+
37+
munge_underscores=true
38+
39+
module.name_mapper='^react-native$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/react-native/react-native-implementation'
40+
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
41+
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'
42+
43+
suppress_type=$FlowIssue
44+
suppress_type=$FlowFixMe
45+
suppress_type=$FlowFixMeProps
46+
suppress_type=$FlowFixMeState
47+
48+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
49+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
50+
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
51+
52+
[lints]
53+
sketchy-null-number=warn
54+
sketchy-null-mixed=warn
55+
sketchy-number=warn
56+
untyped-type-import=warn
57+
nonstrict-import=warn
58+
deprecated-type=warn
59+
unsafe-getters-setters=warn
60+
inexact-spread=warn
61+
unnecessary-invariant=warn
62+
signature-verification-failure=warn
63+
deprecated-utility=error
64+
65+
[strict]
66+
deprecated-type
67+
nonstrict-import
68+
sketchy-null
69+
unclear-type
70+
unsafe-getters-setters
71+
untyped-import
72+
untyped-type-import
73+
74+
[version]
75+
^0.105.0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pbxproj -text

0 commit comments

Comments
 (0)