* The project uses [Go Modules](https://blog.golang.org/using-go-modules)
for dependency management See
[`gopls`](https://github.com/golang/go/wiki/gopls) for making your editor
work with modules.
1. Change to the project directory:
```
cd ~/code/gocloud
```
1. Make sure your `git` auth is configured correctly by visiting
https://code.googlesource.com, clicking "Generate Password" at the top-right,
and following the directions. Otherwise, `git codereview mail` in the next step
will fail.
1. Now you are ready to make changes. Don't create a new branch or make commits in the traditional
way. Use the following`git codereview` commands to create a commit and create a Gerrit CL:
```
git codereview change <branch-name> # Use this instead of git checkout -b <branch-name>
# Make changes.
git add ...
git codereview change # Use this instead of git commit
git codereview mail # If this fails, the error message will contain instructions to fix it.
```
* This will create a new `git` branch for you to develop on. Once your
change is merged, you can delete this branch.
1. As you make changes for code review, ammend the commit and re-mail the
change:
```
# Make more changes.
git add ...
git codereview change
git codereview mail
```
* **Warning**: do not change the `Change-Id` at the bottom of the commit
message - it's how Gerrit knows which change this is (or if it's new).
* When you fixes issues from code review, respond to each code review
message then click **Reply** at the top of the page.
* Each new mailed amendment will create a new patch set for
your change in Gerrit. Patch sets can be compared and reviewed.
* **Note**: if your change includes a breaking change, our breaking change
detector will cause CI/CD to fail. If your breaking change is acceptable
in some way, add a `BREAKING_CHANGE_ACCEPTABLE=<reason>` line to the commit
message to cause the detector not to be run and to make it clear why that is
acceptable.
1. Finally, add reviewers to your CL when it's ready for review. Reviewers will
not be added automatically. If you're not sure who to add for your code review,
add deklerk@, tbp@, cbro@, and codyoss@.
## Integration Tests
In addition to the unit tests, you may run the integration test suite. These
directions describe setting up your environment to run integration tests for
_all_ packages: note that many of these instructions may be redundant if you
intend only to run integration tests on a single package.
#### GCP Setup
To run the integrations tests, creation and configuration of two projects in
the Google Developers Console is required: one specifically for Firestore
integration tests, and another for all other integration tests. We'll refer to
these projects as "general project" and "Firestore project".
After creating each project, you must [create a service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#creatinganaccount)
for each project. Ensure the project-level **Owner**
[IAM role](console.cloud.google.com/iam-admin/iam/project) role is added to
each service account. During the creation of the service account, you should
download the JSON credential file for use later.
Next, ensure the following APIs are enabled in the general project:
- BigQuery API
- BigQuery Data Transfer API
- Cloud Dataproc API
- Cloud Dataproc Control API Private
- Cloud Datastore API
- Cloud Firestore API
- Cloud Key Management Service (KMS) API
- Cloud Natural Language API
- Cloud OS Login API
- Cloud Pub/Sub API
- Cloud Resource Manager API
- Cloud Spanner API
- Cloud Speech API
- Cloud Translation API
- Cloud Video Intelligence API
- Cloud Vision API
- Compute Engine API
- Compute Engine Instance Group Manager API
- Container Registry API
- Firebase Rules API
- Google Cloud APIs
- Google Cloud Deployment Manager V2 API
- Google Cloud SQL
- Google Cloud Storage
- Google Cloud Storage JSON API
- Google Compute Engine Instance Group Updater API
- Google Compute Engine Instance Groups API
- Kubernetes Engine API
- Stackdriver Error Reporting API
Next, create a Datastore database in the general project, and a Firestore
database in the Firestore project.
Finally, in the general project, create an API key for the translate API:
- Go to GCP Developer Console.
- Navigate to APIs & Services > Credentials.
- Click Create Credentials > API Key.
- Save this key for use in `GCLOUD_TESTS_API_KEY` as described below.
#### Local Setup
Once the two projects are created and configured, set the following environment
variables:
-`GCLOUD_TESTS_GOLANG_PROJECT_ID`: Developers Console project's ID (e.g.
bamboo-shift-455) for the general project.
-`GCLOUD_TESTS_GOLANG_KEY`: The path to the JSON key file of the general
project's service account.
-`GCLOUD_TESTS_GOLANG_FIRESTORE_PROJECT_ID`: Developers Console project's ID
(e.g. doorway-cliff-677) for the Firestore project.
-`GCLOUD_TESTS_GOLANG_FIRESTORE_KEY`: The path to the JSON key file of the
Firestore project's service account.
-`GCLOUD_TESTS_GOLANG_KEYRING`: The full name of the keyring for the tests,
in the form
"projects/P/locations/L/keyRings/R". The creation of this is described below.
-`GCLOUD_TESTS_API_KEY`: API key for using the Translate API.
-`GCLOUD_TESTS_GOLANG_ZONE`: Compute Engine zone.
Install the [gcloud command-line tool][gcloudcli] to your machine and use it to
create some resources used in integration tests.
From the project's root directory:
``` sh
# Sets the default project in your env.
$ gcloud config set project $GCLOUD_TESTS_GOLANG_PROJECT_ID
# Authenticates the gcloud tool with your account.
$ gcloud auth login
# Create the indexes used in the datastore integration tests.