Skip to content

Commit 5336724

Browse files
authored
Update CONTRIBUTING, ISSUE_TEMPLATE, and parent README (#1503)
* Update ReadMe * Move to match the new github style * Update contributing
1 parent 6a9d4e3 commit 5336724

File tree

3 files changed

+105
-65
lines changed

3 files changed

+105
-65
lines changed

ISSUE_TEMPLATE.md renamed to .github/ISSUE_TEMPLATE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
<!-- If this is a question about a specific product or for debugging help, please
2+
ask your question on [Stack Overflow](https://stackoverflow.com/) using
3+
appropriate tags. This improves visibility of your question and the answer for
4+
additional users. -->
5+
16
## In which file did you encounter the issue?
27

38
<!-- Please provide the full path to the file, to avoid ambiguity -->

CONTRIBUTING.md

Lines changed: 68 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# How to become a contributor and submit your own code
22

33
* [Contributor License Agreements](#Contributor-License-Agreements)
4-
* [Contributing a Patch](#Contributing-a-Patch)
5-
* [Contributing a new sample](#Contributing-a-new-sample)
4+
* [Contributing a Patch or New Sample](#Contributing-a-Patch)
65
* [Build Tools](#build-tools)
76
* [Integration Testing](#testing)
87
* [Style](#Style)
@@ -26,32 +25,37 @@ Follow either of the two links above to access the appropriate CLA and
2625
instructions for how to sign and return it. Once we receive it, we'll be able to
2726
accept your pull requests.
2827

29-
## Contributing a Patch
28+
## Contributing a Patch or New Sample
3029

31-
1. Submit an issue describing your proposed change to the repo in question.
32-
1. The repo owner will respond to your issue promptly.
33-
1. If your proposed change is accepted, and you haven't already done so, sign a
34-
Contributor License Agreement (see details above).
35-
1. Fork the desired repo, develop and test your code changes.
36-
1. Ensure that your code adheres to the existing style in the sample to which
37-
you are contributing.
30+
1. Sign a [Contributor License Agreement](#Contributor-License-Agreements).
31+
1. Set up your [Java Developer Environment](https://cloud.google.com/java/docs/setup).
32+
1. Fork the repo.
33+
1. Develop and test your code.
34+
1. Ensure that your code adheres to the [SAMPLE_FORMAT.md](SAMPLE_FORMAT.md)
35+
guidelines.
3836
1. Ensure that your code has an appropriate set of unit tests which all pass.
3937
1. Submit a pull request.
38+
1. A maintainer will review the pull request and make comments.
4039

41-
## Contributing a new sample
40+
## Build Tools
4241

43-
1. See the [SAMPLE_FORMAT.md](SAMPLE_FORMAT.md) for guidelines on the preferred sample format.
42+
All new samples should build and run integration tests with both [Maven](https://maven.apache.org/) and [Gradle](https://gradle.org/).
4443

44+
## Integration Testing
4545

46-
## Build Tools
46+
All samples must have Integration Tests that run with Maven and Gradle
4747

48-
For instructions regarding development environment setup, please visit [the documentation](https://cloud.google.com/java/docs/setup). All new samples should build and run integration tests with both [Maven](https://maven.apache.org/) and [Gradle](https://gradle.org/).
48+
* Test Library: [JUnit4](https://junit.org/junit4/)
49+
* Test Runner: [Maven Failsafe plugin](https://maven.apache.org/surefire/maven-failsafe-plugin/) and [Maven Surefire plugin](https://maven.apache.org/surefire/maven-surefire-plugin/).
4950

50-
## Testing
51+
### Running Tests Locally
5152

52-
All samples must have Integration Tests (ie. They need to run against a real service) that run with
53-
`mvn verify` & `gradle build test`. If we need to enable an API, let us know.
53+
Run tests locally with commands:
54+
* Maven: `mvn verify`
55+
* Gradle: `gradle build test`
5456

57+
58+
### Gradle Specifcs
5559
Your `build.gradle` should have the following section:
5660

5761
```groovy
@@ -72,9 +76,34 @@ test {
7276
}
7377
```
7478

75-
### Keys and Secrets
79+
### Other Testing Set Up
80+
81+
Most samples require a GCP project and billing account. Keep the following in
82+
mind when setting up tests.
83+
84+
* **Environment variables**
85+
Minimize additional environment variables that need to be set to run the tests.
86+
If you do require additional environment variables, they should be added to
87+
`run_tests.sh`.
88+
89+
Existing environment variables include:
90+
* `GOOGLE_APPLICATION_CREDENTIALS`
91+
* `GOOGLE_CLOUD_PROJECT`
92+
* `PROJECT_ID`
93+
94+
95+
* **API library**
96+
Add a note in the pull request, if an API needs to be enable in the testing
97+
project.
7698

77-
Please contact a Java DPE for instructions before adding to Travis.
99+
* **Cloud resources**
100+
Most Java samples create the Cloud resources that they need to run. If this
101+
is resource intensive or not possible, add a note in the pull request for the
102+
resource to be added to the testing project.
103+
104+
* **Keys and Secrets**
105+
Add a note in the pull request, in order for a Java maintainer to assist you
106+
in adding keys and secrets to the testing project.
78107

79108
## Style
80109

@@ -90,34 +119,37 @@ tool or IntelliJ plugin.
90119

91120
[google-java-format]: https://github.com/google/google-java-format
92121

93-
### Running the Linter
94-
95-
To run the checkstyle & ErrorProne plugins on an existing sample, run
96-
97-
```shell
98-
mvn clean verify -DskipTests
99-
```
100-
101-
The `-DskipTests` is optional. It is useful if you want to verify that your code
102-
builds and adheres to the style guide without waiting for tests to complete.
103-
104122
### Adding the Checkstyle Plugin to New Samples
105123

106124
The samples in this repository use a common parent POM to define plugins used
107125
for linting and testing. Add the following to your sample POM to ensure that it
108-
uses the common Checkstyle configuration.
126+
uses the common Checkstyle configuration. For more information, see the
127+
[java-repo-tools](https://github.com/GoogleCloudPlatform/java-repo-tools)
128+
repository.
109129

110130
```xml
131+
<!--
132+
The parent pom defines common style checks and testing strategies for our samples.
133+
Removing or replacing it should not affect the execution of the samples in anyway.
134+
-->
111135
<parent>
112136
<groupId>com.google.cloud</groupId>
113137
<artifactId>doc-samples</artifactId>
114-
<version>1.0.0</version>
115-
<!-- Change relativePath to point to the root directory. -->
116-
<relativePath>../..</relativePath>
138+
<version>1.0.11</version>
117139
</parent>
118140
```
119141

120-
This is just used for testing. The sample should build without a parent defined.
142+
### Running the Linter
143+
144+
To run the checkstyle & ErrorProne plugins on an existing sample, run
145+
146+
```shell
147+
mvn clean verify -DskipTests
148+
```
149+
150+
The `-DskipTests` is optional. It is useful if you want to verify that your code
151+
builds and adheres to the style guide without waiting for tests to complete.
152+
121153

122154
### Parsing Command-Line Arguments in Samples
123155

@@ -128,5 +160,4 @@ CLI](https://commons.apache.org/proper/commons-cli/index.html) library.
128160

129161
Dataflow samples are an exception to this rule, since Dataflow has [its own
130162
method for setting custom
131-
options](https://cloud.google.com/dataflow/pipelines/specifying-exec-params)
132-
163+
options](https://cloud.google.com/dataflow/pipelines/specifying-exec-params).

README.md

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,48 @@
1-
# java-docs-samples
1+
# Google Cloud Platform Java Samples
22

33
![Kokoro Build Status](https://storage.googleapis.com/cloud-devrel-kokoro-resources/java/badges/java-docs-samples.png)
44
[![Coverage Status](https://codecov.io/gh/GoogleCloudPlatform/java-docs-samples/branch/master/graph/badge.svg)](https://codecov.io/gh/GoogleCloudPlatform/java-docs-samples)
55

66
<a href="https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/java-docs-samples&page=editor&open_in_editor=README.md">
77
<img alt="Open in Cloud Shell" src ="http://gstatic.com/cloudssh/images/open-btn.png"></a>
88

9-
While this library is still supported, we suggest trying the newer [Cloud Client Library](https://developers.google.com/api-client-library/java/apis/vision/v1) for Google Cloud Vision, especially for new projects. For more information, please see the notice on the [API Client Library Page](https://developers.google.com/api-client-library/java/apis/vision/v1).
9+
This repository holds sample code written in Go that demonstrates the
10+
[Google Cloud Platform](https://cloud.google.com/docs/).
1011

11-
This is a repository that contains java code snippets on [Cloud Platform Documentation](https://cloud.google.com/docs/).
12+
Some samples have accompanying guides on <cloud.google.com>. See respective
13+
README files for details.
1214

13-
Technology Samples:
15+
## Set Up
1416

15-
* [Bigquery](bigquery)
16-
* [Data Catalog](datacatalog)
17-
* [Datastore](datastore)
18-
* [Endpoints](endpoints)
19-
* [Identity-Aware Proxy](iap)
20-
* [Key Management Service](kms)
21-
* [Logging](logging)
22-
* [Monitoring](monitoring)
23-
* [Natural Language](language)
24-
* [PubSub](pubsub)
25-
* [Cloud Spanner](spanner)
26-
* [Speech](speech)
27-
* [Cloud Storage](storage)
28-
* [Translate](translate)
29-
* [Vision](vision)
17+
1. [Set up your Java Development Environment](https://cloud.google.com/java/docs/setup)
3018

31-
## Credentials Example
19+
1. Clone this repository:
3220

33-
The documentation for [Application Default Credentials](https://developers.google.com/identity/protocols/application-default-credentials).
21+
git clone https://github.com/GoogleCloudPlatform/java-docs-samples.git
3422

35-
`BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService();`
23+
1. Obtain authentication credentials.
3624

37-
The client library looks for credentials using the following rules:
25+
Create local credentials by running the following command and following the
26+
oauth2 flow (read more about the command [here][auth_command]):
3827

39-
1. `GOOGLE_APPLICATION_CREDENTIALS` environment variable, pointing to a service account key JSON file path.
40-
2. Cloud SDK credentials `gcloud auth application-default login`
41-
3. App Engine standard environment credentials.
42-
4. Compute Engine credentials.
28+
gcloud auth application-default login
4329

44-
You can override this behavior using setCredentials in `BigQueryOptions.newBuilder()` by adding `setCredentials(Credentials credentials)` from [ServiceOptions.builder](http://googlecloudplatform.github.io/google-cloud-java/0.12.0/apidocs/com/google/cloud/ServiceOptions.Builder.html#setCredentials-com.google.auth.Credentials-) and [Credentials](http://google.github.io/google-auth-library-java/releases/0.6.0/apidocs/com/google/auth/Credentials.html?is-external=true).
30+
Or manually set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable
31+
to point to a service account key JSON file path.
32+
33+
Learn more at [Setting Up Authentication for Server to Server Production Applications](ADC).
34+
35+
*Note:* Application Default Credentials is able to implicitly find the credentials as long as the application is running on Compute Engine, Kubernetes Engine, App Engine, or Cloud Functions.
36+
37+
## Contributing
38+
39+
* See the [Contributing Guide](CONTRIBUTING.md)
40+
41+
## Licensing
42+
43+
* See [LICENSE](LICENSE)
44+
45+
[ADC]: https://developers.google.com/identity/protocols/application-default-credentials
46+
[cred]: http://google.github.io/google-auth-library-java/releases/0.6.0/apidocs/com/google/auth/Credentials.html?is-external=true
47+
[options]: http://googlecloudplatform.github.io/google-cloud-java/0.12.0/apidocs/com/google/cloud/ServiceOptions.Builder.html#setCredentials-com.google.auth.Credentials-
48+
[auth_command]: https://cloud.google.com/sdk/gcloud/reference/beta/auth/application-default/login

0 commit comments

Comments
 (0)