Marian Harbach | ebeb154 | 2019-12-13 10:42:46 +0100 | [diff] [blame] | 1 | :linkattrs: |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 2 | = Gerrit Code Review - Building with Bazel |
| 3 | |
Han-Wen Nienhuys | 1e31803 | 2020-01-08 16:53:08 +0100 | [diff] [blame] | 4 | [[summary]] |
| 5 | == TL;DR |
| 6 | |
| 7 | If you have the prerequisites, running |
| 8 | |
| 9 | ``` |
| 10 | $ bazel build gerrit |
| 11 | ``` |
| 12 | |
| 13 | should generate a .war file under `bazel-bin/gerrit.war`. |
| 14 | |
Alice Kober-Sotzek | d9da89f | 2016-11-25 12:02:18 +0100 | [diff] [blame] | 15 | [[installation]] |
Olivier Croquette | a909119 | 2018-01-14 20:20:56 +0100 | [diff] [blame] | 16 | == Prerequisites |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 17 | |
Olivier Croquette | a909119 | 2018-01-14 20:20:56 +0100 | [diff] [blame] | 18 | To build Gerrit from source, you need: |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 19 | |
Olivier Croquette | a909119 | 2018-01-14 20:20:56 +0100 | [diff] [blame] | 20 | * A Linux or macOS system (Windows is not supported at this time) |
David Ostrovsky | 21a891c | 2020-12-19 12:57:06 +0100 | [diff] [blame] | 21 | * A JDK for Java 11 or Java 17 |
David Ostrovsky | 2b5fe09 | 2021-03-03 11:52:30 +0100 | [diff] [blame] | 22 | * Python 3 |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 23 | * link:https://github.com/nodesource/distributions/blob/master/README.md[Node.js (including npm),role=external,window=_blank] |
Ben Rohlfs | 11876a4 | 2020-04-27 10:16:51 +0200 | [diff] [blame] | 24 | * Bower (`npm install -g bower`) |
David Pursehouse | bfe2d14 | 2020-01-29 18:02:53 +0900 | [diff] [blame] | 25 | * link:https://docs.bazel.build/versions/master/install.html[Bazel,role=external,window=_blank] -launched with |
| 26 | link:https://github.com/bazelbuild/bazelisk[Bazelisk,role=external,window=_blank] |
Han-Wen Nienhuys | f66222f | 2018-04-18 14:11:40 +0200 | [diff] [blame] | 27 | * Maven |
| 28 | * zip, unzip |
Christian Aistleitner | 5334506 | 2020-04-27 14:37:08 +0200 | [diff] [blame] | 29 | * curl |
Han-Wen Nienhuys | f66222f | 2018-04-18 14:11:40 +0200 | [diff] [blame] | 30 | * gcc |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 31 | |
Marco Miller | 9bede91 | 2020-01-27 17:38:40 -0500 | [diff] [blame] | 32 | [[bazel]] |
| 33 | === Bazel |
| 34 | |
Ben Rohlfs | 11876a4 | 2020-04-27 10:16:51 +0200 | [diff] [blame] | 35 | link:https://github.com/bazelbuild/bazelisk[Bazelisk,role=external,window=_blank] is a version |
| 36 | manager for link:https://bazel.build/[Bazel,role=external,window=_blank], similar to how `nvm` |
| 37 | manages `npm` versions. It takes care of downloading and installing Bazel itself, so you don't have |
Clark Boylan | 8784a6c | 2023-09-27 16:35:19 -0700 | [diff] [blame] | 38 | to worry about using the correct version of Bazel. One particular advantage to |
| 39 | using Bazelisk is that you can jump between different versions of Gerrit and not |
| 40 | worry about which version of Bazel you need. |
| 41 | |
| 42 | Bazelisk can be installed in different ways: |
| 43 | link:https://docs.bazel.build/install-bazelisk.html[Bazelisk Installation,role=external,window=_blank]. |
| 44 | To execute the correct version of Bazel using Bazelisk you simply replace |
| 45 | the `bazel` command with `bazelisk`. |
Marco Miller | 9bede91 | 2020-01-27 17:38:40 -0500 | [diff] [blame] | 46 | |
David Pursehouse | c8b633d | 2019-05-08 08:36:18 +0900 | [diff] [blame] | 47 | [[java]] |
| 48 | === Java |
| 49 | |
Matthias Sohn | 8278667 | 2021-02-25 17:19:53 +0100 | [diff] [blame] | 50 | Ensure that the link:install.html#Requirements[required Java version] |
| 51 | is installed and that `JAVA_HOME` is set to it. |
Alice Kober-Sotzek | a8029b6 | 2019-05-07 19:13:00 +0200 | [diff] [blame] | 52 | |
| 53 | To check the installed version of Java, open a terminal window and run: |
| 54 | |
| 55 | `java -version` |
| 56 | |
David Ostrovsky | b89332d | 2020-04-27 07:06:24 +0200 | [diff] [blame] | 57 | [[java-11]] |
| 58 | ==== Java 11 support |
| 59 | |
David Ostrovsky | 2f23187 | 2022-01-11 21:51:15 +0100 | [diff] [blame] | 60 | To build Gerrit with Java 11 language level, run: |
David Ostrovsky | b89332d | 2020-04-27 07:06:24 +0200 | [diff] [blame] | 61 | |
| 62 | ``` |
Jacek Centkowski | 8f91b02 | 2023-11-16 21:56:46 +0100 | [diff] [blame] | 63 | $ bazelisk build --config=java11 :release |
David Ostrovsky | b89332d | 2020-04-27 07:06:24 +0200 | [diff] [blame] | 64 | ``` |
| 65 | |
David Ostrovsky | 21a891c | 2020-12-19 12:57:06 +0100 | [diff] [blame] | 66 | [[java-17]] |
| 67 | ==== Java 17 support |
David Pursehouse | c8b633d | 2019-05-08 08:36:18 +0900 | [diff] [blame] | 68 | |
David Ostrovsky | 21a891c | 2020-12-19 12:57:06 +0100 | [diff] [blame] | 69 | Java 17 is supported. To build Gerrit with Java 17, run: |
David Ostrovsky | f55b69f | 2018-08-23 08:25:24 +0200 | [diff] [blame] | 70 | |
| 71 | ``` |
Jacek Centkowski | 8f91b02 | 2023-11-16 21:56:46 +0100 | [diff] [blame] | 72 | $ bazelisk build :release |
David Ostrovsky | f55b69f | 2018-08-23 08:25:24 +0200 | [diff] [blame] | 73 | ``` |
| 74 | |
David Ostrovsky | 21a891c | 2020-12-19 12:57:06 +0100 | [diff] [blame] | 75 | To run the tests with Java 17, run: |
David Ostrovsky | 0bceb04 | 2018-08-25 07:37:54 +0200 | [diff] [blame] | 76 | |
| 77 | ``` |
Diego Zambelli Sessona | 23acbe4 | 2023-11-17 15:49:36 +0100 | [diff] [blame] | 78 | $ bazelisk test //... |
David Ostrovsky | 0bceb04 | 2018-08-25 07:37:54 +0200 | [diff] [blame] | 79 | ``` |
| 80 | |
Alice Kober-Sotzek | 79290dc | 2019-05-07 19:26:18 +0200 | [diff] [blame] | 81 | === Node.js and npm packages |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 82 | See link:https://gerrit.googlesource.com/gerrit/+/master/polygerrit-ui/README.md#installing-node_js-and-npm-packages[Installing Node.js and npm packages,role=external,window=_blank]. |
Alice Kober-Sotzek | 79290dc | 2019-05-07 19:26:18 +0200 | [diff] [blame] | 83 | |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 84 | [[build]] |
| 85 | == Building on the Command Line |
| 86 | |
| 87 | === Gerrit Development WAR File |
| 88 | |
David Ostrovsky | 7163dac | 2017-07-29 06:49:38 +0200 | [diff] [blame] | 89 | To build the Gerrit web application: |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 90 | |
| 91 | ---- |
Clark Boylan | 8784a6c | 2023-09-27 16:35:19 -0700 | [diff] [blame] | 92 | bazelisk build gerrit |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 93 | ---- |
| 94 | |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 95 | The output executable WAR will be placed in: |
| 96 | |
| 97 | ---- |
| 98 | bazel-bin/gerrit.war |
| 99 | ---- |
| 100 | |
Edwin Kempin | 976dc0b | 2016-11-14 16:34:50 -0800 | [diff] [blame] | 101 | [[release]] |
Edwin Kempin | 3cfce17 | 2016-11-14 16:17:17 -0800 | [diff] [blame] | 102 | === Gerrit Release WAR File |
| 103 | |
Ben Rohlfs | da0a62b | 2021-04-26 17:02:19 +0200 | [diff] [blame] | 104 | To build the Gerrit web application that includes the Gerrit UI, |
David Ostrovsky | 7163dac | 2017-07-29 06:49:38 +0200 | [diff] [blame] | 105 | core plugins and documentation: |
Edwin Kempin | 3cfce17 | 2016-11-14 16:17:17 -0800 | [diff] [blame] | 106 | |
| 107 | ---- |
Clark Boylan | 8784a6c | 2023-09-27 16:35:19 -0700 | [diff] [blame] | 108 | bazelisk build release |
Edwin Kempin | 3cfce17 | 2016-11-14 16:17:17 -0800 | [diff] [blame] | 109 | ---- |
| 110 | |
| 111 | The output executable WAR will be placed in: |
| 112 | |
| 113 | ---- |
| 114 | bazel-bin/release.war |
| 115 | ---- |
| 116 | |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 117 | === Headless Mode |
| 118 | |
Ben Rohlfs | da0a62b | 2021-04-26 17:02:19 +0200 | [diff] [blame] | 119 | To build Gerrit in headless mode, i.e. without the Gerrit UI: |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 120 | |
| 121 | ---- |
Clark Boylan | 8784a6c | 2023-09-27 16:35:19 -0700 | [diff] [blame] | 122 | bazelisk build headless |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 123 | ---- |
| 124 | |
| 125 | The output executable WAR will be placed in: |
| 126 | |
| 127 | ---- |
Edwin Kempin | 03eaa9a | 2016-11-14 15:45:51 -0800 | [diff] [blame] | 128 | bazel-bin/headless.war |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 129 | ---- |
| 130 | |
| 131 | === Extension and Plugin API JAR Files |
| 132 | |
David Ostrovsky | 7163dac | 2017-07-29 06:49:38 +0200 | [diff] [blame] | 133 | To build the extension, plugin and acceptance-framework JAR files: |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 134 | |
| 135 | ---- |
Clark Boylan | 8784a6c | 2023-09-27 16:35:19 -0700 | [diff] [blame] | 136 | bazelisk build api |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 137 | ---- |
| 138 | |
David Ostrovsky | 26f8da8 | 2016-12-24 09:29:33 +0100 | [diff] [blame] | 139 | The output archive that contains Java binaries, Java sources and |
| 140 | Java docs will be placed in: |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 141 | |
| 142 | ---- |
Luca Milanesio | 5bd7b9b | 2019-06-10 10:01:02 +0100 | [diff] [blame] | 143 | bazel-bin/api.zip |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 144 | ---- |
| 145 | |
David Ostrovsky | 7163dac | 2017-07-29 06:49:38 +0200 | [diff] [blame] | 146 | Install {extension,plugin,acceptance-framework}-api to the local |
| 147 | maven repository: |
David Ostrovsky | 50785fd | 2016-10-28 09:17:14 +0200 | [diff] [blame] | 148 | |
| 149 | ---- |
Edwin Kempin | d3bb302 | 2017-01-24 11:28:34 +0100 | [diff] [blame] | 150 | tools/maven/api.sh install |
David Ostrovsky | 50785fd | 2016-10-28 09:17:14 +0200 | [diff] [blame] | 151 | ---- |
| 152 | |
| 153 | Install gerrit.war to the local maven repository: |
| 154 | |
| 155 | ---- |
Edwin Kempin | d3bb302 | 2017-01-24 11:28:34 +0100 | [diff] [blame] | 156 | tools/maven/api.sh war_install |
David Ostrovsky | 50785fd | 2016-10-28 09:17:14 +0200 | [diff] [blame] | 157 | ---- |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 158 | |
| 159 | === Plugins |
| 160 | |
David Ostrovsky | af71968 | 2016-09-28 20:31:18 +0200 | [diff] [blame] | 161 | ---- |
Clark Boylan | 8784a6c | 2023-09-27 16:35:19 -0700 | [diff] [blame] | 162 | bazelisk build plugins:core |
David Ostrovsky | af71968 | 2016-09-28 20:31:18 +0200 | [diff] [blame] | 163 | ---- |
| 164 | |
| 165 | The output JAR files for individual plugins will be placed in: |
| 166 | |
| 167 | ---- |
Luca Milanesio | 5bd7b9b | 2019-06-10 10:01:02 +0100 | [diff] [blame] | 168 | bazel-bin/plugins/<name>/<name>.jar |
David Ostrovsky | af71968 | 2016-09-28 20:31:18 +0200 | [diff] [blame] | 169 | ---- |
| 170 | |
| 171 | The JAR files will also be packaged in: |
| 172 | |
| 173 | ---- |
Luca Milanesio | 5bd7b9b | 2019-06-10 10:01:02 +0100 | [diff] [blame] | 174 | bazel-bin/plugins/core.zip |
David Ostrovsky | af71968 | 2016-09-28 20:31:18 +0200 | [diff] [blame] | 175 | ---- |
| 176 | |
| 177 | To build a specific plugin: |
| 178 | |
| 179 | ---- |
Clark Boylan | 8784a6c | 2023-09-27 16:35:19 -0700 | [diff] [blame] | 180 | bazelisk build plugins/<name> |
David Ostrovsky | af71968 | 2016-09-28 20:31:18 +0200 | [diff] [blame] | 181 | ---- |
| 182 | |
| 183 | The output JAR file will be be placed in: |
| 184 | |
| 185 | ---- |
Luca Milanesio | 5bd7b9b | 2019-06-10 10:01:02 +0100 | [diff] [blame] | 186 | bazel-bin/plugins/<name>/<name>.jar |
David Ostrovsky | af71968 | 2016-09-28 20:31:18 +0200 | [diff] [blame] | 187 | ---- |
| 188 | |
| 189 | Note that when building an individual plugin, the `core.zip` package |
| 190 | is not regenerated. |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 191 | |
Han-Wen Nienhuys | 8ba8abe | 2016-10-25 15:54:28 +0200 | [diff] [blame] | 192 | [[IDEs]] |
| 193 | == Using an IDE. |
| 194 | |
| 195 | === IntelliJ |
| 196 | |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 197 | The Gerrit build works with Bazel's link:https://ij.bazel.build[IntelliJ plugin,role=external,window=_blank]. |
Alice Kober-Sotzek | d9da89f | 2016-11-25 12:02:18 +0100 | [diff] [blame] | 198 | Please follow the instructions on <<dev-intellij#,IntelliJ Setup>>. |
David Ostrovsky | c69f360 | 2016-11-13 08:01:08 -0800 | [diff] [blame] | 199 | |
| 200 | === Eclipse |
| 201 | |
| 202 | ==== Generating the Eclipse Project |
| 203 | |
| 204 | Create the Eclipse project: |
| 205 | |
| 206 | ---- |
David Pursehouse | 7e43d1d | 2017-01-24 08:45:16 +0900 | [diff] [blame] | 207 | tools/eclipse/project.py |
David Ostrovsky | c69f360 | 2016-11-13 08:01:08 -0800 | [diff] [blame] | 208 | ---- |
| 209 | |
| 210 | and then follow the link:dev-eclipse.html#setup[setup instructions]. |
| 211 | |
| 212 | ==== Refreshing the Classpath |
| 213 | |
| 214 | If an updated classpath is needed, the Eclipse project can be |
| 215 | refreshed and missing dependency JARs can be downloaded by running |
David Pursehouse | 7e43d1d | 2017-01-24 08:45:16 +0900 | [diff] [blame] | 216 | `project.py` again. For IntelliJ, you need to click the `Sync Project |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 217 | with BUILD Files` button of link:https://ij.bazel.build[Bazel plugin,role=external,window=_blank]. |
David Ostrovsky | c69f360 | 2016-11-13 08:01:08 -0800 | [diff] [blame] | 218 | |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 219 | [[documentation]] |
Nasser Grainawi | a55b20d | 2021-03-08 11:52:01 -0700 | [diff] [blame] | 220 | == Documentation |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 221 | |
David Ostrovsky | 9413ff8 | 2016-10-25 00:02:17 +0200 | [diff] [blame] | 222 | To build only the documentation for testing or static hosting: |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 223 | |
David Ostrovsky | 9413ff8 | 2016-10-25 00:02:17 +0200 | [diff] [blame] | 224 | ---- |
Clark Boylan | 8784a6c | 2023-09-27 16:35:19 -0700 | [diff] [blame] | 225 | bazelisk build Documentation:searchfree |
David Ostrovsky | 9413ff8 | 2016-10-25 00:02:17 +0200 | [diff] [blame] | 226 | ---- |
| 227 | |
| 228 | The html files will be bundled into `searchfree.zip` in this location: |
| 229 | |
| 230 | ---- |
| 231 | bazel-bin/Documentation/searchfree.zip |
| 232 | ---- |
| 233 | |
Luca Milanesio | dcd5bbe | 2023-06-19 14:56:52 +0100 | [diff] [blame] | 234 | To use local fonts with the searchfree target: |
| 235 | |
| 236 | ---- |
| 237 | bazel build Documentation:searchfree_safe |
| 238 | ---- |
| 239 | |
| 240 | The html files will be bundled into `searchfree.zip` or `searchfree_safe.zip` in this location: |
| 241 | |
| 242 | ---- |
| 243 | bazel-bin/Documentation/searchfree.zip |
| 244 | bazel-bin/Documentation/searchfree_safe.zip |
| 245 | ---- |
| 246 | |
Antoine Musso | 8e4ae54 | 2020-12-22 12:09:16 +0100 | [diff] [blame] | 247 | To generate HTML files skipping the zip archiving: |
| 248 | |
| 249 | ---- |
Clark Boylan | 8784a6c | 2023-09-27 16:35:19 -0700 | [diff] [blame] | 250 | bazelisk build Documentation |
Antoine Musso | 8e4ae54 | 2020-12-22 12:09:16 +0100 | [diff] [blame] | 251 | ---- |
| 252 | |
| 253 | And open `bazel-bin/Documentation/index.html`. |
| 254 | |
| 255 | To build the Gerrit executable WAR with the documentation included: |
David Ostrovsky | 9413ff8 | 2016-10-25 00:02:17 +0200 | [diff] [blame] | 256 | |
| 257 | ---- |
Clark Boylan | 8784a6c | 2023-09-27 16:35:19 -0700 | [diff] [blame] | 258 | bazelisk build withdocs |
David Ostrovsky | 9413ff8 | 2016-10-25 00:02:17 +0200 | [diff] [blame] | 259 | ---- |
| 260 | |
| 261 | The WAR file will be placed in: |
| 262 | |
| 263 | ---- |
| 264 | bazel-bin/withdocs.war |
| 265 | ---- |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 266 | |
Antoine Musso | 524b056 | 2020-11-18 10:36:05 +0100 | [diff] [blame] | 267 | Alternatively, one can generate the documentation as flat files: |
| 268 | |
| 269 | ---- |
Clark Boylan | 8784a6c | 2023-09-27 16:35:19 -0700 | [diff] [blame] | 270 | bazelisk build Documentation:Documentation |
Antoine Musso | 524b056 | 2020-11-18 10:36:05 +0100 | [diff] [blame] | 271 | ---- |
| 272 | |
| 273 | The html, css, js files are placed in: |
| 274 | |
| 275 | ---- |
| 276 | `bazel-bin/Documentation/` |
| 277 | ---- |
| 278 | |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 279 | [[tests]] |
| 280 | == Running Unit Tests |
| 281 | |
Clark Boylan | 8784a6c | 2023-09-27 16:35:19 -0700 | [diff] [blame] | 282 | Bazel BUILD files define test targets for Gerrit. You can run all declared |
| 283 | test targets with: |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 284 | |
| 285 | ---- |
Clark Boylan | 8784a6c | 2023-09-27 16:35:19 -0700 | [diff] [blame] | 286 | bazelisk test --build_tests_only //... |
Edwin Kempin | d31903c | 2016-11-14 17:01:44 -0800 | [diff] [blame] | 287 | ---- |
| 288 | |
Clark Boylan | 8784a6c | 2023-09-27 16:35:19 -0700 | [diff] [blame] | 289 | [[testgroups]] |
| 290 | === Running Test Groups |
| 291 | |
| 292 | To run one or more specific labeled groups of tests: |
Edwin Kempin | d31903c | 2016-11-14 17:01:44 -0800 | [diff] [blame] | 293 | |
| 294 | ---- |
Clark Boylan | 8784a6c | 2023-09-27 16:35:19 -0700 | [diff] [blame] | 295 | bazelisk test --test_tag_filters=api,git //... |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 296 | ---- |
| 297 | |
Clark Boylan | 8784a6c | 2023-09-27 16:35:19 -0700 | [diff] [blame] | 298 | The following label values are currently supported for the group name: |
David Pursehouse | 4444518 | 2017-02-22 15:59:17 +0900 | [diff] [blame] | 299 | |
| 300 | * annotation |
| 301 | * api |
| 302 | * edit |
| 303 | * git |
David Pursehouse | 180bca5 | 2019-12-04 20:05:07 +0900 | [diff] [blame] | 304 | * git-protocol-v2 |
David Ostrovsky | 61a44ae | 2020-05-14 08:29:54 +0200 | [diff] [blame] | 305 | * git-upload-archive |
David Pursehouse | 4444518 | 2017-02-22 15:59:17 +0900 | [diff] [blame] | 306 | * notedb |
| 307 | * pgm |
| 308 | * rest |
| 309 | * server |
| 310 | * ssh |
| 311 | |
Clark Boylan | 8784a6c | 2023-09-27 16:35:19 -0700 | [diff] [blame] | 312 | We can also select tests within a specific BUILD target group. For example |
| 313 | `javatests/com/google/gerrit/acceptance/rest/account/BUILD` declares a |
| 314 | rest_account test target group: |
| 315 | |
| 316 | ---- |
| 317 | bazelisk test //javatests/com/google/gerrit/acceptance/rest/account:rest_account |
| 318 | ---- |
| 319 | |
| 320 | [[debugtests]] |
| 321 | === Debugging Tests |
| 322 | |
| 323 | To debug specific tests you will need to select the test target containing |
| 324 | that test then use `--test_filter` to select the specific test you want. |
| 325 | This `--test_filter` is a regex and can be used to select multiple tests |
| 326 | out of the target: |
| 327 | |
| 328 | ---- |
| 329 | bazelisk test --test_output=streamed --test_filter=com.gerrit.TestClass.testMethod testTarget |
| 330 | ---- |
| 331 | |
| 332 | For example `javatests/com/google/gerrit/acceptance/api/change/BUILD` |
| 333 | defines a test target group for every `*IT.java` file in the directory. |
| 334 | We can execute the single `getAmbiguous()` test found in ChangeIT.java using |
| 335 | this `--test_filter` and target: |
| 336 | |
| 337 | ---- |
| 338 | bazelisk test --test_output=streamed \ |
| 339 | --test_filter=com.google.gerrit.acceptance.api.change.ChangeIT.getAmbiguous \ |
| 340 | //javatests/com/google/gerrit/acceptance/api/change:ChangeIT |
| 341 | ---- |
| 342 | |
| 343 | [[additionaltestfiltering]] |
| 344 | === Additional Test Filtering |
| 345 | |
| 346 | To run only tests that do not use SSH: |
| 347 | |
| 348 | ---- |
| 349 | bazelisk test --test_env=GERRIT_USE_SSH=NO //... |
| 350 | ---- |
| 351 | |
| 352 | To exclude tests that have been marked as flaky: |
| 353 | |
| 354 | ---- |
| 355 | bazelisk test --test_tag_filters=-flaky //... |
| 356 | ---- |
| 357 | |
| 358 | To exclude tests that require very recent git client version: |
| 359 | |
| 360 | ---- |
| 361 | bazelisk test --test_tag_filters=-git-protocol-v2 //... |
| 362 | ---- |
| 363 | |
| 364 | To run the tests against a specific index backend (LUCENE, FAKE): |
| 365 | ---- |
| 366 | bazelisk test --test_env=GERRIT_INDEX_TYPE=LUCENE //... |
| 367 | ---- |
| 368 | |
Nasser Grainawi | 02f5345 | 2021-02-19 08:17:49 -0700 | [diff] [blame] | 369 | Bazel itself supports a multitude of ways to |
Clark Boylan | 8784a6c | 2023-09-27 16:35:19 -0700 | [diff] [blame] | 370 | link:https://bazel.build/run/build#specifying-build-targets[specify targets,role=external,window=_blank] |
Nasser Grainawi | 02f5345 | 2021-02-19 08:17:49 -0700 | [diff] [blame] | 371 | for fine-grained test selection that can be combined with many of the examples |
| 372 | above. |
| 373 | |
Clark Boylan | 8784a6c | 2023-09-27 16:35:19 -0700 | [diff] [blame] | 374 | [[testcaching]] |
| 375 | === Test Caching |
| 376 | |
| 377 | By default Bazel caches test results and will not reexecute tests unless they |
| 378 | or their dependencies have been modified. To ignore cached test results and |
| 379 | force the tests to rerun: |
| 380 | |
| 381 | ---- |
| 382 | bazelisk test --cache_test_results=NO //... |
| 383 | ---- |
| 384 | |
| 385 | [[plugintests]] |
| 386 | === Running Plugin Tests |
| 387 | |
| 388 | Running tests for Gerrit plugins follows the process above. From within the |
| 389 | Gerrit project root with the desired plugins checked out into `plugins/` we |
| 390 | execute Bazel with the appropriate target: |
| 391 | |
| 392 | ---- |
| 393 | bazelisk test //plugins/replication/... |
| 394 | ---- |
| 395 | |
Edwin Kempin | 08a0f27 | 2023-12-18 14:48:17 +0000 | [diff] [blame] | 396 | [[known-issues]] |
| 397 | === Known Issues |
| 398 | |
| 399 | [[byte-buddy-not-initialized-or-unavailable]] |
| 400 | ==== The Byte Buddy agent is not initialized or unavailable |
| 401 | |
| 402 | If running tests that make use of mocks fail with the exception below, set the |
| 403 | `sandbox_tmpfs_path` flag for running tests in `.bazelrc` as described in this |
| 404 | link:https://github.com/mockito/mockito/issues/1879#issuecomment-922459131[ |
| 405 | issue], e.g. add this line: `test --sandbox_tmpfs_path=/tmp` |
| 406 | |
| 407 | .Exception: |
| 408 | ---- |
| 409 | ... |
| 410 | Caused by: org.mockito.exceptions.base.MockitoInitializationException: |
| 411 | Could not initialize inline Byte Buddy mock maker. |
| 412 | |
| 413 | It appears as if your JDK does not supply a working agent attachment mechanism. |
| 414 | ... |
| 415 | Caused by: java.lang.IllegalStateException: The Byte Buddy agent is not initialized or unavailable |
| 416 | at net.bytebuddy.agent.ByteBuddyAgent.getInstrumentation(ByteBuddyAgent.java:230) |
| 417 | at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:617) |
| 418 | at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:568) |
| 419 | at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:545) |
| 420 | at org.mockito.internal.creation.bytebuddy.InlineDelegateByteBuddyMockMaker.<clinit>(InlineDelegateByteBuddyMockMaker.java:115) |
| 421 | ... 47 more |
| 422 | ---- |
| 423 | |
Saša Živkov | 1b716dd | 2021-03-12 17:03:33 +0100 | [diff] [blame] | 424 | [[debugging-tests]] |
| 425 | == Debugging Unit Tests |
| 426 | In some cases it may be necessary to debug a test while running it in bazel. For example, when we |
| 427 | observe a different test result in Eclipse and bazel. Using the `--java_debug` option will start the |
| 428 | JVM in debug mode and await for a remote debugger to attach. |
| 429 | |
| 430 | Example: |
| 431 | [source,bash] |
| 432 | ---- |
Clark Boylan | 8784a6c | 2023-09-27 16:35:19 -0700 | [diff] [blame] | 433 | bazelisk test --java_debug --test_tag_filters=delete-project //... |
Saša Živkov | 1b716dd | 2021-03-12 17:03:33 +0100 | [diff] [blame] | 434 | ... |
| 435 | Listening for transport dt_socket at address: 5005 |
| 436 | ... |
| 437 | ---- |
| 438 | |
| 439 | Now attach with a debugger to the port `5005`. For example use "Remote Java Application" launch |
Martin Fick | 6b67d57 | 2023-04-04 14:23:14 -0600 | [diff] [blame] | 440 | configuration in Eclipse and specify the port `5005`. |
Saša Živkov | 1b716dd | 2021-03-12 17:03:33 +0100 | [diff] [blame] | 441 | |
David Ostrovsky | 17ef127 | 2020-02-16 14:51:07 +0100 | [diff] [blame] | 442 | [[logging]] |
| 443 | === Controlling logging level |
Hamza Kaced | c54e6b5 | 2020-01-24 12:59:09 -0500 | [diff] [blame] | 444 | |
David Ostrovsky | 17ef127 | 2020-02-16 14:51:07 +0100 | [diff] [blame] | 445 | Per default, logging level is set to `INFO` level for all tests. The `DEBUG` |
| 446 | log level can be enabled for the tests. |
Hamza Kaced | c54e6b5 | 2020-01-24 12:59:09 -0500 | [diff] [blame] | 447 | |
David Ostrovsky | 17ef127 | 2020-02-16 14:51:07 +0100 | [diff] [blame] | 448 | In IDE, set `-Dgerrit.logLevel=debug` as a VM argument. With `bazel`, pass |
| 449 | `GERRIT_LOG_LEVEL=debug` environment variable: |
Hamza Kaced | c54e6b5 | 2020-01-24 12:59:09 -0500 | [diff] [blame] | 450 | |
| 451 | ---- |
Clark Boylan | 8784a6c | 2023-09-27 16:35:19 -0700 | [diff] [blame] | 452 | bazelisk test --test_filter=com.google.gerrit.server.notedb.ChangeNotesTest \ |
| 453 | --test_env=GERRIT_LOG_LEVEL=debug \ |
| 454 | javatests/com/google/gerrit/server:server_tests |
Hamza Kaced | c54e6b5 | 2020-01-24 12:59:09 -0500 | [diff] [blame] | 455 | ---- |
| 456 | |
David Ostrovsky | 17ef127 | 2020-02-16 14:51:07 +0100 | [diff] [blame] | 457 | The log results can be found in: |
| 458 | `bazel-testlogs/javatests/com/google/gerrit/server/server_tests/test.log`. |
| 459 | |
| 460 | |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 461 | == Dependencies |
| 462 | |
Han-Wen Nienhuys | 314fb11 | 2016-11-14 10:04:02 -0800 | [diff] [blame] | 463 | Dependency JARs are normally downloaded as needed, but you can |
| 464 | download everything upfront. This is useful to enable |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 465 | subsequent builds to run without network access: |
| 466 | |
| 467 | ---- |
Clark Boylan | 8784a6c | 2023-09-27 16:35:19 -0700 | [diff] [blame] | 468 | bazelisk fetch //... |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 469 | ---- |
| 470 | |
| 471 | When downloading from behind a proxy (which is common in some corporate |
| 472 | environments), it might be necessary to explicitly specify the proxy that |
| 473 | is then used by `curl`: |
| 474 | |
| 475 | ---- |
| 476 | export http_proxy=http://<proxy_user_id>:<proxy_password>@<proxy_server>:<proxy_port> |
| 477 | ---- |
| 478 | |
David Ostrovsky | c0f6d4d | 2017-01-20 08:30:07 +0100 | [diff] [blame] | 479 | Redirection to local mirrors of Maven Central and the Gerrit storage |
| 480 | bucket is supported by defining specific properties in |
| 481 | `local.properties`, a file that is not tracked by Git: |
| 482 | |
| 483 | ---- |
| 484 | echo download.GERRIT = http://nexus.my-company.com/ >>local.properties |
| 485 | echo download.MAVEN_CENTRAL = http://nexus.my-company.com/ >>local.properties |
| 486 | ---- |
| 487 | |
| 488 | The `local.properties` file may be placed in the root of the gerrit repository |
| 489 | being built, or in `~/.gerritcodereview/`. The file in the root of the gerrit |
| 490 | repository has precedence. |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 491 | |
| 492 | == Building against unpublished Maven JARs |
| 493 | |
Dave Borowitz | 8626f87 | 2019-04-19 14:34:36 -0700 | [diff] [blame] | 494 | To build against unpublished Maven JARs, like PrologCafe, the custom JARs must |
| 495 | be installed in the local Maven repository (`mvn clean install`) and |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 496 | `maven_jar()` must be updated to point to the `MAVEN_LOCAL` Maven repository for |
| 497 | that artifact: |
| 498 | |
| 499 | [source,python] |
| 500 | ---- |
| 501 | maven_jar( |
Dave Borowitz | 8626f87 | 2019-04-19 14:34:36 -0700 | [diff] [blame] | 502 | name = 'prolog-runtime', |
| 503 | artifact = 'com.googlecode.prolog-cafe:prolog-runtime:42', |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 504 | repository = MAVEN_LOCAL, |
| 505 | ) |
| 506 | ---- |
| 507 | |
| 508 | == Building against artifacts from custom Maven repositories |
| 509 | |
| 510 | To build against custom Maven repositories, two modes of operations are |
| 511 | supported: with rewrite in local.properties and without. |
| 512 | |
| 513 | Without rewrite the URL of custom Maven repository can be directly passed |
| 514 | to the maven_jar() function: |
| 515 | |
| 516 | [source,python] |
| 517 | ---- |
| 518 | GERRIT_FORGE = 'http://gerritforge.com/snapshot' |
| 519 | |
| 520 | maven_jar( |
| 521 | name = 'gitblit', |
Paladox none | dab92ab | 2017-01-28 22:56:33 +0000 | [diff] [blame] | 522 | artifact = 'com.gitblit:gitblit:1.4.0', |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 523 | sha1 = '1b130dbf5578ace37507430a4a523f6594bf34fa', |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 524 | repository = GERRIT_FORGE, |
| 525 | ) |
| 526 | ---- |
| 527 | |
| 528 | When the custom URL has to be rewritten, then the same logic as with Gerrit |
| 529 | known Maven repository is used: Repo name must be defined that matches an entry |
| 530 | in local.properties file: |
| 531 | |
| 532 | ---- |
| 533 | download.GERRIT_FORGE = http://my.company.mirror/gerrit-forge |
| 534 | ---- |
| 535 | |
| 536 | And corresponding WORKSPACE excerpt: |
| 537 | |
| 538 | [source,python] |
| 539 | ---- |
| 540 | GERRIT_FORGE = 'GERRIT_FORGE:' |
| 541 | |
| 542 | maven_jar( |
| 543 | name = 'gitblit', |
Paladox none | dab92ab | 2017-01-28 22:56:33 +0000 | [diff] [blame] | 544 | artifact = 'com.gitblit:gitblit:1.4.0', |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 545 | sha1 = '1b130dbf5578ace37507430a4a523f6594bf34fa', |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 546 | repository = GERRIT_FORGE, |
| 547 | ) |
| 548 | ---- |
| 549 | |
David Ostrovsky | ad61c85 | 2019-01-14 07:11:04 +0100 | [diff] [blame] | 550 | == Building against SNAPSHOT Maven JARs |
| 551 | |
| 552 | To build against SNAPSHOT Maven JARs, the complete SNAPSHOT version must be used: |
| 553 | |
| 554 | [source,python] |
| 555 | ---- |
| 556 | maven_jar( |
| 557 | name = "pac4j-core", |
| 558 | artifact = "org.pac4j:pac4j-core:3.5.0-SNAPSHOT-20190112.120241-16", |
| 559 | sha1 = "da2b1cb68a8f87bfd40813179abd368de9f3a746", |
| 560 | ) |
| 561 | ---- |
| 562 | |
David Ostrovsky | 2bf355d | 2018-05-30 08:58:22 +0200 | [diff] [blame] | 563 | [[bazel-local-caches]] |
David Ostrovsky | 88bc372 | 2017-09-19 08:29:27 +0200 | [diff] [blame] | 564 | |
David Pursehouse | 42cb293 | 2018-06-05 14:49:06 +0900 | [diff] [blame] | 565 | To accelerate builds, several caches are activated per default: |
David Ostrovsky | 2bf355d | 2018-05-30 08:58:22 +0200 | [diff] [blame] | 566 | |
| 567 | * ~/.gerritcodereview/bazel-cache/downloaded-artifacts |
| 568 | * ~/.gerritcodereview/bazel-cache/repository |
| 569 | * ~/.gerritcodereview/bazel-cache/cas |
| 570 | |
Antoine Musso | ff89f79 | 2021-05-04 11:14:05 +0200 | [diff] [blame] | 571 | The `downloaded-artifacts` cache can be relocated by setting the |
| 572 | `GERRIT_CACHE_HOME` environment variable. The other two can be adjusted with |
Clark Boylan | 8784a6c | 2023-09-27 16:35:19 -0700 | [diff] [blame] | 573 | `bazelisk build` options `--repository_cache` and `--disk_cache` respectively. |
Antoine Musso | ff89f79 | 2021-05-04 11:14:05 +0200 | [diff] [blame] | 574 | |
David Pursehouse | 42cb293 | 2018-06-05 14:49:06 +0900 | [diff] [blame] | 575 | Currently none of these caches have a maximum size limit. See |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 576 | link:https://github.com/bazelbuild/bazel/issues/5139[this bazel issue,role=external,window=_blank] for |
David Pursehouse | 42cb293 | 2018-06-05 14:49:06 +0900 | [diff] [blame] | 577 | details. Users should watch the cache sizes and clean them manually if |
| 578 | necessary. |
| 579 | |
Dave Borowitz | f04eb08 | 2018-07-16 08:51:17 -0700 | [diff] [blame] | 580 | [[npm-binary]] |
| 581 | == NPM Binaries |
| 582 | |
Ben Rohlfs | da0a62b | 2021-04-26 17:02:19 +0200 | [diff] [blame] | 583 | Parts of the Gerrit web app build require running NPM-based JavaScript programs |
| 584 | as "binaries". We don't attempt to resolve and download NPM dependencies at |
| 585 | build time, but instead use pre-built bundles of the NPM binary along with all |
| 586 | its dependencies. Some packages on |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 587 | link:https://docs.npmjs.com/misc/registry[registry.npmjs.org,role=external,window=_blank] come with their |
Dave Borowitz | f04eb08 | 2018-07-16 08:51:17 -0700 | [diff] [blame] | 588 | dependencies bundled, but this is the exception rather than the rule. More |
| 589 | commonly, to add a new binary to this list, you will need to bundle the binary |
| 590 | yourself. |
| 591 | |
| 592 | [NOTE] |
| 593 | We can only use binaries that meet certain licensing requirements, and that do |
| 594 | not include any native code. |
| 595 | |
| 596 | Start by checking that the license and file types of the bundle are acceptable: |
| 597 | [source,bash] |
| 598 | ---- |
| 599 | gerrit_repo=/path/to/gerrit |
| 600 | package=some-npm-package |
| 601 | version=1.2.3 |
| 602 | |
Dmitrii Filippov | c2cdcce | 2020-01-27 12:57:42 +0100 | [diff] [blame] | 603 | # Note - yarn must be installed before running the following commands |
| 604 | yarn global add license-checker && \ |
Dave Borowitz | f04eb08 | 2018-07-16 08:51:17 -0700 | [diff] [blame] | 605 | rm -rf /tmp/$package-$version && mkdir -p /tmp/$package-$version && \ |
| 606 | cd /tmp/$package-$version && \ |
Dmitrii Filippov | c2cdcce | 2020-01-27 12:57:42 +0100 | [diff] [blame] | 607 | yarn add $package@$version && \ |
Dave Borowitz | f04eb08 | 2018-07-16 08:51:17 -0700 | [diff] [blame] | 608 | license-checker | grep licenses: | sort -u |
| 609 | ---- |
| 610 | |
| 611 | This will output a list of the different licenses used by the package and all |
| 612 | its transitive dependencies. We can only legally distribute a bundle via our |
| 613 | storage bucket if the licenses allow us to do so. As long as all of the listed |
| 614 | license are allowed by |
| 615 | link:https://opensource.google.com/docs/thirdparty/licenses/[Google's |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 616 | standards,role=external,window=_blank]. Any `by_exception_only`, commercial, prohibited, or unlisted |
Dave Borowitz | f04eb08 | 2018-07-16 08:51:17 -0700 | [diff] [blame] | 617 | licenses are not allowed; otherwise, it is ok to distribute the source. If in |
| 618 | doubt, contact a maintainer who is a Googler. |
| 619 | |
| 620 | Next, check the file types: |
| 621 | [source,bash] |
| 622 | ---- |
| 623 | cd /tmp/$package-$version |
| 624 | find . -type f | xargs file | grep -v 'ASCII\|UTF-8\|empty$' |
| 625 | ---- |
| 626 | |
| 627 | If you see anything that looks like a native library or binary, then we can't |
| 628 | use the bundle. |
| 629 | |
Dmitrii Filippov | c2cdcce | 2020-01-27 12:57:42 +0100 | [diff] [blame] | 630 | If everything looks good, install the package with the following command: |
| 631 | [source, bash] |
Dave Borowitz | f04eb08 | 2018-07-16 08:51:17 -0700 | [diff] [blame] | 632 | ---- |
Dmitrii Filippov | c2cdcce | 2020-01-27 12:57:42 +0100 | [diff] [blame] | 633 | # Add to ui_npm. Other packages.json can be updated in the same way |
| 634 | cd $gerrit_repo/polygerrit-ui/app |
Clark Boylan | 8784a6c | 2023-09-27 16:35:19 -0700 | [diff] [blame] | 635 | bazelisk run @nodejs//:yarn add $package |
Dave Borowitz | f04eb08 | 2018-07-16 08:51:17 -0700 | [diff] [blame] | 636 | ---- |
| 637 | |
Dmitrii Filippov | c2cdcce | 2020-01-27 12:57:42 +0100 | [diff] [blame] | 638 | Update the `polygerrit-ui/app/node_modules_licenses/licenses.ts` file. You should add licenses |
Martin Fick | 6b67d57 | 2023-04-04 14:23:14 -0600 | [diff] [blame] | 639 | for the package itself and for all transitive dependencies. If you forgot to add a license, the |
Dmitrii Filippov | c2cdcce | 2020-01-27 12:57:42 +0100 | [diff] [blame] | 640 | `Documentation:check_licenses` test will fail. |
Dave Borowitz | f04eb08 | 2018-07-16 08:51:17 -0700 | [diff] [blame] | 641 | |
Dmitrii Filippov | c2cdcce | 2020-01-27 12:57:42 +0100 | [diff] [blame] | 642 | After the update, commit all changes to the repository (including `yarn.lock`). |
Dave Borowitz | f04eb08 | 2018-07-16 08:51:17 -0700 | [diff] [blame] | 643 | |
Dmitrii Filippov | c2cdcce | 2020-01-27 12:57:42 +0100 | [diff] [blame] | 644 | [NOTE] |
| 645 | ==== |
| 646 | If a npm package has transitive dependencies (or just several files) with a not allowed |
| 647 | license and you can't avoid use it in release, then you can add this package. |
| 648 | For example some packages contain demo-code with a different license. Another example - optional |
Ben Rohlfs | da0a62b | 2021-04-26 17:02:19 +0200 | [diff] [blame] | 649 | dependencies, which are not needed to build the Gerrit web app, but they are installed together |
| 650 | with the package anyway. |
Dave Borowitz | f04eb08 | 2018-07-16 08:51:17 -0700 | [diff] [blame] | 651 | |
Dmitrii Filippov | c2cdcce | 2020-01-27 12:57:42 +0100 | [diff] [blame] | 652 | In this case you should exclude all files and/or transitive dependencies with a not allowed license. |
| 653 | Adding such package requires additional updates: |
Dave Borowitz | f04eb08 | 2018-07-16 08:51:17 -0700 | [diff] [blame] | 654 | |
Dmitrii Filippov | c2cdcce | 2020-01-27 12:57:42 +0100 | [diff] [blame] | 655 | - Add dependencies (or files) to the license.ts with an appropriate license marked with |
| 656 | `allowed: false`. |
Dave Borowitz | f04eb08 | 2018-07-16 08:51:17 -0700 | [diff] [blame] | 657 | |
Dmitrii Filippov | c2cdcce | 2020-01-27 12:57:42 +0100 | [diff] [blame] | 658 | - update package.json postinstall script to remove all non-allowed files (if you don't |
| 659 | update postinstall script, `Documentation:check_licenses` test will fail.) |
| 660 | ==== |
| 661 | |
| 662 | === Update NPM Binaries |
| 663 | To update a NPM binary the same actions as for a new one must be done (check licenses, |
| 664 | update `licenses.ts` file, etc...). The only difference is a command to install a package: instead |
Clark Boylan | 8784a6c | 2023-09-27 16:35:19 -0700 | [diff] [blame] | 665 | of `bazelisk run @nodejs//:yarn add $package` you should run the `bazelisk run @nodejs//:yarn upgrade ...` |
Dmitrii Filippov | c2cdcce | 2020-01-27 12:57:42 +0100 | [diff] [blame] | 666 | command with correct arguments. You can find the list of arguments in the |
| 667 | link:https://classic.yarnpkg.com/en/docs/cli/upgrade/[yarn upgrade doc,role=external,window=_blank]. |
Dave Borowitz | f04eb08 | 2018-07-16 08:51:17 -0700 | [diff] [blame] | 668 | |
| 669 | |
Han-Wen Nienhuys | 9c15e2b | 2019-05-16 16:59:33 +0200 | [diff] [blame] | 670 | [[RBE]] |
David Pursehouse | 0713b9a | 2019-05-21 12:20:26 +0900 | [diff] [blame] | 671 | == Google Remote Build Support |
Han-Wen Nienhuys | 9c15e2b | 2019-05-16 16:59:33 +0200 | [diff] [blame] | 672 | |
| 673 | The Bazel build can be used with Google's Remote Build Execution. |
| 674 | |
| 675 | |
| 676 | This needs the following setup steps: |
| 677 | |
| 678 | ``` |
| 679 | gcloud auth application-default login |
| 680 | gcloud services enable remotebuildexecution.googleapis.com --project=${PROJECT} |
| 681 | ``` |
| 682 | |
| 683 | Create a worker pool. The instances should have at least 4 CPUs each |
| 684 | for adequate performance. |
| 685 | |
| 686 | ``` |
| 687 | gcloud alpha remote-build-execution worker-pools create default \ |
| 688 | --project=${PROJECT} \ |
| 689 | --instance=default_instance \ |
| 690 | --worker-count=50 \ |
Han-Wen Nienhuys | 8abed33 | 2020-04-06 16:50:38 +0200 | [diff] [blame] | 691 | --machine-type=e2-standard-4 \ |
Han-Wen Nienhuys | 9c15e2b | 2019-05-16 16:59:33 +0200 | [diff] [blame] | 692 | --disk-size=200 |
| 693 | ``` |
| 694 | |
David Ostrovsky | bb95163 | 2023-11-14 06:40:36 +0100 | [diff] [blame] | 695 | Note, that we are using Ubuntu2204 docker image from bazel project: |
David Ostrovsky | 65951c5 | 2020-03-28 18:23:20 +0100 | [diff] [blame] | 696 | |
David Ostrovsky | 65951c5 | 2020-03-28 18:23:20 +0100 | [diff] [blame] | 697 | |
| 698 | ``` |
David Ostrovsky | bb95163 | 2023-11-14 06:40:36 +0100 | [diff] [blame] | 699 | docker pull gcr.io/bazel-public/ubuntu2204-java17@sha256:ffe37746a34537d8e73cef5a20ccd3a4e3ec7af3e7410cba87387ba97c0e520f |
David Ostrovsky | 65951c5 | 2020-03-28 18:23:20 +0100 | [diff] [blame] | 700 | ``` |
| 701 | |
David Ostrovsky | bb95163 | 2023-11-14 06:40:36 +0100 | [diff] [blame] | 702 | Re-build rbe_autoconfig project, conduct a new release and switch to using it |
| 703 | in `WORKSPACE` file. For more details see this |
| 704 | link:https://github.com/davido/rbe_autoconfig[repository,role=external,window=_blank] |
David Ostrovsky | 65951c5 | 2020-03-28 18:23:20 +0100 | [diff] [blame] | 705 | |
| 706 | Note, to authenticate to the gcr.io registry, the following command must be |
| 707 | used: |
| 708 | |
| 709 | ``` |
| 710 | gcloud auth configure-docker |
| 711 | ``` |
| 712 | |
| 713 | To see the documentation, developer must be added to this group: |
| 714 | https://groups.google.com/forum/#!forum/rbe-alpha-customers. |
| 715 | |
| 716 | Documentation can be found at: |
| 717 | https://cloud.google.com/remote-build-execution/docs. |
| 718 | |
Han-Wen Nienhuys | 9c15e2b | 2019-05-16 16:59:33 +0200 | [diff] [blame] | 719 | To use RBE, execute |
| 720 | |
| 721 | ``` |
Clark Boylan | 8784a6c | 2023-09-27 16:35:19 -0700 | [diff] [blame] | 722 | bazelisk test --config=remote \ |
Han-Wen Nienhuys | 9c15e2b | 2019-05-16 16:59:33 +0200 | [diff] [blame] | 723 | --remote_instance_name=projects/${PROJECT}/instances/default_instance \ |
| 724 | javatests/... |
| 725 | ``` |
| 726 | |
| 727 | |
Alvaro Vilaplana Garcia | d0908c9 | 2023-11-15 15:59:25 +0000 | [diff] [blame] | 728 | == BuildBuddy Remote Build Support |
| 729 | |
| 730 | To utilize the BuildBuddy Remote Build Execution service, please consult the |
| 731 | documentation available at the following link: https://www.buildbuddy.io[BuildBuddy]. |
| 732 | |
| 733 | To use RBE, execute |
| 734 | |
| 735 | ``` |
| 736 | bazelisk test --config=remote_bb \ |
| 737 | --remote_instance_name=projects/${PROJECT}/instances/default_instance \ |
| 738 | --remote_header=x-buildbuddy-api-key=YOUR_API_KEY \ |
| 739 | javatests/... |
| 740 | ``` |
| 741 | |
| 742 | |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 743 | GERRIT |
| 744 | ------ |
| 745 | Part of link:index.html[Gerrit Code Review] |
| 746 | |
| 747 | SEARCHBOX |
| 748 | --------- |