Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

CONTRIBUTING.md 7.7 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. # Contributing
  2. 1. Sign one of the contributor license agreements below.
  3. 1. `go get golang.org/x/review/git-codereview` to install the code reviewing tool.
  4. 1. You will need to ensure that your `GOBIN` directory (by default
  5. `$GOPATH/bin`) is in your `PATH` so that git can find the command.
  6. 1. If you would like, you may want to set up aliases for git-codereview,
  7. such that `git codereview change` becomes `git change`. See the
  8. [godoc](https://godoc.org/golang.org/x/review/git-codereview) for details.
  9. 1. Should you run into issues with the git-codereview tool, please note
  10. that all error messages will assume that you have set up these
  11. aliases.
  12. 1. Get the cloud package by running `go get -d cloud.google.com/go`.
  13. 1. If you have already checked out the source, make sure that the remote git
  14. origin is https://code.googlesource.com/gocloud:
  15. git remote set-url origin https://code.googlesource.com/gocloud
  16. 1. Make sure your auth is configured correctly by visiting
  17. https://code.googlesource.com, clicking "Generate Password", and following
  18. the directions.
  19. 1. Make changes and create a change by running `git codereview change <name>`,
  20. provide a commit message, and use `git codereview mail` to create a Gerrit CL.
  21. 1. Keep amending to the change with `git codereview change` and mail as your receive
  22. feedback. Each new mailed amendment will create a new patch set for your change in Gerrit.
  23. ## Integration Tests
  24. In addition to the unit tests, you may run the integration test suite.
  25. To run the integrations tests, creating and configuration of a project in the
  26. Google Developers Console is required.
  27. After creating a project, you must [create a service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#creatinganaccount).
  28. Ensure the project-level **Owner**
  29. [IAM role](console.cloud.google.com/iam-admin/iam/project) role is added to the
  30. service account. Alternatively, the account can be granted all of the following roles:
  31. - **Editor**
  32. - **Logs Configuration Writer**
  33. - **PubSub Admin**
  34. Once you create a project, set the following environment variables to be able to
  35. run the against the actual APIs.
  36. - **GCLOUD_TESTS_GOLANG_PROJECT_ID**: Developers Console project's ID (e.g. bamboo-shift-455)
  37. - **GCLOUD_TESTS_GOLANG_KEY**: The path to the JSON key file.
  38. Some packages require additional environment variables to be set:
  39. - firestore
  40. - **GCLOUD_TESTS_GOLANG_FIRESTORE_PROJECT_ID**: project ID for Firestore.
  41. - **GCLOUD_TESTS_GOLANG_FIRESTORE_KEY**: The path to the JSON key file.
  42. - storage
  43. - **GCLOUD_TESTS_GOLANG_KEYRING**: The full name of the keyring for the tests, in the
  44. form "projects/P/locations/L/keyRings/R".
  45. - translate
  46. - **GCLOUD_TESTS_API_KEY**: API key for using the Translate API.
  47. - profiler
  48. - **GCLOUD_TESTS_GOLANG_ZONE**: Compute Engine zone.
  49. Install the [gcloud command-line tool][gcloudcli] to your machine and use it
  50. to create some resources used in integration tests.
  51. From the project's root directory:
  52. ``` sh
  53. # Set the default project in your env.
  54. $ gcloud config set project $GCLOUD_TESTS_GOLANG_PROJECT_ID
  55. # Authenticate the gcloud tool with your account.
  56. $ gcloud auth login
  57. # Create the indexes used in the datastore integration tests.
  58. $ gcloud preview datastore create-indexes datastore/testdata/index.yaml
  59. # Create a Google Cloud storage bucket with the same name as your test project,
  60. # and with the Stackdriver Logging service account as owner, for the sink
  61. # integration tests in logging.
  62. $ gsutil mb gs://$GCLOUD_TESTS_GOLANG_PROJECT_ID
  63. $ gsutil acl ch -g cloud-logs@google.com:O gs://$GCLOUD_TESTS_GOLANG_PROJECT_ID
  64. # Create a PubSub topic for integration tests of storage notifications.
  65. $ gcloud beta pubsub topics create go-storage-notification-test
  66. # Create a Spanner instance for the spanner integration tests.
  67. $ gcloud beta spanner instances create go-integration-test --config regional-us-central1 --nodes 1 --description 'Instance for go client test'
  68. # NOTE: Spanner instances are priced by the node-hour, so you may want to delete
  69. # the instance after testing with 'gcloud beta spanner instances delete'.
  70. # For Storage integration tests:
  71. # Enable KMS for your project in the Cloud Console.
  72. # Create a KMS keyring, in the same location as the default location for your project's buckets.
  73. $ gcloud kms keyrings create MY_KEYRING --location MY_LOCATION
  74. # Create two keys in the keyring, named key1 and key2.
  75. $ gcloud kms keys create key1 --keyring MY_KEYRING --location MY_LOCATION --purpose encryption
  76. $ gcloud kms keys create key2 --keyring MY_KEYRING --location MY_LOCATION --purpose encryption
  77. # As mentioned above, set the GCLOUD_TESTS_GOLANG_KEYRING environment variable.
  78. $ export GCLOUD_TESTS_GOLANG_KEYRING=projects/$GCLOUD_TESTS_GOLANG_PROJECT_ID/locations/MY_LOCATION/keyRings/MY_KEYRING
  79. # Authorize Google Cloud Storage to encrypt and decrypt using key1.
  80. gsutil kms authorize -p $GCLOUD_TESTS_GOLANG_PROJECT_ID -k $GCLOUD_TESTS_GOLANG_KEYRING/cryptoKeys/key1
  81. ```
  82. Once you've done the necessary setup, you can run the integration tests by running:
  83. ``` sh
  84. $ go test -v cloud.google.com/go/...
  85. ```
  86. ## Contributor License Agreements
  87. Before we can accept your pull requests you'll need to sign a Contributor
  88. License Agreement (CLA):
  89. - **If you are an individual writing original source code** and **you own the
  90. intellectual property**, then you'll need to sign an [individual CLA][indvcla].
  91. - **If you work for a company that wants to allow you to contribute your
  92. work**, then you'll need to sign a [corporate CLA][corpcla].
  93. You can sign these electronically (just scroll to the bottom). After that,
  94. we'll be able to accept your pull requests.
  95. ## Contributor Code of Conduct
  96. As contributors and maintainers of this project,
  97. and in the interest of fostering an open and welcoming community,
  98. we pledge to respect all people who contribute through reporting issues,
  99. posting feature requests, updating documentation,
  100. submitting pull requests or patches, and other activities.
  101. We are committed to making participation in this project
  102. a harassment-free experience for everyone,
  103. regardless of level of experience, gender, gender identity and expression,
  104. sexual orientation, disability, personal appearance,
  105. body size, race, ethnicity, age, religion, or nationality.
  106. Examples of unacceptable behavior by participants include:
  107. * The use of sexualized language or imagery
  108. * Personal attacks
  109. * Trolling or insulting/derogatory comments
  110. * Public or private harassment
  111. * Publishing other's private information,
  112. such as physical or electronic
  113. addresses, without explicit permission
  114. * Other unethical or unprofessional conduct.
  115. Project maintainers have the right and responsibility to remove, edit, or reject
  116. comments, commits, code, wiki edits, issues, and other contributions
  117. that are not aligned to this Code of Conduct.
  118. By adopting this Code of Conduct,
  119. project maintainers commit themselves to fairly and consistently
  120. applying these principles to every aspect of managing this project.
  121. Project maintainers who do not follow or enforce the Code of Conduct
  122. may be permanently removed from the project team.
  123. This code of conduct applies both within project spaces and in public spaces
  124. when an individual is representing the project or its community.
  125. Instances of abusive, harassing, or otherwise unacceptable behavior
  126. may be reported by opening an issue
  127. or contacting one or more of the project maintainers.
  128. This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0,
  129. available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
  130. [gcloudcli]: https://developers.google.com/cloud/sdk/gcloud/
  131. [indvcla]: https://developers.google.com/open-source/cla/individual
  132. [corpcla]: https://developers.google.com/open-source/cla/corporate