| 1 | Want to contribute? Great: read the page (including the small print at the end). |
| 2 | |
| 3 | # Before you contribute |
| 4 | |
| 5 | As an individual, sign the [Google Individual Contributor License |
| 6 | Agreement](https://cla.developers.google.com/about/google-individual) (CLA) |
| 7 | online. This is required for any of your code to be accepted. |
| 8 | |
| 9 | Before you start working on a larger contribution, get in touch with us first |
| 10 | through the issue tracker with your idea so that we can help out and possibly |
| 11 | guide you. Coordinating up front makes it much easier to avoid frustration later |
| 12 | on. |
| 13 | |
| 14 | # What to expect |
| 15 | |
| 16 | All submissions (including by project members) are done via GitHub pull requests |
| 17 | and require a code review by a project member. |
| 18 | |
| 19 | We expect contributions to be good, clean code following style and practices for |
| 20 | the language the contribution is in. The pprof source code is in Go with a bit |
| 21 | of JavaScript, CSS and HTML. If you are new to Go, read [Effective |
| 22 | Go](https://golang.org/doc/effective_go.html) and the [summary on typical |
| 23 | comments during Go code |
| 24 | reviews](https://github.com/golang/go/wiki/CodeReviewComments). |
| 25 | |
| 26 | All contributions should include automated tests for the change. We are |
| 27 | continuously improving pprof automated testing and we can't accept changes that |
| 28 | are not helping that direction. Code coverage numbers are automatically |
| 29 | published in each pull request - we expect that number to go up. Note that |
| 30 | adding a good test often requires more time than the fix itself - this is |
| 31 | expected and you should be prepared for that time investment. |
| 32 | |
| 33 | Contributions that do not meet the above guidelines will get less attention and |
| 34 | will be slow to get accepted or won't be accepted at all. We will also likely |
| 35 | refuse to accept changes that have fairly limited audience but will require us |
| 36 | to commit to maintain them for foreseeable future. This includes support for |
| 37 | specific platforms, making internal pprof APIs public, etc. |
| 38 | |
| 39 | # Development |
| 40 | |
| 41 | The commands below assume `/tmp/pprof` as the location for the source code. |
| 42 | You can change it to a directory of your choice. |
| 43 | |
| 44 | To get the source code, run |
| 45 | |
| 46 | ``` |
| 47 | cd /tmp |
| 48 | git clone [email protected]:google/pprof.git |
| 49 | cd pprof |
| 50 | ``` |
| 51 | |
| 52 | To run the tests, do |
| 53 | |
| 54 | ``` |
| 55 | cd /tmp/pprof |
| 56 | go test -v ./... |
| 57 | (cd browsertests && go test) |
| 58 | ``` |
| 59 | |
| 60 | When you wish to work with your own fork of the source (which is required to be |
| 61 | able to create a pull request), you'll want to get your fork repo as another Git |
| 62 | remote in the same `github.com/google/pprof` directory. Otherwise, if you'll `go |
| 63 | get` your fork directly, you'll be getting errors like `use of internal package |
| 64 | not allowed` when running tests. To set up the remote do something like |
| 65 | |
| 66 | ``` |
| 67 | cd /tmp/pprof |
| 68 | git remote add aalexand [email protected]:aalexand/pprof.git |
| 69 | git fetch aalexand |
| 70 | git checkout -b my-new-feature |
| 71 | # hack hack hack |
| 72 | go test -v ./... |
| 73 | (cd browsertests && go test) |
| 74 | git commit -a -m "Add new feature." |
| 75 | git push aalexand |
| 76 | ``` |
| 77 | |
| 78 | where `aalexand` is your GitHub user ID. Then proceed to the GitHub UI to send a |
| 79 | code review. |
| 80 | |
| 81 | # The small print |
| 82 | |
| 83 | Contributions made by corporations are covered by a different agreement than the |
| 84 | one above, the [Software Grant and Corporate Contributor License |
| 85 | Agreement](https://cla.developers.google.com/about/google-corporate). |