Merge branch 'stable-2.16' * stable-2.16: PolyGerrit UI integration Upgrade bazlets to latest stable-2.16 to build with 2.16.13 API Upgrade bazlets to latest stable-2.16 Upgrade bazlets to latest stable-2.15 to build with 2.15.18 API Upgrade bazlets to latest stable-2.15 Upgrade bazlets to latest stable-2.14 Bazel: Migrate workspace status script to python Upgrade bazlets to latest stable-2.16 Upgrade bazlets to latest stable-2.15 Upgrade bazlets to latest stable-2.14 Bump Bazel version to 1.1.0 build.md: Correct bazel test commands Remove bazel-genfiles from .gitignore Replace bazel-genfiles with bazel-bin in documentation Bump bazel version to 1.0.0 Upgrade bazlets to latest stable-2.16 to build with 2.16.12 API Upgrade bazlets to latest stable-2.15 to build with 2.15.17 API Switch required bazel version to 0.29.1 Make build tests name consistent with stable-2.15 Upgrade bazlets to latest stable-2.16 Upgrade bazlets to latest stable-2.15 Bump required bazel version to 1.0.0rc2 Upgrade bazlets to latest stable-2.14 Upgrade bazlets to latest stable-2.15 Upgrade bazlets to latest stable-2.14 Bazel: Add fixes for --incompatible_load_java_rules_from_bzl Bazel: Use junit_test instead of java_test Upgrade bazlets to latest stable-2.16 to build with 2.16.11.1 API Upgrade bazlets to latest stable-2.15 to build with 2.15.16 API Upgrade bazlets to latest stable-2.15 to build with 2.15.15 API Upgrade bazlets to latest stable-2.16 to build with 2.16.10 API Upgrade bazlets to latest stable-2.16 Upgrade bazlets to latest stable-2.15 Upgrade bazlets to latest stable-2.14 Upgrade bazlets to latest stable-2.15 BUILD: Make java_test name consistent with other plugins Upgrade bazlets to latest stable-2.14 Upgrade bazlets to latest stable-2.16 to build with 2.16.9 API Upgrade bazlets to latest stable-2.15 Upgrade bazlets to latest stable-2.14 Upgrade bazlets to latest stable-2.15 to build with 2.15.14 API Change-Id: Idb428a5cbd2bb0533202c4143670db7562eea0a5
diff --git a/.bazelrc b/.bazelrc index 4ed16cf..3ae03ff 100644 --- a/.bazelrc +++ b/.bazelrc
@@ -1,2 +1,2 @@ -build --workspace_status_command=./tools/workspace-status.sh +build --workspace_status_command="python ./tools/workspace_status.py" test --build_tests_only
diff --git a/.bazelversion b/.bazelversion new file mode 100644 index 0000000..9084fa2 --- /dev/null +++ b/.bazelversion
@@ -0,0 +1 @@ +1.1.0
diff --git a/.gitignore b/.gitignore index bd910fd..a6ef529 100644 --- a/.gitignore +++ b/.gitignore
@@ -3,7 +3,6 @@ /.settings *.pyc bazel-bin -bazel-genfiles bazel-out bazel-testlogs bazel-verify-status
diff --git a/BUILD b/BUILD index e1a13dd..27d5da3 100644 --- a/BUILD +++ b/BUILD
@@ -1,9 +1,13 @@ +load("@rules_java//java:defs.bzl", "java_library") load( "//tools/bzl:plugin.bzl", "PLUGIN_DEPS", "PLUGIN_TEST_DEPS", "gerrit_plugin", ) +load("//tools/bzl:junit.bzl", "junit_tests") +load("//tools/bzl:genrule2.bzl", "genrule2") +load("//tools/bzl:js.bzl", "polygerrit_plugin") gerrit_plugin( name = "verify-status", @@ -18,15 +22,15 @@ "Implementation-Title: Verify Status Plugin", "Implementation-URL: https://gerrit-review.googlesource.com/#/admin/projects/plugins/verify-status", ], + resource_jars = [":gr-verify-status-static"], resources = glob(["src/main/**/*"]), ) -java_test( - name = "verify-status-tests", +junit_tests( + name = "verify-status_tests", size = "small", srcs = ["src/test/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusIT.java"], tags = ["verify-status"], - test_class = "com.googlesource.gerrit.plugins.verifystatus.VerifyStatusIT", deps = [ ":verify-status__plugin_test_deps", ], @@ -40,3 +44,20 @@ ":verify-status__plugin", ], ) + +genrule2( + name = "gr-verify-status-static", + srcs = [":gr-verify-status"], + outs = ["gr-verify-status-static.jar"], + cmd = " && ".join([ + "mkdir $$TMP/static", + "cp -r $(locations :gr-verify-status) $$TMP/static", + "cd $$TMP", + "zip -Drq $$ROOT/$@ -g .", + ]), +) + +polygerrit_plugin( + name = "gr-verify-status", + app = "gr-verify-status-plugin.html", +)
diff --git a/WORKSPACE b/WORKSPACE index 9957123..4865447 100644 --- a/WORKSPACE +++ b/WORKSPACE
@@ -3,10 +3,34 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "d100b6aad6b37e7db8fa141020c882dc97fb7723", + commit = "23d849dfd1876c1b4b88efa55a4f716895e33fa3", #local_path = "/home/<user>/projects/bazlets", ) +# Polymer dependencies +load( + "@com_googlesource_gerrit_bazlets//:gerrit_polymer.bzl", + "gerrit_polymer", +) + +gerrit_polymer() + +# Load closure compiler with transitive dependencies +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_repositories") + +closure_repositories() + +# Load Gerrit npm_binary toolchain +load("@com_googlesource_gerrit_bazlets//tools:js.bzl", "GERRIT", "npm_binary") +npm_binary( + name = "polymer-bundler", + repository = GERRIT, +) +npm_binary( + name = "crisper", + repository = GERRIT, +) + # Snapshot Plugin API #load( # "@com_googlesource_gerrit_bazlets//:gerrit_api_maven_local.bzl",
diff --git a/gr-verify-status-plugin.html b/gr-verify-status-plugin.html new file mode 100644 index 0000000..42786f6 --- /dev/null +++ b/gr-verify-status-plugin.html
@@ -0,0 +1,121 @@ +<!-- +Copyright (C) 2019 The Android Open Source Project +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at +http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +--> +<dom-module id="verify-status"> +<script type="text/javascript"> + if (window.Polymer) { + Gerrit.install(function(plugin) { + plugin.registerCustomComponent( + 'change-metadata-item', 'gr-verify-status-panel'); + }); + } +</script> +</dom-module> + +<dom-module id="gr-verify-status-panel"> <template> +<style include="gr-form-styles" type="text/css"></style> +<style type="text/css"> + .u-green { + color: #388E3C; + } + + .u-red { + color: #D32F2F; + } +</style> + +<gr-verifiy-status-panel> +<div id="verify-status"> + <span class="u-green">Passed:[[verifystatus.summary.passed]]</span>, + <span class="u-red">Failed:[[verifystatus.summary.failed]]</span>, + <span class="u-black">Not done:[[verifystatus.summary.notdone]]</span> +</div> +<div class="separatedSection style-scope gr-change-metadata" + style="margin-top: 0; padding: 0"> + <table class="test_result_table"> + <tbody> + <template is="dom-repeat" items="{{verifystatus.results}}"> + <tr> + <td class="cell verifiedstatus"><a href$="[[item.url]]">[[item.name]]</a></td> + <td class="cell verifiedstatus verifiedstatus_value">[[item.value]]</td> + </tr> + </template> + </tbody> + </table> +</div> + +</gr-verifiy-status-panel> </template> +<script type="text/javascript"> +/*(function() { + 'use strict';*/ +const Defs = {}; +/** + * @typedef {{ + * summary: Object, + * results: Array, + * }} + */ +Defs.verifystatus; + +Polymer({ + is: 'gr-verify-status-panel', + + properties: { + verifystatus: { + /** @type {Defs.verifystatus} */ + type: Object, + }, + _verifystatus: { + /** @type {Defs.verifystatus} */ + type: Object, + computed: '_fetchData(revision)', + }, + }, + attached() { + this.plugin.attributeHelper(this).bind('revision', this._onRevisionChanged.bind(this)); + }, + + _fetchData(revision) { + const query ='/verify-status~verifications?sort=REPORTER&filter=CURRENT'; + const endpoint = '/changes/' + this.change.id + '/revisions/' + + this.__data__.revision._number + query; + + const errFn = response => { + this.fire('page-error', {response}); + }; + + this.plugin.restApi().get(endpoint, errFn).then(r => { + let summary = {failed:0, passed:0, notdone:0}; + let results = []; + for (let checkid in r) { + let check= r[checkid]; + if (check.value == '0') { + summary.notdone +=1;} + else if (check.value == 1) { + summary.passed +=1; + } + else { + summary.failed +=1; + } + results.push(check); + }; + + this.set('verifystatus', {summary:summary, results: results}); + }); + }, + _onRevisionChanged(value) { + console.log(`(attributeHelper.bind) revision number: ${value._number}`); + }, +}); +/*}());*/ +</script> +</dom-module>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/HttpModule.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/HttpModule.java index d0959e0..517b162 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/HttpModule.java +++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/HttpModule.java
@@ -16,6 +16,7 @@ import com.google.gerrit.extensions.registration.DynamicSet; import com.google.gerrit.extensions.webui.GwtPlugin; +import com.google.gerrit.extensions.webui.JavaScriptPlugin; import com.google.gerrit.extensions.webui.WebUiPlugin; import com.google.inject.servlet.ServletModule; @@ -23,5 +24,6 @@ @Override protected void configureServlets() { DynamicSet.bind(binder(), WebUiPlugin.class).toInstance(new GwtPlugin("verifystatus")); + DynamicSet.bind(binder(), WebUiPlugin.class).toInstance(new JavaScriptPlugin("gr-verify-status.html")); } }
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md index 46f11b1..6a18e01 100644 --- a/src/main/resources/Documentation/build.md +++ b/src/main/resources/Documentation/build.md
@@ -21,13 +21,13 @@ The output is created in ``` - bazel-genfiles/@PLUGIN@.jar + bazel-bin/@PLUGIN@.jar ``` To execute the tests run: ``` - bazel test verify_status_tests + bazel test verify-status_tests ``` ### Build in Gerrit tree @@ -42,7 +42,7 @@ The output is created in ``` - bazel-genfiles/plugins/@PLUGIN@/@PLUGIN@.jar + bazel-bin/plugins/@PLUGIN@/@PLUGIN@.jar ``` This project can be imported into the Eclipse IDE. List the plugin in the @@ -64,7 +64,7 @@ To execute the tests run: ``` - bazel test plugins/verify-status:verify_status_tests + bazel test plugins/verify-status:verify-status_tests ``` How to build the Gerrit Plugin API is described in the [Gerrit
diff --git a/tools/bzl/genrule2.bzl b/tools/bzl/genrule2.bzl new file mode 100644 index 0000000..61c4e18 --- /dev/null +++ b/tools/bzl/genrule2.bzl
@@ -0,0 +1,3 @@ +load("@com_googlesource_gerrit_bazlets//tools:genrule2.bzl", _genrule2 = "genrule2") + +genrule2 = _genrule2
diff --git a/tools/bzl/js.bzl b/tools/bzl/js.bzl new file mode 100644 index 0000000..0f9e367 --- /dev/null +++ b/tools/bzl/js.bzl
@@ -0,0 +1,3 @@ +load("@com_googlesource_gerrit_bazlets//tools:js.bzl", _polygerrit_plugin = "polygerrit_plugin") + +polygerrit_plugin = _polygerrit_plugin
diff --git a/tools/workspace-status.sh b/tools/workspace-status.sh deleted file mode 100755 index 2e97406..0000000 --- a/tools/workspace-status.sh +++ /dev/null
@@ -1,17 +0,0 @@ -#!/bin/bash - -# This script will be run by bazel when the build process starts to -# generate key-value information that represents the status of the -# workspace. The output should be like -# -# KEY1 VALUE1 -# KEY2 VALUE2 -# -# If the script exits with non-zero code, it's considered as a failure -# and the output will be discarded. - -function rev() { - cd $1; git describe --always --match "v[0-9].*" --dirty -} - -echo "STABLE_BUILD_VERIFY-STATUS_LABEL" $(rev .)
diff --git a/tools/workspace_status.py b/tools/workspace_status.py new file mode 100644 index 0000000..e7ece80 --- /dev/null +++ b/tools/workspace_status.py
@@ -0,0 +1,31 @@ +#!/usr/bin/env python + +# This script will be run by bazel when the build process starts to +# generate key-value information that represents the status of the +# workspace. The output should be like +# +# KEY1 VALUE1 +# KEY2 VALUE2 +# +# If the script exits with non-zero code, it's considered as a failure +# and the output will be discarded. + +from __future__ import print_function +import subprocess +import sys + +CMD = ['git', 'describe', '--always', '--match', 'v[0-9].*', '--dirty'] + + +def revision(): + try: + return subprocess.check_output(CMD).strip().decode("utf-8") + except OSError as err: + print('could not invoke git: %s' % err, file=sys.stderr) + sys.exit(1) + except subprocess.CalledProcessError as err: + print('error using git: %s' % err, file=sys.stderr) + sys.exit(1) + + +print("STABLE_BUILD_VERIFY-STATUS_LABEL %s" % revision())