This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
lynxis lazus gerrit-no-reply at lists.osmocom.orglynxis lazus has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ci/+/26393 )
Change subject: RFC: lint: annotate lines in gerrit
......................................................................
RFC: lint: annotate lines in gerrit
Use robot comments to add line based comments for the lint output.
Add checkpatch_json from coreboot to parse the checkpatch output and
convert it into a gerrit parsable format.
The jenkins nodes needs to access the gerrit via ssh. It might be more
secure to put this into a second job.
Change-Id: I1a48ddb976e0f53bfc0552d0be11e42ba68d9e49
---
A lint/checkpatch/checkpatch_json.py
M lint/lint_diff.sh
2 files changed, 66 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ci refs/changes/93/26393/1
diff --git a/lint/checkpatch/checkpatch_json.py b/lint/checkpatch/checkpatch_json.py
new file mode 100755
index 0000000..c693809
--- /dev/null
+++ b/lint/checkpatch/checkpatch_json.py
@@ -0,0 +1,61 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0-only
+# from coreboot rev 9cae17d028d4bd3b278fc89ada8e06287917e213
+
+"""
+This utilty generate json output to post comment in gerrit.
+
+INPUT: output of checkpatch.pl.
+OUTPUT: json format output that can be used to post comment in gerrit
+"""
+import os
+import sys
+import json
+
+data = {}
+data['comments'] = []
+list_temp = {}
+
+def update_struct( file_path, msg_output, line_number):
+ if file_path not in list_temp:
+ list_temp[file_path] = []
+ list_temp[file_path].append({
+ "robot_id" : "checkpatch",
+ "robot_run_id" : sys.argv[3],
+ "url" : sys.argv[4],
+ "line" : line_number,
+ "message" : msg_output,}
+ )
+
+def parse_file(input_file):
+ fp = open (input_file, "r")
+ for line in fp:
+ if line.startswith("ERROR:"):
+ msg_output = line.split("ERROR:")[1].strip()
+ elif line.startswith("WARNING:"):
+ msg_output = line.split("WARNING:")[1].strip()
+ elif ": FILE:" in line:
+ temp = line.split("FILE:")
+ file_path = temp[1].split(":")[0]
+ line_number = temp[1].split(":")[1]
+ update_struct( file_path.strip(), msg_output, str(line_number) )
+ else:
+ continue
+ fp.close()
+
+def main():
+ if (len(sys.argv) < 5) or (sys.argv[1] == "-h"):
+ print("HELP:")
+ print(sys.argv[0] + " <input file> <output file in json> <job-id> <job-url>")
+ sys.exit()
+
+ print(sys.argv[1])
+ parse_file(sys.argv[1])
+ data['robot_comments'] = list_temp
+ print(json.dumps(data))
+ out_file = open( sys.argv[2] , "w")
+ json.dump(data, out_file, sort_keys=True, indent=4)
+ out_file.close()
+
+if __name__ == "__main__":
+ main()
diff --git a/lint/lint_diff.sh b/lint/lint_diff.sh
index f8daab7..3532454 100755
--- a/lint/lint_diff.sh
+++ b/lint/lint_diff.sh
@@ -31,6 +31,11 @@
exit 0
fi
+if ! git diff -U0 "$COMMIT" | "$SCRIPT_DIR/checkpatch/checkpatch_osmo.sh" > gerrit_report ; then
+ "$SCRIPT_DIR/checkpatch/checkpatch_json.py" gerrit_report gerrit_report.json "$BUILD_TAG" "$BUILD_URL"
+ ssh -p "$GERRIT_PORT" -l jenkins "$GERRIT_HOST" gerrit review "$GERRIT_PATCHSET_REVISION" --json < gerrit_report.json
+fi
+
echo
echo "Please fix the linting errors above. More information:"
echo "https://osmocom.org/projects/cellular-infrastructure/wiki/Linting"
--
To view, visit https://gerrit.osmocom.org/c/osmo-ci/+/26393
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Change-Id: I1a48ddb976e0f53bfc0552d0be11e42ba68d9e49
Gerrit-Change-Number: 26393
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211127/5e670624/attachment.htm>