Skip to content

Commit 6ce8c70

Browse files
authored
Improve contribution docs (#34)
1 parent 5fe7f7a commit 6ce8c70

File tree

6 files changed

+76
-44
lines changed

6 files changed

+76
-44
lines changed

.github/actions/use-turbo-cache/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ runs:
88
uses: actions/cache@v3
99
with:
1010
path: .turbo
11-
key: turbo-${{ github.sha }}
11+
key: ${{ runner.os }}-turbo-${{ github.sha }}
1212
restore-keys: |
13-
turbo-
13+
${{ runner.os }}-turbo-

.github/workflows/ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ jobs:
6565

6666
- name: Check build cache
6767
run: |
68-
CACHE_STATUS=$(./scripts/check_cache sample build:android)
69-
echo "[sample] build:android - $CACHE_STATUS"
68+
CACHE_STATUS=$(./scripts/check_cache sample test:android)
69+
echo "[sample] test:android - $CACHE_STATUS"
7070
echo "turbo_cache_hit=$CACHE_STATUS" >> $GITHUB_ENV
7171
7272
- name: Install JDK
@@ -93,7 +93,7 @@ jobs:
9393
- name: Run Android tests
9494
# If turbo has already cached the build it will return instantly here
9595
run: |
96-
yarn turbo run test:android --cache-dir=".turbo"
96+
yarn turbo run test:android --cache-dir=".turbo" --no-daemon
9797
9898
test-ios:
9999
name: Run iOS Tests
@@ -120,7 +120,7 @@ jobs:
120120
- name: Install cocoapods
121121
uses: ./.github/actions/install-cocoapods
122122

123-
- name: Build sample for iOS
123+
- name: Run Swift tests
124124
# If turbo has already cached the build it will return instantly here
125125
run: |
126-
yarn turbo run test:ios --cache-dir=".turbo"
126+
yarn turbo run test:ios --cache-dir=".turbo" --no-daemon

CONTRIBUTING.md

Lines changed: 64 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,64 +3,96 @@
33
This repo is subdivided into 3 parts using yarn workspaces:
44

55
- The base repo (workspace name = `checkout-kit-react-native`)
6-
- The `react-native-shopify-checkout-kit` Native Module (workspace name = `module`)
6+
- The `react-native-shopify-checkout-kit` Native Module (workspace name =
7+
`module`)
78
- The sample application (workspace name = `sample`)
89

9-
Each of the worksapces contains a separate `package.json` to manage tasks specific to each workspace.
10+
Each of the worksapces contains a separate `package.json` to manage tasks
11+
specific to each workspace.
1012

11-
## Base repo
13+
## Getting started
1214

13-
## Install dependencies
15+
If you've cloned the repo and want to run the sample app, you will first need
16+
to:
1417

15-
Run `yarn` to install the dependencies for all workspaces in the repo.
18+
1. Install the NPM dependencies
19+
2. Install iOS dependencies (cocoapods)
20+
3. Build the Native Module
1621

17-
---
18-
19-
## `react-native-shopify-checkout-kit` Module
22+
```sh
23+
# Install NPM dependencies and link local module
24+
yarn
2025

21-
### Clean the modules folder
26+
# Install Cocoapods for iOS
27+
yarn pod-install sample/ios
28+
# Note: Android dependencies are automatically installed by Gradle
2229

23-
```bash
24-
yarn module clean
30+
# Build the Native Module JS
31+
yarn module build
2532
```
2633

27-
### Build the `react-native-shopify-checkout-kit` module
34+
If all of these steps have succeeded, you can now run the sample app with:
2835

2936
```sh
30-
yarn module build
37+
yarn sample start
3138
```
3239

33-
### Lint the module
40+
This command will start the Metro server. Follow the steps given by Metro to
41+
open both the iOS and Android simulators/emulators respectively.
3442

35-
```sh
36-
yarn module lint
37-
```
43+
## Making changes to the Native Module
3844

39-
---
45+
If your intentions are to modify the TS code for the Native Module under
46+
`modules/react-native-shopify-checkout-kit`, note that you will not need to
47+
rebuild to observe your changes in the sample app. This is because the sample
48+
app is importing the TS files directly from the module directory (through
49+
symlinking).
4050

41-
## Sample application
51+
However, if you're running the iOS/Android tests against the module, you will
52+
first need to run `yarn module build` each time you change the TS code.
4253

43-
## Start the sample application
54+
## Cleaning the workspaces
4455

45-
### For Android
56+
There are a handful of commands to clean the individual workspaces.
4657

47-
```bash
48-
# Start the Metro server
49-
yarn sample start
58+
```sh
59+
# Clear the current directory from watchman
60+
yarn clean
5061

51-
# Start the Metro server and run the Android sample application
52-
yarn sample android
62+
# Removes the "sample/node_modules" directory
63+
# Removes "ios/pods" directory
64+
# Removes "ios/build" directory
65+
yarn sample clean
5366

54-
# Start the Metro server and run the iOS sample application
55-
yarn sample android
67+
# Removes the "lib" directory for the Native Module
68+
yarn module clean
5669
```
5770

58-
If everything is set up _correctly_, you should see your new app running in your _Android Emulator_ or _iOS Simulator_ shortly provided you have set up your emulator/simulator correctly.
59-
60-
This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively.
71+
## Linting the code
6172

62-
## Lint the sample application
73+
Linting the codespaces will (1) compile the code with TypeScript and (2) run
74+
eslint over the source code.
6375

6476
```sh
77+
# Lint the Native Module TS code
78+
yarn module lint
79+
80+
# Lint the Sample App TS code
6581
yarn sample lint
6682
```
83+
84+
## Testing
85+
86+
There are 3 types of tests in this repo: Typescript, Swift and Java - each for
87+
testing the Native Module.
88+
89+
```sh
90+
# Run Jest tests for "modules/react-native-shopify-checkout-kit/src/**/*.tsx"
91+
yarn test
92+
93+
# Run swift tests for the Native Module
94+
yarn sample test:ios
95+
96+
# Run Java tests for the Native Module
97+
yarn sample test:android
98+
```

sample/.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
android/build
2+
android/app/build

sample/scripts/test_android

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ set -e
44

55
cd android
66

7-
./gradlew test --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a
7+
./gradlew clean test --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a

turbo.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
"$schema": "https://turbo.build/schema.json",
33
"pipeline": {
44
"build": {
5-
"outputs": ["modules/react-native-shopify-checkout-kit/lib/**/*"]
6-
},
7-
"lint": {
8-
"dependsOn": ["build"]
5+
"outputs": ["./modules/react-native-shopify-checkout-kit/lib/**"]
96
},
7+
"lint": {},
108
"build:android": {
119
"dependsOn": ["build", "lint"],
1210
"outputs": ["sample/android/app/build"]

0 commit comments

Comments
 (0)