From d9183decac242bde87f995ff85b2479d8dc78e1d Mon Sep 17 00:00:00 2001 From: Ihor Aleksandrychiev Date: Tue, 7 Jul 2026 11:22:44 +0300 Subject: [PATCH] Introduced `selenium` command to trigger selenium-only pr-pipeline builds Mentioning `@cf-bottom selenium` on a PR triggers the same pr-pipeline as other build keywords, but restricts the build to the RHEL 9 hub package and runs only selenium tests. Ticket: ENT-14215 Signed-off-by: Ihor Aleksandrychiev --- README.md | 3 ++- tests/test_bot.py | 34 ++++++++++++++++++++++++++++++++++ tom/bot.py | 8 +++++++- tom/jenkins.py | 16 ++++++++++++++++ 4 files changed, 59 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 861d8d9..51ed544 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,14 @@ Mention Tom in a comment with `@cf-bottom` and then include some trigger keyword In `tom/bot.py`: ```python - trigger_words = ["jenkins", "pipeline", "build", "test", "trigger"] + trigger_words = ["jenkins", "pipeline", "build", "test", "trigger", "selenium"] ``` Other keywords available in comments are: * `exotic` - includes exotics platforms such as AIX, HP/UX, Solaris * `no test` - don't run tests. This is useful if you only need packages. Tests are resource intensive so use this option often if it makes sense. +* `selenium` - run only Selenium tests on RHEL 9 Hub packages (skips all other tests and static checks). ### Install dependencies and setup local venv diff --git a/tests/test_bot.py b/tests/test_bot.py index d5a398e..9c1bb80 100644 --- a/tests/test_bot.py +++ b/tests/test_bot.py @@ -109,6 +109,40 @@ def test_notest_build(): ) +def test_selenium_build(): + github_requests, jenkins_requests = _trigger_build( + repo="core", + prs={"core": 42, "nova": 43}, + comment="@cf-bottom selenium", + ) + jenkins_requests.post.assert_called_once_with( + "https://ci.cfengine.com/job/pr-pipeline/buildWithParameters/api/json", + data={ + "CORE_REV": "42", + "NOVA_REV": "43", + "BASE_BRANCH": "master", + "CONFIGURATIONS_FILTER": 'label == "PACKAGES_HUB_x86_64_linux_redhat_9"', + "NO_TESTS": True, + "NO_ACCEPTANCE_TESTS": True, + "NO_DEPLOYMENT_TESTS": True, + "NO_SLOW_DEPLOYMENT_TESTS": True, + "NO_FR_TESTS": True, + "NO_STATIC_CHECKS": True, + "RUN_SELENIUM_TESTS": True, + "BUILD_DESC": "Test PR Title @test-trusted-author (core#42 nova#43 master) [SELENIUM]", + }, + headers={"Jenkins-Crumb": "test-jenkins-crumb"}, + auth=ANY, + ) + github_requests.post.assert_called_once_with( + "https://github.com/cfengine/core/pulls/42/comment_reference", + headers={"Authorization": "token test-github-token", "User-Agent": "cf-bottom"}, + json={ + "body": "Predictably, I triggered a build:\n\n[![Build Status](https://ci.cfengine.com//buildStatus/icon?job=pr-pipeline&build=22)](https://ci.cfengine.com//job/pr-pipeline/22/)\n\n [SELENIUM]\n\n**Jenkins:** https://ci.cfengine.com/job/pr-pipeline/22\n\n**Packages:** http://buildcache.cfengine.com/packages/testing-pr/jenkins-pr-pipeline-22/" + }, + ) + + def test_all_options_build(): github_requests, jenkins_requests = _trigger_build( repo="documentation", diff --git a/tom/bot.py b/tom/bot.py index 74e18b4..bff5062 100644 --- a/tom/bot.py +++ b/tom/bot.py @@ -239,6 +239,10 @@ def trigger_build(self, pr: PR, comment): if no_tests: description += " [NO TESTS]" + selenium = "selenium" in comment + if selenium: + description += " [SELENIUM]" + if self.interactive: msg = [] msg.append(str(comment)) @@ -246,6 +250,7 @@ def trigger_build(self, pr: PR, comment): msg.append("PRs: {}".format(prs)) msg.append("EXOTICS: {}".format(exotics)) msg.append("NO_TESTS: {}".format(no_tests)) + msg.append("SELENIUM: {}".format(selenium)) msg = "\n".join(msg) if not confirmation(msg): return @@ -258,6 +263,7 @@ def trigger_build(self, pr: PR, comment): comment.author, docs, no_tests, + selenium, ) queue_url = headers["Location"] @@ -276,7 +282,7 @@ def handle_mention(self, pr, comment): self.comment(pr, deny) return body = comment.body.lower() - trigger_words = ["jenkins", "pipeline", "build", "test", "trigger"] + trigger_words = ["jenkins", "pipeline", "build", "test", "trigger", "selenium"] for word in trigger_words: if word.lower() in body: self.trigger_build(pr, comment) diff --git a/tom/jenkins.py b/tom/jenkins.py index 64a9892..ddd8847 100644 --- a/tom/jenkins.py +++ b/tom/jenkins.py @@ -55,6 +55,7 @@ def trigger( user=None, docs=False, no_tests=False, + selenium=False, ): params = {} need_slow_build = any( @@ -131,6 +132,21 @@ def trigger( param_name = param_name.replace("DOCUMENTATION", "DOCS") param_name = param_name.replace("GENERATOR", "GEN") params[param_name] = str(prs[repo]) + if selenium: + # We need to run selenium tests on the hub rhel 9 package, + # so add only it to the filter to avoid building packages + # for other platforms that we will not use. + params["CONFIGURATIONS_FILTER"] = ( + 'label == "PACKAGES_HUB_x86_64_linux_redhat_9"' + ) + params["NO_TESTS"] = True + params["NO_ACCEPTANCE_TESTS"] = True + params["NO_DEPLOYMENT_TESTS"] = True + params["NO_SLOW_DEPLOYMENT_TESTS"] = True + params["NO_FR_TESTS"] = True + params["NO_STATIC_CHECKS"] = True + params["RUN_SELENIUM_TESTS"] = True + description += " [SELENIUM]" params["BUILD_DESC"] = description log.info( "Triggering build with params: "