Jeff Ching | 1d770d0 | 2019-09-06 09:12:06 -0700 | [diff] [blame] | 1 | # How to Contribute |
| 2 | |
| 3 | We'd love to accept your patches and contributions to this project. There are |
| 4 | just a few small guidelines you need to follow. |
| 5 | |
| 6 | ## Contributor License Agreement |
| 7 | |
| 8 | Contributions to this project must be accompanied by a Contributor License |
| 9 | Agreement. You (or your employer) retain the copyright to your contribution; |
| 10 | this simply gives us permission to use and redistribute your contributions as |
| 11 | part of the project. Head over to <https://cla.developers.google.com/> to see |
| 12 | your current agreements on file or to sign a new one. |
| 13 | |
| 14 | You generally only need to submit a CLA once, so if you've already submitted one |
| 15 | (even if it was for a different project), you probably don't need to do it |
| 16 | again. |
| 17 | |
| 18 | ## Code reviews |
| 19 | |
| 20 | All submissions, including submissions by project members, require review. We |
| 21 | use GitHub pull requests for this purpose. Consult |
| 22 | [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more |
| 23 | information on using pull requests. |
| 24 | |
| 25 | ## Community Guidelines |
| 26 | |
| 27 | This project follows |
Yoshi Automation Bot | 2275422 | 2020-01-07 08:46:40 -0800 | [diff] [blame] | 28 | [Google's Open Source Community Guidelines](https://opensource.google.com/conduct/). |
| 29 | |
| 30 | ## Building the project |
| 31 | |
| 32 | To build, package, and run all unit tests run the command |
| 33 | |
| 34 | ``` |
| 35 | mvn clean verify |
| 36 | ``` |
| 37 | |
| 38 | ### Running Integration tests |
| 39 | |
| 40 | To include integration tests when building the project, you need access to |
| 41 | a GCP Project with a valid service account. |
| 42 | |
| 43 | For instructions on how to generate a service account and corresponding |
| 44 | credentials JSON see: [Creating a Service Account][1]. |
| 45 | |
| 46 | Then run the following to build, package, run all unit tests and run all |
| 47 | integration tests. |
| 48 | |
| 49 | ```bash |
| 50 | export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/account.json |
| 51 | mvn -Penable-integration-tests clean verify |
| 52 | ``` |
| 53 | |
| 54 | ## Code Samples |
| 55 | |
gcf-owl-bot[bot] | 3ca27c8 | 2021-11-22 18:32:19 +0000 | [diff] [blame] | 56 | All code samples must be in compliance with the [java sample formatting guide][3]. |
| 57 | Code Samples must be bundled in separate Maven modules. |
Yoshi Automation Bot | 2275422 | 2020-01-07 08:46:40 -0800 | [diff] [blame] | 58 | |
| 59 | The samples must be separate from the primary project for a few reasons: |
gcf-owl-bot[bot] | 3ca27c8 | 2021-11-22 18:32:19 +0000 | [diff] [blame] | 60 | 1. Primary projects have a minimum Java version of Java 8 whereas samples can have |
| 61 | Java version of Java 11. Due to this we need the ability to |
Yoshi Automation Bot | 2275422 | 2020-01-07 08:46:40 -0800 | [diff] [blame] | 62 | selectively exclude samples from a build run. |
| 63 | 2. Many code samples depend on external GCP services and need |
| 64 | credentials to access the service. |
| 65 | 3. Code samples are not released as Maven artifacts and must be excluded from |
| 66 | release builds. |
| 67 | |
| 68 | ### Building |
| 69 | |
| 70 | ```bash |
gcf-owl-bot[bot] | 3ca27c8 | 2021-11-22 18:32:19 +0000 | [diff] [blame] | 71 | mvn clean verify |
Yoshi Automation Bot | 2275422 | 2020-01-07 08:46:40 -0800 | [diff] [blame] | 72 | ``` |
| 73 | |
| 74 | Some samples require access to GCP services and require a service account: |
| 75 | |
| 76 | ```bash |
| 77 | export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/account.json |
gcf-owl-bot[bot] | 3ca27c8 | 2021-11-22 18:32:19 +0000 | [diff] [blame] | 78 | mvn clean verify |
Yoshi Automation Bot | 2275422 | 2020-01-07 08:46:40 -0800 | [diff] [blame] | 79 | ``` |
| 80 | |
Yoshi Automation Bot | a4d5fae | 2020-05-18 12:50:51 -0700 | [diff] [blame] | 81 | ### Code Formatting |
| 82 | |
| 83 | Code in this repo is formatted with |
| 84 | [google-java-format](https://github.com/google/google-java-format). |
| 85 | To run formatting on your project, you can run: |
| 86 | ``` |
| 87 | mvn com.coveo:fmt-maven-plugin:format |
| 88 | ``` |
Yoshi Automation Bot | 2275422 | 2020-01-07 08:46:40 -0800 | [diff] [blame] | 89 | |
Yoshi Automation Bot | 2275422 | 2020-01-07 08:46:40 -0800 | [diff] [blame] | 90 | [1]: https://cloud.google.com/docs/authentication/getting-started#creating_a_service_account |
| 91 | [2]: https://maven.apache.org/settings.html#Active_Profiles |
gcf-owl-bot[bot] | 3ca27c8 | 2021-11-22 18:32:19 +0000 | [diff] [blame] | 92 | [3]: https://github.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md |