1# Contributing Code 2 3## Communicate 4 5* Whether you're writing a new feature or fixing an existing bug, it pays to get a second opinion 6 before you get too far. If it's a new feature idea, post to the discussion group 7 ([angleproject][ANGLE-website]). 8* Not all bugs in our [bug system][anglebug.com] are assigned, but if the one you're interested in 9 fixing is, send a note to the person it's assigned to and ask if they would like a patch. 10* Behavior changes and anything nontrivial (i.e. anything other than simple cleanups and style 11 fixes) should generally be tracked in the bug system. Please [file a bug][anglebug-new] and 12 describe what you're doing if there isn't one already. 13* If you would like bug-editing rights, simply ask a team member via email or the discussion group. 14 15[ANGLE-website]: https://groups.google.com/forum/?fromgroups#!forum/angleproject 16[anglebug.com]: http://anglebug.com 17[anglebug-new]: http://anglebug.com/new 18 19## Get your code ready 20 21### Code 22 231. Must conform to the [ANGLE style][ANGLE-style] guidelines. 242. Must be tested. (see the [Testing][Testing] section below) 253. Should be a reasonable size to review. Giant patches are unlikely to get reviewed quickly. 26 27[ANGLE-style]: CodingStandard.md 28[Testing]: #Testing 29 30### Build maintenance 31 321. If you added or removed source files: 33 * You _must_ update the build files with your changes. See [`src/libGLESv2.gni`][libGLESv2.gni] 34 and [`src/compiler.gni`][compiler.gni]. 352. ANGLE's BUILD.gn script is used by [Chromium's gn build][gn-build-config]. If you change build 36 files other than to add or remove source files be aware you could break the Chromium build. 37 ANGLE's commit queue (CQ) will detect such breakage. Ask a project member for help with Chromium 38 issues if you don't have a Chromium checkout. 393. Some generated code is baked into the repository. If you modify the source of these files, such 40 as the translator's [`glslang.l`][glslang.l], or one of the internal shaders in the Vulkan 41 backend, you will need to run [`scripts/run_code_generation.py`][run_code_generation.py] and 42 include the autogenerated files in your change. 43 `git cl upload` should warn you if you are missing this step. 44 45[gn-build-config]: https://www.chromium.org/developers/gn-build-configuration 46[compiler.gni]: https://chromium.googlesource.com/angle/angle/+/refs/heads/main/src/compiler.gni 47[libGLESv2.gni]: https://chromium.googlesource.com/angle/angle/+/refs/heads/main/src/libGLESv2.gni 48[glslang.l]: https://chromium.googlesource.com/angle/angle/+/refs/heads/main/src/compiler/translator/glslang.l 49[run_code_generation.py]: https://chromium.googlesource.com/angle/angle/+/refs/heads/main/scripts/run_code_generation.py 50 51### Testing 52 53* ANGLE uses trybots to test on a variety of platforms. Please run your changes against our bots 54 and check the results before landing changes or requesting reviews. 55 * Upload your change (see [Making changes](#making-changes)). 56 * To kick off a try job, use the 'CQ Dry Run' button, or set the Commit-Queue +1 label to trigger 57 a dry run of the CQ (will not land the change). 58 * If you are not part of the `angle-committers` group, you will need to either ask to be added or 59 ask a member of the group to submit the tryjob for you. Add jmadill or geofflang as a reviewer 60 for assistance. 61 * Wait for the bots to report the result on the code review page. The bot results should be 62 visible in Gerrit as yellow (in-progress), green (passed), or red (failed). This can take up to 63 two hours for some of the debug bots. Click on the colored rectangle to open the bot log to 64 triage failed tests. 65 * If a failure is unexpected, or seems likely unrelated to your change, ask an ANGLE project 66 member for advice. 67 * We do not currently have the capability to run individual bots or tests in a run. 68* Tests can also be run locally, ANGLE's main testing methods are: 69 * `angle_unittests`, `angle_end2end_tests` and `angle_white_box_tests` targets. 70 * The OpenGL CTS also known as [drawElements Quality Program (dEQP)](dEQP.md). 71 If you're working on a new feature, there may be some extensive tests for it already written. 72 * The [Top-of-Tree WebGL Conformance tests][WebGL-CTS]. 73 * If you are a Chromium developer, see 74 [Building ANGLE for Chromium Development][build-ANGLE-for-chromium] for instructions on 75 building ANGLE within Chromium. 76 * If you aren't a browser developer, you should be able to drop your compiled DLLs into a 77 Chrome installation, in place of those distributed with Chrome, to check WebGL conformance. 78 [Chrome Canary][Chrome-Canary] is well-suited for this. 79 * If your code isn't covered by an existing test, you are *strongly encouraged* to add new test 80 coverage. This both ensures that your code is correct and that new contributors won't break it 81 in the future. 82 * Add new tests to `angle_end2end_tests` for OpenGL-based API tests, `angle_unittests` for 83 cross-platform internal tests, and `angle_white_box_tests` for rendering tests which also need 84 visibility into internal ANGLE classes. 85 * If you are submitting a performance fix, test your code with `angle_perftests` and add a new 86 performance test if it is not covered by the existing benchmarks. For more documentation on 87 `angle_perftests` see the [README][README]. 88 * The [Chromium GPU FYI bot waterfall][Chromium-waterfall] provides continuous integration for 89 ANGLE patches that have been committed. There may be hardware configurations that are not 90 tested by the ANGLE trybots, if you notice breakage on this waterfall after landing a patch, 91 please notify a project member. 92 93[WebGL-CTS]: https://www.khronos.org/registry/webgl/sdk/tests/webgl-conformance-tests.html 94[build-ANGLE-for-Chromium]: BuildingAngleForChromiumDevelopment.md 95[Chrome-Canary]: https://www.google.com/chrome/browser/canary.html 96[README]: ../src/tests/perf_tests/README.md 97[Chromium-waterfall]: https://ci.chromium.org/p/chromium/g/chromium.gpu.fyi/console 98 99### Legal 100 1011. You must complete the [Individual Contributor License Agreement][Individual-CLA]. You can do this 102 online, and it only takes a minute. If you are contributing on behalf of a corporation, you must 103 fill out the [Corporate Contributor License Agreement][Corporate-CLA] and send it to Google as 104 described on that page. 1052. Once you've submitted the CLA, please email the following information (as entered on the CLA) to 106 `shannonwoods at chromium dot org` for record keeping purposes: 107 * Full Name: 108 * Email: 109 * Company (If applicable): 1103. If you've never submitted code before, you must add your (or your organization's) name and 111 contact info to the [AUTHORS](../AUTHORS) file. 1124. *NOTE TO REVIEWERS*: Follow the [External Contributor Checklist][Contributor-checklist]. 113 114[Individual-CLA]: https://cla.developers.google.com/about/google-individual 115[Corporate-CLA]: https://cla.developers.google.com/about/google-corporate 116[Contributor-checklist]: http://www.chromium.org/developers/contributing-code/external-contributor-checklist 117 118## Life of a Change List 119 120### Getting started with Gerrit for ANGLE 121 1221. Go to [https://chromium-review.googlesource.com/new-password][CR-passwd] 1232. Log in with the email you use for your git commits. 1243. Follow the directions on the new-password page to set up authentication with your Google account. 1254. Make sure to set your real name. 126 * Visit [https://chromium-review.googlesource.com/#/settings][CR-settings] and check the "Full 127 Name" field. 1285. Check out the repository (see [DevSetup](DevSetup.md)). 1296. Install the Gerrit `commit_msg` hook 130 * Gerrit requires a hook to append a change ID tag to each commit, so that it can associate your 131 CL with a particular review, and track dependencies between commits. 132 * Download the hook from 133 [https://chromium-review.googlesource.com/tools/hooks/commit-msg][commit-msg-hook] and copy 134 this file to `.git/hooks/commit-msg` within your local repository. On non-Windows platforms, 135 ensure that permissions are set to allow execution. 136 * *BE AWARE:* Some patch management tools, such as StGit, currently bypass git hooks. They should 137 not currently be used with changes intended for review. 138 139[CR-passwd]: https://chromium-review.googlesource.com/new-password 140[CR-settings]: https://chromium-review.googlesource.com/#/settings 141[commit-msg-hook]: https://chromium-review.googlesource.com/tools/hooks/commit-msg 142 143### Making changes 144 1451. Commit your changes locally: 146 * `git add src/../FileName.cpp` 147 * `git commit` 148 * A text editor will open. Add a description at the top of the file. 149 * Associate the CL with an issue in the issue tracker (e.g. a fix for a reported bug) 150 by adding the following line to the commit message: `Bug: angleproject:<issue number>`. 151 * If necessary please file a new bug at http://anglebug.com/new 152 * Save. 153 * Close the text editor. 154 * Use `git commit --amend` to update your CL with new changes. 155 * Use `git cl format` to amend the style of your CL. This saves both your time and the reviewers'! 1562. Ensure your code is landed on top of latest changes 157 * `git pull --rebase` 158 * Resolve conflicts if necessary 1593. Upload the change list 160 * `git cl upload` 161 * The change list and modified files will be uploaded to [ANGLE Gerrit][ANGLE-Gerrit]. 162 * Follow the generated URL to the new issue. 163 * Take a moment to perform a self-review of your code. Gerrit's viewer makes it easy to see 164 whitespace errors, erroneous tabs, and other simple style problems. 165 * [Select reviewers](#selecting-reviewers). If you don't do this, reviewers may not realize 166 you're requesting a review! 167 * Make changes, upload and repeat as necessary. 168 * Project members and others will review your code as described in the 169 [CodeReviewProcess](CodeReviewProcess.md). 1705. If your change list needs revision: 171 * If you have correctly installed the commit hook from the section above, Gerrit will be able to 172 track your changes by Change-Id. 173 * You should need only to update your commit with `git commit --amend` and re-upload with 174 `git cl upload`. 1756. Landing change after it receives +2 Code Review: 176 * If you are a committer, you may submit the change yourself via the Gerrit web interface. 177 * If you are not a committer, ask your reviewer to submit the change list. 1787. Pull and integrate reviewed CL: 179 * `git pull --rebase` 180 181[ANGLE-Gerrit]: https://chromium-review.googlesource.com/q/project:angle/angle 182 183### Selecting reviewers 184 185When your CL is ready to review, you can use the "Find Owners" button in 186Gerrit to select appropriate code reviewers. They will be able to route your 187CL to additional reviewers as neccessary and answer any questions you may have 188about the process. 189 190### Rules for submission 191 192 * At least one **Owner** must give approval. 193 * The owner must be from the **most specific** directory. 194 * At least two **Committers** must give approval for non-trival CLs. 195 For trivial CLs, a single Owner approval is sufficient. 196 * Only **Committers** may submit CLs. If you aren't a committer please ask for help submitting. 197 * Committers may submit high-priority small CLs immediately using **TBR**. 198 See [the Chromium docs][TBR] for more info. 199 * There are exceptions to these rules. Use your best judgement. 200 201[TBR]: https://chromium.googlesource.com/chromium/src/+/main/docs/code_reviews.md#tbr-to-be-reviewed 202 203### Reverting a CL 204 205Sometimes a change will cause an unforseen problem, e.g. on a platform that's not tested with 206pre-submit testing. In those cases, a CL may be reverted; often by a "[Wrangler][wrangler]", who is 207an engineer who keeps the testing infrastructure healthy/green. 208 209[wrangler]: ../infra/ANGLEWrangling.md 210 211The best and easiest way to create a revert change is with Gerrit's **REVERT** button, in the 212upper-right corner of the original change. Pressing this will pop up a dialog with a template 213commit message, and an optional checkbox for automatically sending the revert CL to CQ. Please edit 214the commit message with the reason for the revert. When satisfied, press the dialog's **REVERT** 215button. It is wise to add the author and reviewers of the original CL as reviewers of the revert 216CL. If it's been less than 24 hours since the original CL landed, the revert Cl will land 217immediately and bypass the try bots. 218 219If you cannot use Gerrit's **REVERT** button, you can create a revert CL with the "git revert" 220command. When doing so, the commit message should include a short description for why the original 221commit needs to be reverted, and potentially a bug; similar to this example [revert CL][RevertCL]. 222 223[RevertCL]: https://chromium-review.googlesource.com/c/chromium/src/+/2453504 224 225 226### Relanding a reverted CL 227 228When you re-land a reverted CL, follow this process: 229 230 * Prefix the CL title with "Reland: ". 231 * Keep the commit message of the original CL and add a description of what changed in the re-land. 232 * Ensure the re-land CL has a unique Change-Id. 233 * First upload the reverted CL as Patchset 1 with no changes applied. 234 * Then, apply your fixes, and upload your CL as a new Patchset. The reviewers will be able to see 235 the diff between Patchset 1 and the fixed/final Patchset. 236 237Here is an example [reland CL][RelandCL]. This [link][RelandCLDiff] shows the difference between Patchset 1 238and the fixed/final Patchset. Notice how a reviewer can easily see the fix to the original CL. 239 240[RelandCL]: https://chromium-review.googlesource.com/c/angle/angle/+/2197735 241[RelandCLDiff]: https://chromium-review.googlesource.com/c/angle/angle/+/2197735/1..3 242 243If you do not need to make any changes to your CL to re-land, you can instead use Gerrit's **CREATE 244RELAND** button. 245 246### Committer status 247 248Similar to [Chromium's committer status][Committer-status], long-term contributors to the ANGLE 249project may request to join the `angle-committers` group. This allows you to give `+2` on code 250reviews and land patches without assistance. After about 6 months of regular contributions, you may 251request committer status from a core ANGLE team member via email or code review. Chromium 252committers and Googlers may ask at any time. 253 254### OWNERS files and becoming an Owner 255 256See these Chromium docs for some good guidelines: [link][Owners]. 257 258### More info 259 260See also: 261 262* [ANGLE Gerrit][ANGLE-Gerrit] 263* [Chromium Projects: Contributing Code][Contributing-code] 264* [depot_tools tutorial][depot-tools-tutorial] 265* [angle_perftests README][Perftest-README] 266 267[Committer-status]: https://dev.chromium.org/getting-involved/become-a-committer 268[Contributing-code]: http://www.chromium.org/developers/contributing-code/ 269[depot-tools-tutorial]: http://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html 270[Perftest-README]: ../src/tests/perf_tests/README.md 271[Owners]: https://chromium.googlesource.com/chromium/src/+/main/docs/code_reviews.md#expectations-of-owners 272