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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
example/RNBackgroundExample/node_modules
2+
example/RNBackgroundExample/e2e

.eslintrc.js

Lines changed: 4 additions & 0 deletions
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

Lines changed: 37 additions & 0 deletions
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

Lines changed: 62 additions & 0 deletions
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

Lines changed: 28 additions & 0 deletions
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

Lines changed: 40 additions & 0 deletions
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

Lines changed: 24 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 6 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
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.

0 commit comments

Comments
 (0)