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 | b89332d | 2020-04-27 07:06:24 +0200 | [diff] [blame] | 21 | * A JDK for Java 8|11|... |
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 |
David Ostrovsky | 8ee6774 | 2020-05-14 08:23:39 +0200 | [diff] [blame] | 38 | to worry about using the correct version of Bazel. Bazelisk can be installed in different |
| 39 | ways: link:https://docs.bazel.build/install-bazelisk.html[Install,role=external,window=_blank] |
Marco Miller | 9bede91 | 2020-01-27 17:38:40 -0500 | [diff] [blame] | 40 | |
David Pursehouse | c8b633d | 2019-05-08 08:36:18 +0900 | [diff] [blame] | 41 | [[java]] |
| 42 | === Java |
| 43 | |
Matthias Sohn | 8278667 | 2021-02-25 17:19:53 +0100 | [diff] [blame] | 44 | Ensure that the link:install.html#Requirements[required Java version] |
| 45 | is installed and that `JAVA_HOME` is set to it. |
Alice Kober-Sotzek | a8029b6 | 2019-05-07 19:13:00 +0200 | [diff] [blame] | 46 | |
| 47 | To check the installed version of Java, open a terminal window and run: |
| 48 | |
| 49 | `java -version` |
| 50 | |
David Ostrovsky | b89332d | 2020-04-27 07:06:24 +0200 | [diff] [blame] | 51 | [[java-8]] |
| 52 | ==== Java 8 support (deprecated) |
| 53 | |
| 54 | Java 8 is a legacy Java release and support for Java 8 will be discontinued |
| 55 | in future gerrit releases. To build Gerrit with Java 8 language level, run: |
| 56 | |
| 57 | ``` |
Luca Milanesio | bef704e | 2020-11-05 11:29:36 +0000 | [diff] [blame] | 58 | $ bazel build --java_toolchain //tools:error_prone_warnings_toolchain :release |
David Ostrovsky | b89332d | 2020-04-27 07:06:24 +0200 | [diff] [blame] | 59 | ``` |
| 60 | |
| 61 | [[java-11]] |
| 62 | ==== Java 11 support |
| 63 | |
| 64 | Java language level 11 is the default. To build Gerrit with Java 11 language |
| 65 | level, run: |
| 66 | |
| 67 | ``` |
| 68 | $ bazel build :release |
| 69 | ``` |
| 70 | |
David Ostrovsky | ef56128 | 2019-11-12 14:49:13 -0800 | [diff] [blame] | 71 | [[java-13]] |
| 72 | ==== Java 13 support |
David Pursehouse | c8b633d | 2019-05-08 08:36:18 +0900 | [diff] [blame] | 73 | |
David Ostrovsky | ef56128 | 2019-11-12 14:49:13 -0800 | [diff] [blame] | 74 | Java 13 (and newer) is supported through vanilla java toolchain |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 75 | link:https://docs.bazel.build/versions/master/toolchains.html[Bazel option,role=external,window=_blank]. |
David Ostrovsky | ef56128 | 2019-11-12 14:49:13 -0800 | [diff] [blame] | 76 | To build Gerrit with Java 13 and newer, specify vanilla java toolchain and |
David Ostrovsky | 0bceb04 | 2018-08-25 07:37:54 +0200 | [diff] [blame] | 77 | provide the path to JDK home: |
David Ostrovsky | f55b69f | 2018-08-23 08:25:24 +0200 | [diff] [blame] | 78 | |
| 79 | ``` |
David Ostrovsky | 7e1fcd9 | 2018-11-03 08:48:47 +0100 | [diff] [blame] | 80 | $ bazel build \ |
David Ostrovsky | ef56128 | 2019-11-12 14:49:13 -0800 | [diff] [blame] | 81 | --define=ABSOLUTE_JAVABASE=<path-to-java-13> \ |
David Ostrovsky | 5f45e82 | 2019-09-26 17:19:27 +0200 | [diff] [blame] | 82 | --javabase=@bazel_tools//tools/jdk:absolute_javabase \ |
David Ostrovsky | 7e1fcd9 | 2018-11-03 08:48:47 +0100 | [diff] [blame] | 83 | --host_javabase=@bazel_tools//tools/jdk:absolute_javabase \ |
David Ostrovsky | 17b60d9 | 2019-11-10 12:25:53 -0800 | [diff] [blame] | 84 | --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_vanilla \ |
| 85 | --java_toolchain=@bazel_tools//tools/jdk:toolchain_vanilla \ |
David Ostrovsky | f55b69f | 2018-08-23 08:25:24 +0200 | [diff] [blame] | 86 | :release |
| 87 | ``` |
| 88 | |
David Ostrovsky | 0bceb04 | 2018-08-25 07:37:54 +0200 | [diff] [blame] | 89 | To run the tests, `--javabase` option must be passed as well, because |
| 90 | bazel test runs the test using the target javabase: |
| 91 | |
| 92 | ``` |
David Ostrovsky | 7e1fcd9 | 2018-11-03 08:48:47 +0100 | [diff] [blame] | 93 | $ bazel test \ |
David Ostrovsky | ef56128 | 2019-11-12 14:49:13 -0800 | [diff] [blame] | 94 | --define=ABSOLUTE_JAVABASE=<path-to-java-13> \ |
David Ostrovsky | 7e1fcd9 | 2018-11-03 08:48:47 +0100 | [diff] [blame] | 95 | --javabase=@bazel_tools//tools/jdk:absolute_javabase \ |
| 96 | --host_javabase=@bazel_tools//tools/jdk:absolute_javabase \ |
David Ostrovsky | 17b60d9 | 2019-11-10 12:25:53 -0800 | [diff] [blame] | 97 | --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_vanilla \ |
| 98 | --java_toolchain=@bazel_tools//tools/jdk:toolchain_vanilla \ |
David Ostrovsky | 0bceb04 | 2018-08-25 07:37:54 +0200 | [diff] [blame] | 99 | //... |
| 100 | ``` |
| 101 | |
| 102 | To avoid passing all those options on every Bazel build invocation, |
| 103 | they could be added to ~/.bazelrc resource file: |
| 104 | |
| 105 | ``` |
| 106 | $ cat << EOF > ~/.bazelrc |
Marco Miller | d183987 | 2020-09-03 17:46:24 -0400 | [diff] [blame] | 107 | build --define=ABSOLUTE_JAVABASE=<path-to-java-13> |
Orgad Shaneh | 7af0efd | 2020-08-20 22:21:23 +0300 | [diff] [blame] | 108 | build --javabase=@bazel_tools//tools/jdk:absolute_javabase |
| 109 | build --host_javabase=@bazel_tools//tools/jdk:absolute_javabase |
| 110 | build --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_vanilla |
| 111 | build --java_toolchain=@bazel_tools//tools/jdk:toolchain_vanilla |
| 112 | EOF |
David Ostrovsky | 0bceb04 | 2018-08-25 07:37:54 +0200 | [diff] [blame] | 113 | ``` |
| 114 | |
| 115 | Now, invoking Bazel with just `bazel build :release` would include |
| 116 | all those options. |
| 117 | |
Alice Kober-Sotzek | 79290dc | 2019-05-07 19:26:18 +0200 | [diff] [blame] | 118 | === Node.js and npm packages |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 119 | 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] | 120 | |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 121 | [[build]] |
| 122 | == Building on the Command Line |
| 123 | |
| 124 | === Gerrit Development WAR File |
| 125 | |
David Ostrovsky | 7163dac | 2017-07-29 06:49:38 +0200 | [diff] [blame] | 126 | To build the Gerrit web application: |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 127 | |
| 128 | ---- |
| 129 | bazel build gerrit |
| 130 | ---- |
| 131 | |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 132 | The output executable WAR will be placed in: |
| 133 | |
| 134 | ---- |
| 135 | bazel-bin/gerrit.war |
| 136 | ---- |
| 137 | |
Edwin Kempin | 976dc0b | 2016-11-14 16:34:50 -0800 | [diff] [blame] | 138 | [[release]] |
Edwin Kempin | 3cfce17 | 2016-11-14 16:17:17 -0800 | [diff] [blame] | 139 | === Gerrit Release WAR File |
| 140 | |
Ben Rohlfs | da0a62b | 2021-04-26 17:02:19 +0200 | [diff] [blame] | 141 | To build the Gerrit web application that includes the Gerrit UI, |
David Ostrovsky | 7163dac | 2017-07-29 06:49:38 +0200 | [diff] [blame] | 142 | core plugins and documentation: |
Edwin Kempin | 3cfce17 | 2016-11-14 16:17:17 -0800 | [diff] [blame] | 143 | |
| 144 | ---- |
| 145 | bazel build release |
| 146 | ---- |
| 147 | |
| 148 | The output executable WAR will be placed in: |
| 149 | |
| 150 | ---- |
| 151 | bazel-bin/release.war |
| 152 | ---- |
| 153 | |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 154 | === Headless Mode |
| 155 | |
Ben Rohlfs | da0a62b | 2021-04-26 17:02:19 +0200 | [diff] [blame] | 156 | 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] | 157 | |
| 158 | ---- |
| 159 | bazel build headless |
| 160 | ---- |
| 161 | |
| 162 | The output executable WAR will be placed in: |
| 163 | |
| 164 | ---- |
Edwin Kempin | 03eaa9a | 2016-11-14 15:45:51 -0800 | [diff] [blame] | 165 | bazel-bin/headless.war |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 166 | ---- |
| 167 | |
| 168 | === Extension and Plugin API JAR Files |
| 169 | |
David Ostrovsky | 7163dac | 2017-07-29 06:49:38 +0200 | [diff] [blame] | 170 | To build the extension, plugin and acceptance-framework JAR files: |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 171 | |
| 172 | ---- |
David Ostrovsky | 26f8da8 | 2016-12-24 09:29:33 +0100 | [diff] [blame] | 173 | bazel build api |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 174 | ---- |
| 175 | |
David Ostrovsky | 26f8da8 | 2016-12-24 09:29:33 +0100 | [diff] [blame] | 176 | The output archive that contains Java binaries, Java sources and |
| 177 | Java docs will be placed in: |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 178 | |
| 179 | ---- |
Luca Milanesio | 5bd7b9b | 2019-06-10 10:01:02 +0100 | [diff] [blame] | 180 | bazel-bin/api.zip |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 181 | ---- |
| 182 | |
David Ostrovsky | 7163dac | 2017-07-29 06:49:38 +0200 | [diff] [blame] | 183 | Install {extension,plugin,acceptance-framework}-api to the local |
| 184 | maven repository: |
David Ostrovsky | 50785fd | 2016-10-28 09:17:14 +0200 | [diff] [blame] | 185 | |
| 186 | ---- |
Edwin Kempin | d3bb302 | 2017-01-24 11:28:34 +0100 | [diff] [blame] | 187 | tools/maven/api.sh install |
David Ostrovsky | 50785fd | 2016-10-28 09:17:14 +0200 | [diff] [blame] | 188 | ---- |
| 189 | |
| 190 | Install gerrit.war to the local maven repository: |
| 191 | |
| 192 | ---- |
Edwin Kempin | d3bb302 | 2017-01-24 11:28:34 +0100 | [diff] [blame] | 193 | tools/maven/api.sh war_install |
David Ostrovsky | 50785fd | 2016-10-28 09:17:14 +0200 | [diff] [blame] | 194 | ---- |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 195 | |
| 196 | === Plugins |
| 197 | |
David Ostrovsky | af71968 | 2016-09-28 20:31:18 +0200 | [diff] [blame] | 198 | ---- |
| 199 | bazel build plugins:core |
| 200 | ---- |
| 201 | |
| 202 | The output JAR files for individual plugins will be placed in: |
| 203 | |
| 204 | ---- |
Luca Milanesio | 5bd7b9b | 2019-06-10 10:01:02 +0100 | [diff] [blame] | 205 | bazel-bin/plugins/<name>/<name>.jar |
David Ostrovsky | af71968 | 2016-09-28 20:31:18 +0200 | [diff] [blame] | 206 | ---- |
| 207 | |
| 208 | The JAR files will also be packaged in: |
| 209 | |
| 210 | ---- |
Luca Milanesio | 5bd7b9b | 2019-06-10 10:01:02 +0100 | [diff] [blame] | 211 | bazel-bin/plugins/core.zip |
David Ostrovsky | af71968 | 2016-09-28 20:31:18 +0200 | [diff] [blame] | 212 | ---- |
| 213 | |
| 214 | To build a specific plugin: |
| 215 | |
| 216 | ---- |
Edwin Kempin | 1ed86c7 | 2016-11-14 16:28:22 -0800 | [diff] [blame] | 217 | bazel build plugins/<name> |
David Ostrovsky | af71968 | 2016-09-28 20:31:18 +0200 | [diff] [blame] | 218 | ---- |
| 219 | |
| 220 | The output JAR file will be be placed in: |
| 221 | |
| 222 | ---- |
Luca Milanesio | 5bd7b9b | 2019-06-10 10:01:02 +0100 | [diff] [blame] | 223 | bazel-bin/plugins/<name>/<name>.jar |
David Ostrovsky | af71968 | 2016-09-28 20:31:18 +0200 | [diff] [blame] | 224 | ---- |
| 225 | |
| 226 | Note that when building an individual plugin, the `core.zip` package |
| 227 | is not regenerated. |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 228 | |
Han-Wen Nienhuys | 8ba8abe | 2016-10-25 15:54:28 +0200 | [diff] [blame] | 229 | [[IDEs]] |
| 230 | == Using an IDE. |
| 231 | |
| 232 | === IntelliJ |
| 233 | |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 234 | 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] | 235 | Please follow the instructions on <<dev-intellij#,IntelliJ Setup>>. |
David Ostrovsky | c69f360 | 2016-11-13 08:01:08 -0800 | [diff] [blame] | 236 | |
| 237 | === Eclipse |
| 238 | |
| 239 | ==== Generating the Eclipse Project |
| 240 | |
| 241 | Create the Eclipse project: |
| 242 | |
| 243 | ---- |
David Pursehouse | 7e43d1d | 2017-01-24 08:45:16 +0900 | [diff] [blame] | 244 | tools/eclipse/project.py |
David Ostrovsky | c69f360 | 2016-11-13 08:01:08 -0800 | [diff] [blame] | 245 | ---- |
| 246 | |
| 247 | and then follow the link:dev-eclipse.html#setup[setup instructions]. |
| 248 | |
| 249 | ==== Refreshing the Classpath |
| 250 | |
| 251 | If an updated classpath is needed, the Eclipse project can be |
| 252 | refreshed and missing dependency JARs can be downloaded by running |
David Pursehouse | 7e43d1d | 2017-01-24 08:45:16 +0900 | [diff] [blame] | 253 | `project.py` again. For IntelliJ, you need to click the `Sync Project |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 254 | 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] | 255 | |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 256 | [[documentation]] |
Nasser Grainawi | a55b20d | 2021-03-08 11:52:01 -0700 | [diff] [blame] | 257 | == Documentation |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 258 | |
David Ostrovsky | 9413ff8 | 2016-10-25 00:02:17 +0200 | [diff] [blame] | 259 | To build only the documentation for testing or static hosting: |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 260 | |
David Ostrovsky | 9413ff8 | 2016-10-25 00:02:17 +0200 | [diff] [blame] | 261 | ---- |
| 262 | bazel build Documentation:searchfree |
| 263 | ---- |
| 264 | |
| 265 | The html files will be bundled into `searchfree.zip` in this location: |
| 266 | |
| 267 | ---- |
| 268 | bazel-bin/Documentation/searchfree.zip |
| 269 | ---- |
| 270 | |
| 271 | To build the executable WAR with the documentation included: |
| 272 | |
| 273 | ---- |
| 274 | bazel build withdocs |
| 275 | ---- |
| 276 | |
| 277 | The WAR file will be placed in: |
| 278 | |
| 279 | ---- |
| 280 | bazel-bin/withdocs.war |
| 281 | ---- |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 282 | |
Antoine Musso | 524b056 | 2020-11-18 10:36:05 +0100 | [diff] [blame] | 283 | Alternatively, one can generate the documentation as flat files: |
| 284 | |
| 285 | ---- |
| 286 | bazel build Documentation:Documentation |
| 287 | ---- |
| 288 | |
| 289 | The html, css, js files are placed in: |
| 290 | |
| 291 | ---- |
| 292 | `bazel-bin/Documentation/` |
| 293 | ---- |
| 294 | |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 295 | [[tests]] |
| 296 | == Running Unit Tests |
| 297 | |
| 298 | ---- |
| 299 | bazel test --build_tests_only //... |
| 300 | ---- |
| 301 | |
| 302 | Debugging tests: |
| 303 | |
| 304 | ---- |
David Ostrovsky | 17ef127 | 2020-02-16 14:51:07 +0100 | [diff] [blame] | 305 | bazel test --test_output=streamed --test_filter=com.gerrit.TestClass.testMethod testTarget |
Edwin Kempin | d31903c | 2016-11-14 17:01:44 -0800 | [diff] [blame] | 306 | ---- |
| 307 | |
| 308 | Debug test example: |
| 309 | |
| 310 | ---- |
David Ostrovsky | 714982e | 2017-08-24 09:43:44 +0200 | [diff] [blame] | 311 | bazel test --test_output=streamed --test_filter=com.google.gerrit.acceptance.api.change.ChangeIT.getAmbiguous //javatests/com/google/gerrit/acceptance/api/change:api_change |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 312 | ---- |
| 313 | |
| 314 | To run a specific test group, e.g. the rest-account test group: |
| 315 | |
| 316 | ---- |
David Ostrovsky | 714982e | 2017-08-24 09:43:44 +0200 | [diff] [blame] | 317 | bazel test //javatests/com/google/gerrit/acceptance/rest/account:rest_account |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 318 | ---- |
| 319 | |
David Ostrovsky | ceb5ec1 | 2020-04-18 08:50:45 +0200 | [diff] [blame] | 320 | To run SSH tests using JSch ssh client: |
| 321 | |
| 322 | ---- |
| 323 | bazel test --test_env=SSH_CLIENT_IMPLEMENTATION=JSCH //... |
| 324 | ---- |
| 325 | |
| 326 | To run SSH tests using Apache MINA ssh client: |
| 327 | |
| 328 | ---- |
| 329 | bazel test --test_env=SSH_CLIENT_IMPLEMENTATION=APACHE //... |
| 330 | ---- |
| 331 | |
Patrick Hiesel | 244ff8c | 2016-12-22 11:40:23 +0100 | [diff] [blame] | 332 | To run only tests that do not use SSH: |
| 333 | |
| 334 | ---- |
| 335 | bazel test --test_env=GERRIT_USE_SSH=NO //... |
| 336 | ---- |
| 337 | |
Edwin Kempin | 2e8e96c | 2017-02-10 11:52:01 +0100 | [diff] [blame] | 338 | To exclude tests that have been marked as flaky: |
| 339 | |
| 340 | ---- |
| 341 | bazel test --test_tag_filters=-flaky //... |
| 342 | ---- |
| 343 | |
David Pursehouse | 7e18f1a | 2018-05-26 17:40:30 +0900 | [diff] [blame] | 344 | To exclude tests that require a Docker host: |
| 345 | |
| 346 | ---- |
| 347 | bazel test --test_tag_filters=-docker //... |
| 348 | ---- |
| 349 | |
David Pursehouse | 180bca5 | 2019-12-04 20:05:07 +0900 | [diff] [blame] | 350 | To exclude tests that require very recent git client version: |
| 351 | |
| 352 | ---- |
| 353 | bazel test --test_tag_filters=-git-protocol-v2 //... |
| 354 | ---- |
| 355 | |
Edwin Kempin | 2e8e96c | 2017-02-10 11:52:01 +0100 | [diff] [blame] | 356 | To ignore cached test results: |
| 357 | |
| 358 | ---- |
| 359 | bazel test --cache_test_results=NO //... |
| 360 | ---- |
| 361 | |
David Pursehouse | 4444518 | 2017-02-22 15:59:17 +0900 | [diff] [blame] | 362 | To run one or more specific groups of tests: |
| 363 | |
| 364 | ---- |
Jacek Centkowski | 1c41c41 | 2017-02-23 06:49:25 +0000 | [diff] [blame] | 365 | bazel test --test_tag_filters=api,git //... |
David Pursehouse | 4444518 | 2017-02-22 15:59:17 +0900 | [diff] [blame] | 366 | ---- |
| 367 | |
Patrick Hiesel | 2407aca | 2021-04-30 15:49:12 +0200 | [diff] [blame] | 368 | To run the tests against a specific index backend (LUCENE, FAKE): |
| 369 | ---- |
| 370 | bazel test --test_env=GERRIT_INDEX_TYPE=LUCENE //... |
| 371 | ---- |
| 372 | |
| 373 | Elastic search is not currently supported in integration tests. |
| 374 | |
David Pursehouse | 4444518 | 2017-02-22 15:59:17 +0900 | [diff] [blame] | 375 | The following values are currently supported for the group name: |
| 376 | |
| 377 | * annotation |
| 378 | * api |
David Pursehouse | 0223c0f | 2018-06-19 20:44:42 +0900 | [diff] [blame] | 379 | * docker |
David Pursehouse | 4444518 | 2017-02-22 15:59:17 +0900 | [diff] [blame] | 380 | * edit |
David Pursehouse | 0223c0f | 2018-06-19 20:44:42 +0900 | [diff] [blame] | 381 | * elastic |
David Pursehouse | 4444518 | 2017-02-22 15:59:17 +0900 | [diff] [blame] | 382 | * git |
David Pursehouse | 180bca5 | 2019-12-04 20:05:07 +0900 | [diff] [blame] | 383 | * git-protocol-v2 |
David Ostrovsky | 61a44ae | 2020-05-14 08:29:54 +0200 | [diff] [blame] | 384 | * git-upload-archive |
David Pursehouse | 4444518 | 2017-02-22 15:59:17 +0900 | [diff] [blame] | 385 | * notedb |
| 386 | * pgm |
| 387 | * rest |
| 388 | * server |
| 389 | * ssh |
| 390 | |
Nasser Grainawi | 02f5345 | 2021-02-19 08:17:49 -0700 | [diff] [blame] | 391 | Bazel itself supports a multitude of ways to |
| 392 | link:https://docs.bazel.build/versions/master/guide.html#specifying-targets-to-build[specify targets,role=external,window=_blank] |
| 393 | for fine-grained test selection that can be combined with many of the examples |
| 394 | above. |
| 395 | |
Saša Živkov | 1b716dd | 2021-03-12 17:03:33 +0100 | [diff] [blame] | 396 | [[debugging-tests]] |
| 397 | == Debugging Unit Tests |
| 398 | In some cases it may be necessary to debug a test while running it in bazel. For example, when we |
| 399 | observe a different test result in Eclipse and bazel. Using the `--java_debug` option will start the |
| 400 | JVM in debug mode and await for a remote debugger to attach. |
| 401 | |
| 402 | Example: |
| 403 | [source,bash] |
| 404 | ---- |
| 405 | bazel test --java_debug --test_tag_filters=delete-project //... |
| 406 | ... |
| 407 | Listening for transport dt_socket at address: 5005 |
| 408 | ... |
| 409 | ---- |
| 410 | |
| 411 | Now attach with a debugger to the port `5005`. For example use "Remote Java Application" launch |
| 412 | configuration in Eclipe and specify the port `5005`. |
| 413 | |
David Pursehouse | 564b29a | 2018-05-30 07:49:02 +0900 | [diff] [blame] | 414 | [[elasticsearch]] |
| 415 | === Elasticsearch |
| 416 | |
David Pursehouse | b04ae61 | 2018-06-19 20:34:36 +0900 | [diff] [blame] | 417 | Successfully running the Elasticsearch tests requires Docker, and |
Marco Miller | 12e4f2b | 2019-12-19 16:24:43 -0500 | [diff] [blame] | 418 | may require setting the local virtual memory on |
Marco Miller | 20b0d30 | 2019-12-21 14:29:49 -0500 | [diff] [blame] | 419 | link:https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html[linux,role=external,window=_blank] and |
| 420 | link:https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#_set_vm_max_map_count_to_at_least_262144[macOS,role=external,window=_blank]. |
Marco Miller | 12e4f2b | 2019-12-19 16:24:43 -0500 | [diff] [blame] | 421 | |
Marco Miller | 20b0d30 | 2019-12-21 14:29:49 -0500 | [diff] [blame] | 422 | On macOS, if using link:https://docs.docker.com/docker-for-mac/[Docker Desktop,role=external,window=_blank], |
Marco Miller | 12e4f2b | 2019-12-19 16:24:43 -0500 | [diff] [blame] | 423 | the effective memory value can be set in the Preferences, under the Advanced tab. |
| 424 | The default value usually does not suffice and is causing premature container exits. |
| 425 | That default is currently 2 GB and should be set to at least 5 (GB). |
David Pursehouse | 564b29a | 2018-05-30 07:49:02 +0900 | [diff] [blame] | 426 | |
David Pursehouse | b04ae61 | 2018-06-19 20:34:36 +0900 | [diff] [blame] | 427 | If Docker is not available, the Elasticsearch tests will be skipped. |
| 428 | Note that Bazel currently does not show |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 429 | link:https://github.com/bazelbuild/bazel/issues/3476[the skipped tests,role=external,window=_blank]. |
David Pursehouse | 564b29a | 2018-05-30 07:49:02 +0900 | [diff] [blame] | 430 | |
David Ostrovsky | 17ef127 | 2020-02-16 14:51:07 +0100 | [diff] [blame] | 431 | [[logging]] |
| 432 | === Controlling logging level |
Hamza Kaced | c54e6b5 | 2020-01-24 12:59:09 -0500 | [diff] [blame] | 433 | |
David Ostrovsky | 17ef127 | 2020-02-16 14:51:07 +0100 | [diff] [blame] | 434 | Per default, logging level is set to `INFO` level for all tests. The `DEBUG` |
| 435 | log level can be enabled for the tests. |
Hamza Kaced | c54e6b5 | 2020-01-24 12:59:09 -0500 | [diff] [blame] | 436 | |
David Ostrovsky | 17ef127 | 2020-02-16 14:51:07 +0100 | [diff] [blame] | 437 | In IDE, set `-Dgerrit.logLevel=debug` as a VM argument. With `bazel`, pass |
| 438 | `GERRIT_LOG_LEVEL=debug` environment variable: |
Hamza Kaced | c54e6b5 | 2020-01-24 12:59:09 -0500 | [diff] [blame] | 439 | |
| 440 | ---- |
David Pursehouse | d623a5c | 2020-05-01 14:29:57 +0900 | [diff] [blame] | 441 | bazel test --test_filter=com.google.gerrit.server.notedb.ChangeNotesTest \ |
David Ostrovsky | 17ef127 | 2020-02-16 14:51:07 +0100 | [diff] [blame] | 442 | --test_env=GERRIT_LOG_LEVEL=debug \ |
| 443 | javatests/com/google/gerrit/server:server_tests |
Hamza Kaced | c54e6b5 | 2020-01-24 12:59:09 -0500 | [diff] [blame] | 444 | ---- |
| 445 | |
David Ostrovsky | 17ef127 | 2020-02-16 14:51:07 +0100 | [diff] [blame] | 446 | The log results can be found in: |
| 447 | `bazel-testlogs/javatests/com/google/gerrit/server/server_tests/test.log`. |
| 448 | |
| 449 | |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 450 | == Dependencies |
| 451 | |
Han-Wen Nienhuys | 314fb11 | 2016-11-14 10:04:02 -0800 | [diff] [blame] | 452 | Dependency JARs are normally downloaded as needed, but you can |
| 453 | download everything upfront. This is useful to enable |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 454 | subsequent builds to run without network access: |
| 455 | |
| 456 | ---- |
Han-Wen Nienhuys | 314fb11 | 2016-11-14 10:04:02 -0800 | [diff] [blame] | 457 | bazel fetch //... |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 458 | ---- |
| 459 | |
| 460 | When downloading from behind a proxy (which is common in some corporate |
| 461 | environments), it might be necessary to explicitly specify the proxy that |
| 462 | is then used by `curl`: |
| 463 | |
| 464 | ---- |
| 465 | export http_proxy=http://<proxy_user_id>:<proxy_password>@<proxy_server>:<proxy_port> |
| 466 | ---- |
| 467 | |
David Ostrovsky | c0f6d4d | 2017-01-20 08:30:07 +0100 | [diff] [blame] | 468 | Redirection to local mirrors of Maven Central and the Gerrit storage |
| 469 | bucket is supported by defining specific properties in |
| 470 | `local.properties`, a file that is not tracked by Git: |
| 471 | |
| 472 | ---- |
| 473 | echo download.GERRIT = http://nexus.my-company.com/ >>local.properties |
| 474 | echo download.MAVEN_CENTRAL = http://nexus.my-company.com/ >>local.properties |
| 475 | ---- |
| 476 | |
| 477 | The `local.properties` file may be placed in the root of the gerrit repository |
| 478 | being built, or in `~/.gerritcodereview/`. The file in the root of the gerrit |
| 479 | repository has precedence. |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 480 | |
| 481 | == Building against unpublished Maven JARs |
| 482 | |
Dave Borowitz | 8626f87 | 2019-04-19 14:34:36 -0700 | [diff] [blame] | 483 | To build against unpublished Maven JARs, like PrologCafe, the custom JARs must |
| 484 | be installed in the local Maven repository (`mvn clean install`) and |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 485 | `maven_jar()` must be updated to point to the `MAVEN_LOCAL` Maven repository for |
| 486 | that artifact: |
| 487 | |
| 488 | [source,python] |
| 489 | ---- |
| 490 | maven_jar( |
Dave Borowitz | 8626f87 | 2019-04-19 14:34:36 -0700 | [diff] [blame] | 491 | name = 'prolog-runtime', |
| 492 | artifact = 'com.googlecode.prolog-cafe:prolog-runtime:42', |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 493 | repository = MAVEN_LOCAL, |
| 494 | ) |
| 495 | ---- |
| 496 | |
| 497 | == Building against artifacts from custom Maven repositories |
| 498 | |
| 499 | To build against custom Maven repositories, two modes of operations are |
| 500 | supported: with rewrite in local.properties and without. |
| 501 | |
| 502 | Without rewrite the URL of custom Maven repository can be directly passed |
| 503 | to the maven_jar() function: |
| 504 | |
| 505 | [source,python] |
| 506 | ---- |
| 507 | GERRIT_FORGE = 'http://gerritforge.com/snapshot' |
| 508 | |
| 509 | maven_jar( |
| 510 | name = 'gitblit', |
Paladox none | dab92ab | 2017-01-28 22:56:33 +0000 | [diff] [blame] | 511 | artifact = 'com.gitblit:gitblit:1.4.0', |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 512 | sha1 = '1b130dbf5578ace37507430a4a523f6594bf34fa', |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 513 | repository = GERRIT_FORGE, |
| 514 | ) |
| 515 | ---- |
| 516 | |
| 517 | When the custom URL has to be rewritten, then the same logic as with Gerrit |
| 518 | known Maven repository is used: Repo name must be defined that matches an entry |
| 519 | in local.properties file: |
| 520 | |
| 521 | ---- |
| 522 | download.GERRIT_FORGE = http://my.company.mirror/gerrit-forge |
| 523 | ---- |
| 524 | |
| 525 | And corresponding WORKSPACE excerpt: |
| 526 | |
| 527 | [source,python] |
| 528 | ---- |
| 529 | GERRIT_FORGE = 'GERRIT_FORGE:' |
| 530 | |
| 531 | maven_jar( |
| 532 | name = 'gitblit', |
Paladox none | dab92ab | 2017-01-28 22:56:33 +0000 | [diff] [blame] | 533 | artifact = 'com.gitblit:gitblit:1.4.0', |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 534 | sha1 = '1b130dbf5578ace37507430a4a523f6594bf34fa', |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 535 | repository = GERRIT_FORGE, |
| 536 | ) |
| 537 | ---- |
| 538 | |
David Ostrovsky | ad61c85 | 2019-01-14 07:11:04 +0100 | [diff] [blame] | 539 | == Building against SNAPSHOT Maven JARs |
| 540 | |
| 541 | To build against SNAPSHOT Maven JARs, the complete SNAPSHOT version must be used: |
| 542 | |
| 543 | [source,python] |
| 544 | ---- |
| 545 | maven_jar( |
| 546 | name = "pac4j-core", |
| 547 | artifact = "org.pac4j:pac4j-core:3.5.0-SNAPSHOT-20190112.120241-16", |
| 548 | sha1 = "da2b1cb68a8f87bfd40813179abd368de9f3a746", |
| 549 | ) |
| 550 | ---- |
| 551 | |
David Ostrovsky | 2bf355d | 2018-05-30 08:58:22 +0200 | [diff] [blame] | 552 | [[bazel-local-caches]] |
David Ostrovsky | 88bc372 | 2017-09-19 08:29:27 +0200 | [diff] [blame] | 553 | |
David Pursehouse | 42cb293 | 2018-06-05 14:49:06 +0900 | [diff] [blame] | 554 | To accelerate builds, several caches are activated per default: |
David Ostrovsky | 2bf355d | 2018-05-30 08:58:22 +0200 | [diff] [blame] | 555 | |
| 556 | * ~/.gerritcodereview/bazel-cache/downloaded-artifacts |
| 557 | * ~/.gerritcodereview/bazel-cache/repository |
| 558 | * ~/.gerritcodereview/bazel-cache/cas |
| 559 | |
Antoine Musso | ff89f79 | 2021-05-04 11:14:05 +0200 | [diff] [blame] | 560 | The `downloaded-artifacts` cache can be relocated by setting the |
| 561 | `GERRIT_CACHE_HOME` environment variable. The other two can be adjusted with |
| 562 | `bazel build` options `--repository_cache` and `--disk_cache` respectively. |
| 563 | |
David Pursehouse | 42cb293 | 2018-06-05 14:49:06 +0900 | [diff] [blame] | 564 | Currently none of these caches have a maximum size limit. See |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 565 | 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] | 566 | details. Users should watch the cache sizes and clean them manually if |
| 567 | necessary. |
| 568 | |
Dave Borowitz | f04eb08 | 2018-07-16 08:51:17 -0700 | [diff] [blame] | 569 | [[npm-binary]] |
| 570 | == NPM Binaries |
| 571 | |
Ben Rohlfs | da0a62b | 2021-04-26 17:02:19 +0200 | [diff] [blame] | 572 | Parts of the Gerrit web app build require running NPM-based JavaScript programs |
| 573 | as "binaries". We don't attempt to resolve and download NPM dependencies at |
| 574 | build time, but instead use pre-built bundles of the NPM binary along with all |
| 575 | its dependencies. Some packages on |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 576 | 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] | 577 | dependencies bundled, but this is the exception rather than the rule. More |
| 578 | commonly, to add a new binary to this list, you will need to bundle the binary |
| 579 | yourself. |
| 580 | |
| 581 | [NOTE] |
| 582 | We can only use binaries that meet certain licensing requirements, and that do |
| 583 | not include any native code. |
| 584 | |
| 585 | Start by checking that the license and file types of the bundle are acceptable: |
| 586 | [source,bash] |
| 587 | ---- |
| 588 | gerrit_repo=/path/to/gerrit |
| 589 | package=some-npm-package |
| 590 | version=1.2.3 |
| 591 | |
Dmitrii Filippov | c2cdcce | 2020-01-27 12:57:42 +0100 | [diff] [blame] | 592 | # Note - yarn must be installed before running the following commands |
| 593 | yarn global add license-checker && \ |
Dave Borowitz | f04eb08 | 2018-07-16 08:51:17 -0700 | [diff] [blame] | 594 | rm -rf /tmp/$package-$version && mkdir -p /tmp/$package-$version && \ |
| 595 | cd /tmp/$package-$version && \ |
Dmitrii Filippov | c2cdcce | 2020-01-27 12:57:42 +0100 | [diff] [blame] | 596 | yarn add $package@$version && \ |
Dave Borowitz | f04eb08 | 2018-07-16 08:51:17 -0700 | [diff] [blame] | 597 | license-checker | grep licenses: | sort -u |
| 598 | ---- |
| 599 | |
| 600 | This will output a list of the different licenses used by the package and all |
| 601 | its transitive dependencies. We can only legally distribute a bundle via our |
| 602 | storage bucket if the licenses allow us to do so. As long as all of the listed |
| 603 | license are allowed by |
| 604 | link:https://opensource.google.com/docs/thirdparty/licenses/[Google's |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 605 | 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] | 606 | licenses are not allowed; otherwise, it is ok to distribute the source. If in |
| 607 | doubt, contact a maintainer who is a Googler. |
| 608 | |
| 609 | Next, check the file types: |
| 610 | [source,bash] |
| 611 | ---- |
| 612 | cd /tmp/$package-$version |
| 613 | find . -type f | xargs file | grep -v 'ASCII\|UTF-8\|empty$' |
| 614 | ---- |
| 615 | |
| 616 | If you see anything that looks like a native library or binary, then we can't |
| 617 | use the bundle. |
| 618 | |
Dmitrii Filippov | c2cdcce | 2020-01-27 12:57:42 +0100 | [diff] [blame] | 619 | If everything looks good, install the package with the following command: |
| 620 | [source, bash] |
Dave Borowitz | f04eb08 | 2018-07-16 08:51:17 -0700 | [diff] [blame] | 621 | ---- |
Dmitrii Filippov | c2cdcce | 2020-01-27 12:57:42 +0100 | [diff] [blame] | 622 | # Add to ui_npm. Other packages.json can be updated in the same way |
| 623 | cd $gerrit_repo/polygerrit-ui/app |
| 624 | bazel run @nodejs//:yarn add $package |
Dave Borowitz | f04eb08 | 2018-07-16 08:51:17 -0700 | [diff] [blame] | 625 | ---- |
| 626 | |
Dmitrii Filippov | c2cdcce | 2020-01-27 12:57:42 +0100 | [diff] [blame] | 627 | Update the `polygerrit-ui/app/node_modules_licenses/licenses.ts` file. You should add licenses |
| 628 | for the package itself and for all transitive depndencies. If you forgot to add a license, the |
| 629 | `Documentation:check_licenses` test will fail. |
Dave Borowitz | f04eb08 | 2018-07-16 08:51:17 -0700 | [diff] [blame] | 630 | |
Dmitrii Filippov | c2cdcce | 2020-01-27 12:57:42 +0100 | [diff] [blame] | 631 | After the update, commit all changes to the repository (including `yarn.lock`). |
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 | [NOTE] |
| 634 | ==== |
| 635 | If a npm package has transitive dependencies (or just several files) with a not allowed |
| 636 | license and you can't avoid use it in release, then you can add this package. |
| 637 | 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] | 638 | dependencies, which are not needed to build the Gerrit web app, but they are installed together |
| 639 | with the package anyway. |
Dave Borowitz | f04eb08 | 2018-07-16 08:51:17 -0700 | [diff] [blame] | 640 | |
Dmitrii Filippov | c2cdcce | 2020-01-27 12:57:42 +0100 | [diff] [blame] | 641 | In this case you should exclude all files and/or transitive dependencies with a not allowed license. |
| 642 | Adding such package requires additional updates: |
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 | - Add dependencies (or files) to the license.ts with an appropriate license marked with |
| 645 | `allowed: false`. |
Dave Borowitz | f04eb08 | 2018-07-16 08:51:17 -0700 | [diff] [blame] | 646 | |
Dmitrii Filippov | c2cdcce | 2020-01-27 12:57:42 +0100 | [diff] [blame] | 647 | - update package.json postinstall script to remove all non-allowed files (if you don't |
| 648 | update postinstall script, `Documentation:check_licenses` test will fail.) |
| 649 | ==== |
| 650 | |
| 651 | === Update NPM Binaries |
| 652 | To update a NPM binary the same actions as for a new one must be done (check licenses, |
| 653 | update `licenses.ts` file, etc...). The only difference is a command to install a package: instead |
| 654 | of `bazel run @nodejs//:yarn add $package` you should run the `bazel run @nodejs//:yarn upgrade ...` |
| 655 | command with correct arguments. You can find the list of arguments in the |
| 656 | 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] | 657 | |
| 658 | |
Han-Wen Nienhuys | 9c15e2b | 2019-05-16 16:59:33 +0200 | [diff] [blame] | 659 | [[RBE]] |
David Pursehouse | 0713b9a | 2019-05-21 12:20:26 +0900 | [diff] [blame] | 660 | == Google Remote Build Support |
Han-Wen Nienhuys | 9c15e2b | 2019-05-16 16:59:33 +0200 | [diff] [blame] | 661 | |
| 662 | The Bazel build can be used with Google's Remote Build Execution. |
| 663 | |
| 664 | |
| 665 | This needs the following setup steps: |
| 666 | |
| 667 | ``` |
| 668 | gcloud auth application-default login |
| 669 | gcloud services enable remotebuildexecution.googleapis.com --project=${PROJECT} |
| 670 | ``` |
| 671 | |
| 672 | Create a worker pool. The instances should have at least 4 CPUs each |
| 673 | for adequate performance. |
| 674 | |
| 675 | ``` |
| 676 | gcloud alpha remote-build-execution worker-pools create default \ |
| 677 | --project=${PROJECT} \ |
| 678 | --instance=default_instance \ |
| 679 | --worker-count=50 \ |
Han-Wen Nienhuys | 8abed33 | 2020-04-06 16:50:38 +0200 | [diff] [blame] | 680 | --machine-type=e2-standard-4 \ |
Han-Wen Nienhuys | 9c15e2b | 2019-05-16 16:59:33 +0200 | [diff] [blame] | 681 | --disk-size=200 |
| 682 | ``` |
| 683 | |
| 684 | To use RBE, execute |
| 685 | |
| 686 | ``` |
| 687 | bazel test --config=remote \ |
| 688 | --remote_instance_name=projects/${PROJECT}/instances/default_instance \ |
| 689 | javatests/... |
| 690 | ``` |
| 691 | |
| 692 | |
Han-Wen Nienhuys | 80fcbe1 | 2016-09-22 13:16:51 +0200 | [diff] [blame] | 693 | GERRIT |
| 694 | ------ |
| 695 | Part of link:index.html[Gerrit Code Review] |
| 696 | |
| 697 | SEARCHBOX |
| 698 | --------- |