[build/luci-config] all: create a Tricium recipe

0 views
Skip to first unread message

Carlos Amedee (Gerrit)

unread,
Mar 28, 2023, 4:04:33 PM3/28/23
to goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Heschi Kreinick, Dmitri Shuralyov, Dmitri Shuralyov, Michael Knyszek, golang-co...@googlegroups.com

Carlos Amedee submitted this change.

View Change



7 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:

```
The name of the file: recipes/recipes/tricium_simple.py
Insertions: 3, Deletions: 3.

@@ -17,18 +17,18 @@
def RunSteps(api):
"""This recipe runs quick analyzers for Go repos.
"""
+ project = api.tryserver.gerrit_change_repo_project
commit_message = api.gerrit.get_change_description(
'https://%s' % api.tryserver.gerrit_change.host,
api.tryserver.gerrit_change.change, api.tryserver.gerrit_change.patchset)
- repo_path = api.path['start_dir'].join('go')
+ repo_path = api.path['start_dir'].join(project)
url = 'https://%s' % api.tryserver.gerrit_change.host
ref = "refs/changes/%d/%d/%d" % (api.tryserver.gerrit_change.change%100,
api.tryserver.gerrit_change.change,
api.tryserver.gerrit_change.patchset)
api.git.checkout(url=url, ref=ref, dir_path=repo_path)
- exp_repo_patch_root = "go"
affected_files = api.tryserver.get_files_affected_by_patch(
- patch_root=exp_repo_patch_root,
+ patch_root=project,
report_files_via_property='affected_files')
analyzers = [
api.tricium.analyzers.HTTPS_CHECK,
```

Approvals: Dmitri Shuralyov: Looks good to me, but someone else must approve Carlos Amedee: Ignore missing or failing TryBot-Result Heschi Kreinick: Looks good to me, approved Dmitri Shuralyov: Looks good to me, approved
all: create a Tricium recipe

As instructed in:
https://chromium.googlesource.com/infra/infra/+/932b34a4f3ecbe435f272db64f33ba9be1524cea/go/src/infra/tricium/docs/user-guide.md

Change-Id: I489e048f3bce5503c57b712c8130e18afb9016ae
Reviewed-on: https://go-review.googlesource.com/c/build/+/475923
TryBot-Bypass: Carlos Amedee <car...@golang.org>
Reviewed-by: Dmitri Shuralyov <dmit...@golang.org>
Reviewed-by: Heschi Kreinick <hes...@google.com>
Reviewed-by: Dmitri Shuralyov <dmit...@google.com>
---
M infra/config/recipes.cfg
M recipes/README.recipes.md
A recipes/recipes/tricium_simple.py
3 files changed, 100 insertions(+), 4 deletions(-)

diff --git a/infra/config/recipes.cfg b/infra/config/recipes.cfg
index 35d5491..f795281 100644
--- a/infra/config/recipes.cfg
+++ b/infra/config/recipes.cfg
@@ -1,12 +1,18 @@
{
"api_version": 2,
+ "py3_only": true,
"repo_name": "golang",
"canonical_repo_url": "https://go-review.googlesource.com/build.git",
"deps": {
"recipe_engine": {
"branch": "refs/heads/main",
- "revision": "928ef440687fbb8428c428b03819ebbb57a24ac8",
+ "revision": "b12b29b1516133836ef7fbd61f43bb7202efeb7e",
"url": "https://chromium.googlesource.com/infra/luci/recipes-py.git"
+ },
+ "depot_tools": {
+ "branch": "refs/heads/main",
+ "revision": "d9e2d47985743491d3aa3f74398ada910c9e4fe2",
+ "url": "https://chromium.googlesource.com/chromium/tools/depot_tools.git"
}
},
"recipes_path": "recipes"
diff --git a/recipes/README.recipes.md b/recipes/README.recipes.md
index c4b2340..c0d9d86 100644
--- a/recipes/README.recipes.md
+++ b/recipes/README.recipes.md
@@ -3,15 +3,33 @@
## Table of Contents

**[Recipes](#Recipes)**
- * [hello_world](#recipes-hello_world)
+ * [hello_world](#recipes-hello_world) (Python3 ✅)
+ * [tricium_simple](#recipes-tricium_simple) (Python3 ✅)
## Recipes

### *recipes* / [hello\_world](/recipes/recipes/hello_world.py)

[DEPS](/recipes/recipes/hello_world.py#7): [recipe\_engine/step][recipe_engine/recipe_modules/step]

-PYTHON_VERSION_COMPATIBILITY: PY2
+PYTHON_VERSION_COMPATIBILITY: PY3

&mdash; **def [RunSteps](/recipes/recipes/hello_world.py#11)(api):**
+### *recipes* / [tricium\_simple](/recipes/recipes/tricium_simple.py)

-[recipe_engine/recipe_modules/step]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/928ef440687fbb8428c428b03819ebbb57a24ac8/README.recipes.md#recipe_modules-step
+[DEPS](/recipes/recipes/tricium_simple.py#7): [depot\_tools/gerrit][depot_tools/recipe_modules/gerrit], [depot\_tools/git][depot_tools/recipe_modules/git], [depot\_tools/tryserver][depot_tools/recipe_modules/tryserver], [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/tricium][recipe_engine/recipe_modules/tricium]
+
+PYTHON_VERSION_COMPATIBILITY: PY3
+
+&mdash; **def [RunSteps](/recipes/recipes/tricium_simple.py#17)(api):**
+
+This recipe runs quick analyzers for Go repos.
+
+
+[depot_tools/recipe_modules/gerrit]: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+/d9e2d47985743491d3aa3f74398ada910c9e4fe2/recipes/README.recipes.md#recipe_modules-gerrit
+[depot_tools/recipe_modules/git]: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+/d9e2d47985743491d3aa3f74398ada910c9e4fe2/recipes/README.recipes.md#recipe_modules-git
+[depot_tools/recipe_modules/tryserver]: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+/d9e2d47985743491d3aa3f74398ada910c9e4fe2/recipes/README.recipes.md#recipe_modules-tryserver
+[recipe_engine/recipe_modules/buildbucket]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/b12b29b1516133836ef7fbd61f43bb7202efeb7e/README.recipes.md#recipe_modules-buildbucket
+[recipe_engine/recipe_modules/path]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/b12b29b1516133836ef7fbd61f43bb7202efeb7e/README.recipes.md#recipe_modules-path
+[recipe_engine/recipe_modules/platform]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/b12b29b1516133836ef7fbd61f43bb7202efeb7e/README.recipes.md#recipe_modules-platform
+[recipe_engine/recipe_modules/step]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/b12b29b1516133836ef7fbd61f43bb7202efeb7e/README.recipes.md#recipe_modules-step
+[recipe_engine/recipe_modules/tricium]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/b12b29b1516133836ef7fbd61f43bb7202efeb7e/README.recipes.md#recipe_modules-tricium
diff --git a/recipes/recipes/tricium_simple.py b/recipes/recipes/tricium_simple.py
new file mode 100644
index 0000000..fe847b8
--- /dev/null
+++ b/recipes/recipes/tricium_simple.py
@@ -0,0 +1,72 @@
+# Copyright 2023 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+from recipe_engine import post_process
+
+DEPS = [
+ 'depot_tools/gerrit',
+ 'depot_tools/git',
+ 'depot_tools/tryserver',
+ 'recipe_engine/buildbucket',
+ 'recipe_engine/path',
+ 'recipe_engine/platform',
+ 'recipe_engine/tricium',
+]
+
+def RunSteps(api):
+ """This recipe runs quick analyzers for Go repos.
+ """
+ project = api.tryserver.gerrit_change_repo_project
+ commit_message = api.gerrit.get_change_description(
+ 'https://%s' % api.tryserver.gerrit_change.host,
+ api.tryserver.gerrit_change.change, api.tryserver.gerrit_change.patchset)
+ repo_path = api.path['start_dir'].join(project)
+ url = 'https://%s' % api.tryserver.gerrit_change.host
+ ref = "refs/changes/%d/%d/%d" % (api.tryserver.gerrit_change.change%100,
+ api.tryserver.gerrit_change.change,
+ api.tryserver.gerrit_change.patchset)
+ api.git.checkout(url=url, ref=ref, dir_path=repo_path)
+ affected_files = api.tryserver.get_files_affected_by_patch(
+ patch_root=project,
+ report_files_via_property='affected_files')
+ analyzers = [
+ api.tricium.analyzers.HTTPS_CHECK,
+ api.tricium.analyzers.SPELLCHECKER,
+ api.tricium.analyzers.INCLUSIVE_LANGUAGE_CHECK,
+ api.tricium.analyzers.COPYRIGHT,
+ ]
+ api.tricium.run_legacy(analyzers, repo_path, affected_files, commit_message)
+
+def GenTests(api):
+
+ def test_with_patch(name, affected_files):
+ test = api.test(
+ name,
+ api.buildbucket.try_build(
+ project='go',
+ builder='tricium-simple',
+ git_repo='https://go.googlesource.com/go',
+ change_number=86753,
+ patch_set=1),
+ api.platform('linux', 64),
+ )
+ existing_files = [
+ api.path['start_dir'].join('go', f) for f in affected_files
+ ]
+ test += api.path.exists(*existing_files)
+ return test
+
+ yield test_with_patch('one_file', ['README.md']) + api.post_check(
+ post_process.StatusSuccess) + api.post_process(
+ post_process.DropExpectation)
+
+ yield test_with_patch('many_files', [
+ 'go.mod',
+ 'go.sum',
+ 'build.go',
+ 'LICENSE',
+ 'README.md',
+ 'main.go',
+ ]) + api.post_check(post_process.StatusSuccess) + api.post_process(
+ post_process.DropExpectation)

To view, visit change 475923. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: build
Gerrit-Branch: luci-config
Gerrit-Change-Id: I489e048f3bce5503c57b712c8130e18afb9016ae
Gerrit-Change-Number: 475923
Gerrit-PatchSet: 10
Gerrit-Owner: Carlos Amedee <car...@golang.org>
Gerrit-Reviewer: Carlos Amedee <car...@golang.org>
Gerrit-Reviewer: Dmitri Shuralyov <dmit...@golang.org>
Gerrit-Reviewer: Dmitri Shuralyov <dmit...@google.com>
Gerrit-Reviewer: Heschi Kreinick <hes...@google.com>
Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
Gerrit-MessageType: merged
Reply all
Reply to author
Forward
0 new messages