Contributing to Google Cloud Debugger
- Sign one of the contributor license agreements below.
- Fork the repo, develop and test your code changes.
- Send a pull request.
Contributor License Agreements
Before we can accept your pull requests you'll need to sign a Contributor License Agreement (CLA):
- If you are an individual writing original source code and you own the intellectual property, then you'll need to sign an individual CLA.
- If you work for a company that wants to allow you to contribute your work, then you'll need to sign a corporate CLA.
You can sign these electronically (just scroll to the bottom). After that, we'll be able to accept your pull requests.
Setup
In order to use the google-cloud-debugger console and run the project's tests, there is a small amount of setup:
Install Ruby. google-cloud-debugger requires Ruby 2.5+. It is not currently supported on Ruby 3. You may choose to manage your Ruby and gem installations with RVM, rbenv, or chruby.
Install Bundler.
$ gem install bundler
- Install the top-level project dependencies.
$ bundle install
- Install the Debugger dependencies.
$ cd google-cloud-debugger/
$ bundle install
Console
In order to run code interactively, you can automatically load google-cloud-debugger and its dependencies in IRB. This requires that your developer environment has already been configured by following the steps described in the Authentication Guide. An IRB console can be created with:
$ cd google-cloud-debugger/
$ bundle exec rake console
Debugger Tests
Tests are very important part of google-cloud-debugger. All contributions should include tests that ensure the contributed code behaves as expected.
To run the unit tests, documentation tests, and code style checks together for a package:
$ cd google-cloud-debugger/
$ bundle exec rake ci
To run the command above, plus all acceptance tests, use rake ci:acceptance
or
its handy alias, rake ci:a
.
Debugger Unit Tests
The project uses the minitest library, including specs, mocks and minitest-autotest.
To run the Debugger unit tests:
$ cd google-cloud-debugger/
$ bundle exec rake test
Debugger Documentation Tests
The project tests the code examples in the gem's YARD-based documentation.
The example testing functions in a way that is very similar to unit testing, and in fact the library providing it, yard-doctest, is based on the project's unit test library, minitest.
To run the Debugger documentation tests:
$ cd google-cloud-debugger/
$ bundle exec rake doctest
If you add, remove or modify documentation examples when working on a pull
request, you may need to update the setup for the tests. The stubs and mocks
required to run the tests are located in support/doctest_helper.rb
. Please
note that much of the setup is matched by the title of the
@example
tag.
If you alter an example's title, you may encounter breaking tests.
Debugger Acceptance Tests
The Debugger acceptance tests interact with the live service API. Follow the instructions in the Authentication Guide for enabling the Debugger API. Occasionally, some API features may not yet be generally available, making it difficult for some contributors to successfully run the entire acceptance test suite. However, please ensure that you do successfully run acceptance tests for any code areas covered by your pull request.
To run the acceptance tests, first create and configure a project in the Google Developers Console, as described in the Authentication guide. Be sure to download the JSON KEY file. Make note of the PROJECT_ID and the KEYFILE location on your system.
Before you can run the Debugger acceptance tests, you must first create indexes used in the tests.
Running the Debugger acceptance tests
To run the Debugger acceptance tests:
$ cd google-cloud-debugger/
$ bundle exec rake acceptance[\\{my-project-id},\\{/path/to/keyfile.json}]
Or, if you prefer you can store the values in the GCLOUD_TEST_PROJECT
and
GCLOUD_TEST_KEYFILE
environment variables:
$ cd google-cloud-debugger/
$ export GCLOUD_TEST_PROJECT=\\{my-project-id}
$ export GCLOUD_TEST_KEYFILE=\\{/path/to/keyfile.json}
$ bundle exec rake acceptance
If you want to use a different project and credentials for acceptance tests, you
can use the more specific DEBUGGER_TEST_PROJECT
and DEBUGGER_TEST_KEYFILE
environment variables:
$ cd google-cloud-debugger/
$ export DEBUGGER_TEST_PROJECT=\\{my-project-id}
$ export DEBUGGER_TEST_KEYFILE=\\{/path/to/keyfile.json}
$ bundle exec rake acceptance
Coding Style
Please follow the established coding style in the library. The style is is largely based on The Ruby Style Guide with a few exceptions based on seattle-style:
- Avoid parenthesis when possible, including in method definitions.
- Always use double quotes strings. (Option B)
You can check your code against these rules by running Rubocop like so:
$ cd google-cloud-debugger/
$ bundle exec rake rubocop
Code of Conduct
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See Code of Conduct for more information.