diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..cb8e24a6 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,113 @@ +# Contributing Guidelines + +## Environment Setup + +Everything is built and tested using Java 8 so please make sure that you are using that version (e.g. `echo $JAVA_HOME` should print something like `/usr/lib/jvm/java-8-openjdk-amd64`). + +## Directory Structure + +``` +├── build/ # gitignored - build artifacts are put here +├── build.gradle # Gradle build file - https://docs.gradle.org/current/userguide/build_file_basics.html +├── CONTRIBUTING.md # This file :) +├── docs/ # gitignored - generated javadocs are stored here by the CD process +├── gradle/ # autogenerated - contains the gradle wrapper jar and properties +├── gradlew # autogenerated - gradle wrapper file for Unix/macOS +├── gradlew.bat # autogenerated - gradle wrapper file for Windows +├── gradle.properties # config file that contains the name of the repo and the version number +├── LICENSE.md # autogenerated - use ./gradlew markdown to create it +├── LICENSE.mdt # template for the LICENCE +├── README.md # autogenerated - use ./gradlew markdown to create it +├── README.mdt # template for the README +└── src + ├── integration # end to end tests that run the source code against the production API + ├── main # source code for the SDK itself + └── test # unit tests for various portions of the SDK +``` + +## Tests + +### Unit + +Running the unit tests is as simple as running `./gradlew test` + +### Integration + +Running the integration tests requires some set up since we're actually hitting the production API. + +1. Create a / Sign into your developer account at https://dashboard.smartcar.com/login +2. Reach out to Smartcar to get webhooks enabled for your account +3. Add the following redirect URI to your application: `https://example.com/auth` +4. Set the following environment variables + + - `E2E_SMARTCAR_AMT` (fetch from the "Configuration" page) + - `E2E_SMARTCAR_CLIENT_ID` (fetch from the "Configuration" page) + - `E2E_SMARTCAR_CLIENT_SECRET` (fetch from the "Configuration" page) + - `E2E_SMARTCAR_WEBHOOK_ID` (fetch from "Webhooks" page, webhook does not have to be verified for the tests) + +5. Run the tests using `./gradlew integration` + +### Both + +You can run the entire test suite by running `./gradlew check` + +## Local Publishing + +If you would like to use the SDK the same way that a consumer would, you can actually publish it to a local Maven repository and then use it in another project for testing. This is great for making sure the experience for SDK consumers works as you want it to. + +### Setup + +1. Create a PGP key pair that can be used to sign the artifact (you only need to do this once) + + ```bash + gpg --batch --generate-key <' + } + ``` + +## Workflow + +1. Set up your development environment +2. Make changes to main / test / integration as needed to implement your changes +3. Run unit and integration tests +4. Iterate on your changes +5. Publish the SDK locally and verify your changes with some sample code +6. Iterate on your changes further if needed +7. Generate and review the JavaDoc (e.g. `./gradlew javadoc && python -m http.server --directory docs`) (note: This is for local verification only and does not need to be committed, the CD process will generate the ones that are published). +8. Bump the version number in `gradle.properties` and regenerate the README by running `./gradlew markdown`) +9. Commit the version number and README changes and open a PR :tada: