Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 1 | """ |
| 2 | Copyright 2018-present Open Networking Foundation |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | """ |
| 16 | |
| 17 | """ |
| 18 | Rules to build the ONOS GUI 2 FW Lib |
| 19 | |
Sean Condon | 7d27516 | 2018-11-02 16:29:06 +0000 | [diff] [blame] | 20 | The GUI2 Angular 7 elements are built here with Angular CLI 'ng' |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 21 | Some work is being done in the Bazel community to integrate Bazel and |
Sean Condon | 7d27516 | 2018-11-02 16:29:06 +0000 | [diff] [blame] | 22 | Angular 7, (Angular Buildtools Convergence - |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 23 | https://docs.google.com/document/d/1OlyiUnoTirUj4gecGxJeZBcjHcFr36RvLsvpBl2mxA8/preview) |
| 24 | but it is in the very early stages (Aug'18) and not yet fit |
| 25 | for production and at present it works as a replacement for Angular CLI |
| 26 | (which is not desirable). |
| 27 | |
| 28 | There are plans to extend Bazel it to work with Angular CLI, and if works |
| 29 | well this Bazel file may be rearchiteced in future. |
| 30 | |
| 31 | Bazel and npm are incompatibe in how they deal with files. npm likes to |
| 32 | follow links to get back to the original canonical path names, and bazel |
| 33 | uses links extensively when populating the sandbox. To get around these |
| 34 | problems, the rules that follow use filegroups to specify the files as |
| 35 | dependencies and then use a genrule to convert the files into a tar ball. |
| 36 | Once the tar ball is unrolled into the sandbox, the links are broken, but |
| 37 | the build is still hermetic since those files are referred to as dependencies in the genrule. |
| 38 | """ |
| 39 | |
Carmelo Cascone | d33d3b4 | 2019-06-18 12:12:36 -0700 | [diff] [blame] | 40 | load("//tools/build/bazel:jdk_genrule.bzl", genrule = "jdk_genrule") |
| 41 | |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 42 | COMPILE_DEPS = CORE_DEPS + JACKSON + KRYO + [ |
| 43 | "@javax_ws_rs_api//jar", |
| 44 | "@servlet_api//jar", |
| 45 | "@jetty_websocket//jar", |
| 46 | "@jetty_util//jar", |
| 47 | "@jersey_media_multipart//jar", |
| 48 | "@jersey_server//jar", |
| 49 | "//utils/rest:onlab-rest", |
| 50 | "//core/store/serializers:onos-core-serializers", |
| 51 | ] |
| 52 | |
| 53 | TEST_DEPS = TEST + [ |
| 54 | "//core/api:onos-api-tests", |
| 55 | "//drivers/default:onos-drivers-default", |
| 56 | ] |
| 57 | |
| 58 | """ |
| 59 | Files that get put at the top level of the tar ball |
| 60 | """ |
| 61 | |
| 62 | filegroup( |
| 63 | name = "_root_level_files", |
| 64 | srcs = |
| 65 | [ |
| 66 | ":angular.json", |
| 67 | ":package.json", |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 68 | ":tsconfig.json", |
| 69 | ":tslint.json", |
Sean Condon | dfc6dba | 2019-11-09 11:50:23 +0000 | [diff] [blame] | 70 | ":yarn.lock", |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 71 | ], |
| 72 | ) |
| 73 | |
| 74 | filegroup( |
| 75 | name = "_e2e_test_files", |
| 76 | srcs = [ |
| 77 | ":e2e/protractor.conf.js", |
| 78 | ":e2e/src/app.e2e-spec.ts", |
| 79 | ":e2e/src/app.po.ts", |
| 80 | ":e2e/tsconfig.e2e.json", |
| 81 | ], |
| 82 | ) |
| 83 | |
| 84 | """ |
| 85 | Make a group file of all the webapp files. |
| 86 | """ |
| 87 | |
| 88 | filegroup( |
| 89 | name = "_gui2_fw_lib_src", |
| 90 | srcs = glob( |
| 91 | [ |
| 92 | "projects/gui2-fw-lib/**", |
Sean Condon | 4b7818d | 2019-05-23 07:45:14 +0100 | [diff] [blame] | 93 | "README.md", |
| 94 | "LICENSE", |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 95 | ], |
| 96 | exclude = [ |
| 97 | "projects/gui2-fw-lib/**/*.spec.*", # Don't track tests here |
| 98 | "projects/gui2-fw-lib/karma.conf.js", |
| 99 | "projects/gui2-fw-lib/src/test.ts", |
| 100 | ], |
| 101 | ), |
| 102 | ) |
| 103 | |
| 104 | """ |
| 105 | Make a group of all the webapp qpp files. |
| 106 | """ |
| 107 | |
| 108 | filegroup( |
| 109 | name = "_gui2_app_files", |
| 110 | srcs = glob( |
| 111 | [ |
| 112 | "src/**/*", |
| 113 | ], |
| 114 | ), |
| 115 | ) |
| 116 | |
| 117 | """ |
| 118 | Make a jar file of all the webapp test (*.spec.ts) files. |
| 119 | """ |
| 120 | |
| 121 | genrule( |
| 122 | name = "_gui2_fw_lib_tests", |
| 123 | srcs = glob( |
| 124 | [ |
| 125 | "projects/gui2-fw-lib/karma.conf.js", |
| 126 | "projects/gui2-fw-lib/src/test.ts", |
| 127 | "projects/gui2-fw-lib/tsconfig.spec.json", |
| 128 | "projects/gui2-fw-lib/**/*.spec.ts", |
| 129 | ], |
| 130 | exclude = [ |
| 131 | "projects/gui2-fw-lib/ng-package.json", |
| 132 | "projects/gui2-fw-lib/ng-package.prod.json", |
| 133 | "projects/gui2-fw-lib/package.json", |
| 134 | "projects/gui2-fw-lib/tsconfig.lib.json", |
| 135 | "projects/gui2-fw-lib/tslint.json", |
| 136 | "projects/gui2-fw-lib/src/public_api.ts", |
| 137 | ], |
| 138 | ), |
| 139 | outs = ["gui2_fw_lib_tests.jar"], |
| 140 | cmd = "cd web/gui2-fw-lib &&" + |
| 141 | " jar Mcf ../../$@ .", |
| 142 | ) |
| 143 | |
| 144 | """ |
| 145 | Make a jar file of all the CSS files we want to reuse in the target. |
| 146 | """ |
| 147 | |
| 148 | genrule( |
| 149 | name = "gui2_fw_lib_ext_css", |
| 150 | srcs = glob( |
| 151 | [ |
| 152 | "projects/gui2-fw-lib/src/lib/widget/panel.css", |
| 153 | "projects/gui2-fw-lib/src/lib/widget/panel-theme.css", |
| 154 | "projects/gui2-fw-lib/src/lib/widget/table.css", |
| 155 | "projects/gui2-fw-lib/src/lib/widget/table.theme.css", |
| 156 | "projects/gui2-fw-lib/src/lib/widget/table.theme.css", |
| 157 | "projects/gui2-fw-lib/src/lib/layer/loading.service.css", |
| 158 | ], |
| 159 | ), |
| 160 | outs = ["gui2_fw_lib_css.jar"], |
| 161 | cmd = " ROOT=`pwd` &&" + |
| 162 | " cd web/gui2-fw-lib/projects/gui2-fw-lib/src/lib &&" + |
| 163 | " jar Mcf $$ROOT/$@ .", |
| 164 | visibility = ["//visibility:public"], |
| 165 | ) |
| 166 | |
| 167 | """ |
| 168 | Install npm packages listed in package.json in web/gui2 |
Sean Condon | c687ccb | 2019-10-25 12:27:54 +0100 | [diff] [blame] | 169 | See bazel-out/k8-fastbuild/bin/web/gui2/onos-gui2-npm-install.log for details of the 'npm install' |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 170 | """ |
| 171 | |
| 172 | genrule( |
| 173 | name = "onos-gui2-fw-npm-install", |
| 174 | srcs = [ |
| 175 | "@nodejs//:bin/npm", |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 176 | "@nodejs//:bin/nodejs/bin/node", |
Sean Condon | dfc6dba | 2019-11-09 11:50:23 +0000 | [diff] [blame] | 177 | "@npm//:node_modules/@angular/cli/bin/ng", |
| 178 | "@npm//:node_modules", |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 179 | ":_root_level_files", |
| 180 | ], |
| 181 | outs = [ |
| 182 | "onos-gui2-npm-install.jar", |
| 183 | "onos-gui2-npm-install.log", |
| 184 | ], |
| 185 | cmd = " ROOT=`pwd` &&" + |
| 186 | " export HOME=. &&" + |
| 187 | " export XDG_CONFIG_HOME=$(@D)/config &&" + # npm config cache to the sandbox |
| 188 | " export BABEL_DISABLE_CACHE=1 &&" + # turn off babel cache |
| 189 | ' if [[ ! -z $${HTTP_PROXY-} ]]; then NPM_ARGS="--proxy $$HTTP_PROXY --without-ssl --insecure"; else NPM_ARGS=""; fi &&' + |
| 190 | " NPM=$(location @nodejs//:bin/npm) &&" + |
| 191 | " export PATH=$$ROOT/$$(dirname $${NPM}):$$PATH &&" + |
Sean Condon | 0a884ad | 2019-10-28 17:57:21 +0000 | [diff] [blame] | 192 | " $$NPM version > $$ROOT/$(location onos-gui2-npm-install.log) 2>&1 &&" + |
Sean Condon | dfc6dba | 2019-11-09 11:50:23 +0000 | [diff] [blame] | 193 | " NM=external/npm/node_modules &&" + |
Sean Condon | 0a884ad | 2019-10-28 17:57:21 +0000 | [diff] [blame] | 194 | " echo $$NM > $$ROOT/$(location onos-gui2-npm-install.log) 2>&1 &&" + |
| 195 | # " ../../$(location @nodejs//:npm) $$NPM_ARGS install --no-cache >> $$ROOT/$(location onos-gui2-npm-install.log) 2>&1 &&" + |
Sean Condon | dfc6dba | 2019-11-09 11:50:23 +0000 | [diff] [blame] | 196 | " cd external/npm &&" + |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 197 | " jar Mcf $$ROOT/$(location onos-gui2-npm-install.jar) node_modules &&" + |
| 198 | " touch $$ROOT/$(location onos-gui2-npm-install.log)", # to get the log always as the 2nd file |
| 199 | message = "NodeJS npm install", |
| 200 | visibility = ["//visibility:public"], |
| 201 | ) |
| 202 | |
| 203 | """ |
| 204 | Run ng build to create outputs in production mode |
Sean Condon | c687ccb | 2019-10-25 12:27:54 +0100 | [diff] [blame] | 205 | See bazel-out/k8-fastbuild/bin/web/gui2/onos-gui2-ng-build-prod.log for details of the Angular CLI output |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 206 | """ |
| 207 | |
| 208 | genrule( |
| 209 | name = "onos-gui2-fw-ng-build", |
| 210 | srcs = [ |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 211 | "@nodejs//:bin/nodejs/bin/node", |
Sean Condon | 0a884ad | 2019-10-28 17:57:21 +0000 | [diff] [blame] | 212 | "@nodejs//:bin/npm", |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 213 | ":onos-gui2-fw-npm-install", |
Sean Condon | dfc6dba | 2019-11-09 11:50:23 +0000 | [diff] [blame] | 214 | "@npm//:node_modules/@angular/cli/bin/ng", |
| 215 | "@npm//:node_modules", |
Sean Condon | 95fb574 | 2019-04-02 12:16:55 +0100 | [diff] [blame] | 216 | "//web/gui:onos-gui-data-for-gui2", |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 217 | ":_root_level_files", |
| 218 | ":_gui2_fw_lib_src", |
| 219 | ], |
| 220 | outs = [ |
| 221 | "gui2-fw-ng-build-prod.log", |
| 222 | "gui2-fw-lib-ver.tgz", |
| 223 | ], |
| 224 | cmd = "ROOT=`pwd` &&" + |
| 225 | " export HOME=. &&" + |
| 226 | " export XDG_CONFIG_HOME=$(@D)/config &&" + |
Sean Condon | 0a884ad | 2019-10-28 17:57:21 +0000 | [diff] [blame] | 227 | " NODE=$(location @nodejs//:bin/nodejs/bin/node) &&" + |
Sean Condon | dfc6dba | 2019-11-09 11:50:23 +0000 | [diff] [blame] | 228 | # " NG=$(location @npm//:node_modules/@angular/cli/bin/ng) &&" + |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 229 | " INSTALL_FILES=($(locations :onos-gui2-fw-npm-install)) &&" + # An array of filenames - sorted by time created |
| 230 | " cd web/gui2-fw-lib &&" + |
| 231 | " jar xf $$ROOT/$${INSTALL_FILES[0]} &&" + |
| 232 | " chmod +x $$ROOT/web/gui2-fw-lib/node_modules/@angular/cli/bin/ng &&" + |
| 233 | " export PATH=$$ROOT/$$(dirname $${NODE}):$$ROOT/web/gui2-fw-lib/node_modules/@angular/cli/bin:$$PATH &&" + |
| 234 | " node -v > ../../$(location gui2-fw-ng-build-prod.log) &&" + |
Sean Condon | 0a884ad | 2019-10-28 17:57:21 +0000 | [diff] [blame] | 235 | " $$ROOT/$(location @nodejs//:bin/npm) version >> ../../$(location gui2-fw-ng-build-prod.log) &&" + |
Sean Condon | 7d27516 | 2018-11-02 16:29:06 +0000 | [diff] [blame] | 236 | " ng version >> ../../$(location gui2-fw-ng-build-prod.log);" + |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 237 | " ng build --prod gui2-fw-lib >> $$ROOT/$(location gui2-fw-ng-build-prod.log) 2>&1 ||" + |
| 238 | " if [ $$? -eq 0 ]; then echo 'Successfully built GUI FW library';" + |
| 239 | " else " + |
| 240 | " echo 'Error running \'ng build gui2-fw-lib\' on \'//web/gui2-fw-lib:onos-gui2-fw-ng-build\'. \\\n" + |
Sean Condon | c687ccb | 2019-10-25 12:27:54 +0100 | [diff] [blame] | 241 | " See bazel-out/k8-fastbuild/bin/web/gui2-fw-lib/gui2-fw-ng-build-prod.log for more details' >&2;" + |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 242 | " exit 1;" + |
| 243 | " fi;" + |
Sean Condon | 95fb574 | 2019-04-02 12:16:55 +0100 | [diff] [blame] | 244 | # see https://github.com/angular/angular-cli/issues/11071 - Angular CLI does not yet copy across assets |
| 245 | " unzip -q $$ROOT/$(location //web/gui:onos-gui-data-for-gui2) web/gui/src/main/webapp/data/img/loading/* &&" + |
| 246 | " mkdir -p dist/gui2-fw-lib/assets &&" + |
| 247 | " mv web/gui/src/main/webapp/data/img/loading dist/gui2-fw-lib/assets &&" + |
Sean Condon | 4b7818d | 2019-05-23 07:45:14 +0100 | [diff] [blame] | 248 | " cp README.md LICENSE dist/gui2-fw-lib &&" + |
Sean Condon | 0a884ad | 2019-10-28 17:57:21 +0000 | [diff] [blame] | 249 | " $$ROOT/$(location @nodejs//:bin/npm) pack ./dist/gui2-fw-lib >> $$ROOT/$(location gui2-fw-ng-build-prod.log) 2>&1 &&" + |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 250 | " mv gui2-fw-lib-*.tgz $$ROOT/$(location gui2-fw-lib-ver.tgz) &&" + |
| 251 | " touch $$ROOT/$(location gui2-fw-ng-build-prod.log)", # to get the log always as the 2nd file |
| 252 | message = "GUI FW Lib build", |
| 253 | visibility = ["//visibility:public"], |
| 254 | ) |
| 255 | |
| 256 | """ |
| 257 | Run 'ng test' to run Angular test and 'ng lint' for checkstyle |
Sean Condon | c687ccb | 2019-10-25 12:27:54 +0100 | [diff] [blame] | 258 | See bazel-out/k8-fastbuild/bin/web/gui2/onos-gui2-fw-ng-lint.log or |
| 259 | bazel-out/k8-fastbuild/bin/web/gui2/onos-gui2-fw-ng-test.log for details of the Angular CLI output |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 260 | """ |
| 261 | |
| 262 | genrule( |
| 263 | name = "_onos-gui2-fw-ng-test", |
| 264 | srcs = [ |
| 265 | "@nodejs//:bin/npm", |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 266 | "@nodejs//:bin/nodejs/bin/node", |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 267 | ":onos-gui2-fw-npm-install", |
Sean Condon | ee5d4b9 | 2019-03-11 19:57:34 +0000 | [diff] [blame] | 268 | "//web/gui:onos-gui-data-for-gui2", |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 269 | ":_root_level_files", |
| 270 | ":_gui2_fw_lib_src", |
| 271 | ":_gui2_fw_lib_tests", |
| 272 | ":_e2e_test_files", |
| 273 | ], |
| 274 | outs = [ |
| 275 | "onos-gui2-fw-ng-ver.log", |
| 276 | "onos-gui2-fw-ng-lint.log", |
| 277 | "onos-gui2-fw-ng-test.log", |
| 278 | ], |
| 279 | cmd = " ROOT=`pwd` &&" + |
| 280 | " export HOME=. &&" + |
| 281 | " export XDG_CONFIG_HOME=$(@D)/config &&" + |
Sean Condon | 0a884ad | 2019-10-28 17:57:21 +0000 | [diff] [blame] | 282 | " NODE=$(location @nodejs//:bin/nodejs/bin/node) &&" + |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 283 | " INSTALL_FILES=($(locations :onos-gui2-fw-npm-install)) &&" + # An array of filenames - sorted by time created |
| 284 | " mkdir -p web/gui2-fw-lib &&" + |
| 285 | " cd web/gui2-fw-lib &&" + |
| 286 | " jar xf ../../$(location :_gui2_fw_lib_tests) &&" + |
| 287 | " jar xf $$ROOT/$${INSTALL_FILES[0]} &&" + |
Sean Condon | ee5d4b9 | 2019-03-11 19:57:34 +0000 | [diff] [blame] | 288 | # next 2 lines needed for png file referenced from mast.component.css |
| 289 | " unzip -q $$ROOT/$(location //web/gui:onos-gui-data-for-gui2) web/gui/src/main/webapp/data/img/dropdown-icon.png &&" + |
| 290 | " mv web/gui/src/main/webapp/data projects/gui2-fw-lib/src/lib/mast/mast/ &&" + |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 291 | " chmod +x $$ROOT/web/gui2-fw-lib/node_modules/@angular/cli/bin/ng &&" + |
| 292 | " export PATH=$$ROOT/$$(dirname $${NODE}):$$ROOT/web/gui2-fw-lib/node_modules/@angular/cli/bin:$$PATH &&" + |
| 293 | " node -v > ../../$(location onos-gui2-fw-ng-ver.log) &&" + |
Sean Condon | 0a884ad | 2019-10-28 17:57:21 +0000 | [diff] [blame] | 294 | " $$ROOT/$(location @nodejs//:bin/npm) -v >> ../../$(location onos-gui2-fw-ng-ver.log) &&" + |
Sean Condon | b2c483c | 2019-01-16 20:28:55 +0000 | [diff] [blame] | 295 | " ng version >> ../../$(location onos-gui2-fw-ng-ver.log);" + |
| 296 | " ng lint gui2-fw-lib > ../../$(location onos-gui2-fw-ng-lint.log) 2>&1 ||" + |
| 297 | " if [ $$? -eq 0 ]; then echo 'Successfully ran lint';" + |
| 298 | " else " + |
| 299 | " echo 'Error running \'ng lint\' on \'//web/gui2-fw-lib:_onos-gui2-fw-ng-test\'. \\\n" + |
Sean Condon | c687ccb | 2019-10-25 12:27:54 +0100 | [diff] [blame] | 300 | " See bazel-out/k8-fastbuild/bin/web/gui2-fw-lib/onos-gui2-fw-ng-lint.log for more details' >&2;" + |
| 301 | " cat ../../$(location onos-gui2-fw-ng-lint.log) >&2 ||" + |
Sean Condon | b2c483c | 2019-01-16 20:28:55 +0000 | [diff] [blame] | 302 | " exit 1;" + |
| 303 | " fi;" + |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 304 | " if [ -f /usr/bin/chromium-browser ]; then " + # Add to this for Mac and Chrome |
| 305 | " export CHROME_BIN=/usr/bin/chromium-browser; " + |
| 306 | " elif [ -f /opt/google/chrome/chrome ]; then " + |
| 307 | " export CHROME_BIN=/opt/google/chrome/chrome; " + |
| 308 | " else " + |
| 309 | " MSG='Warning: Step _onos-gui2-fw-ng-test skipped because \\n" + |
| 310 | " no binary for ChromeHeadless browser was found at /usr/bin/chromium-browser. \\n" + |
| 311 | " Install Google Chrome or Chromium Browser to allow this step to run.';" + |
| 312 | " echo -e $$MSG >&2;" + |
| 313 | " echo -e $$MSG > ../../$(location onos-gui2-fw-ng-test.log);" + |
| 314 | " exit 0;" + |
| 315 | " fi;" + |
Sean Condon | 7d27516 | 2018-11-02 16:29:06 +0000 | [diff] [blame] | 316 | " ng test gui2-fw-lib --preserve-symlinks --code-coverage --browsers=ChromeHeadless" + |
| 317 | " --watch=false > ../../$(location onos-gui2-fw-ng-test.log) 2>&1 ||" + |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 318 | " if [ $$? -eq 0 ]; then echo 'Successfully ran tests';" + |
| 319 | " else " + |
Sean Condon | dfc6dba | 2019-11-09 11:50:23 +0000 | [diff] [blame] | 320 | " echo 'Error running \'ng test\' on \'//web/gui2-fw-lib:_onos-gui2-fw-ng-test\'. \\\n" + |
Sean Condon | c687ccb | 2019-10-25 12:27:54 +0100 | [diff] [blame] | 321 | " See bazel-out/k8-fastbuild/bin/web/gui2-fw-lib/onos-gui2-fw-ng-test.log for more details' >&2;" + |
Sean Condon | dfc6dba | 2019-11-09 11:50:23 +0000 | [diff] [blame] | 322 | " cat ../../$(location onos-gui2-fw-ng-test.log) >&2;" + |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 323 | " exit 1;" + |
| 324 | " fi;", |
| 325 | message = "GUI FW lib lint and test", |
| 326 | ) |
| 327 | |
| 328 | """ |
| 329 | Wrap the genrule for testing in a test |
| 330 | """ |
| 331 | |
| 332 | sh_test( |
| 333 | name = "onos-gui2-ng-tests", |
| 334 | size = "small", |
| 335 | srcs = [ |
| 336 | ":ng-test.sh", |
| 337 | ], |
| 338 | data = [ |
| 339 | ":_onos-gui2-fw-ng-test", |
| 340 | ], |
| 341 | deps = [ |
| 342 | "@bazel_tools//tools/bash/runfiles", |
| 343 | ], |
| 344 | ) |
Sean Condon | dfc6dba | 2019-11-09 11:50:23 +0000 | [diff] [blame] | 345 | |
| 346 | # This export allows targets in other packages to reference files that live |
| 347 | # in this package. |
| 348 | exports_files([ |
| 349 | "tsconfig.json", |
| 350 | ]) |