Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
34 changes: 34 additions & 0 deletions tests/test_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 7 additions & 1 deletion tom/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,18 @@ 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))
msg.append("Triger build for: {}".format(pr.title))
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
Expand All @@ -258,6 +263,7 @@ def trigger_build(self, pr: PR, comment):
comment.author,
docs,
no_tests,
selenium,
)

queue_url = headers["Location"]
Expand All @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions tom/jenkins.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def trigger(
user=None,
docs=False,
no_tests=False,
selenium=False,
):
params = {}
need_slow_build = any(
Expand Down Expand Up @@ -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: "
Expand Down
Loading