Skip to content

Commit 29dc5e9

Browse files
authored
Merge pull request #362 from EESSI/develop
release v0.11.0
2 parents 753b7e8 + 5a0b562 commit 29dc5e9

14 files changed

Lines changed: 522 additions & 175 deletions

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,12 @@ The example file (`app.cfg.example`) includes notes on what you have to adjust t
342342

343343
The section `[github]` contains information for connecting to GitHub:
344344

345+
```ini
346+
api_timeout = 10
347+
```
348+
349+
Time limit for requests to GitHub's REST API.
350+
345351
```ini
346352
app_id = 123456
347353
```
@@ -548,6 +554,12 @@ submit_command = /usr/bin/sbatch
548554

549555
`submit_command` is the full path to the Slurm job submission command used for submitting batch jobs. You may want to verify if `sbatch` is provided at that path or determine its actual location (using `which sbatch`).
550556

557+
```ini
558+
cancel_command = /usr/bin/scancel
559+
```
560+
561+
`cancel_command` is the full path to the Slurm command used for cancelling batch jobs. You may want to verify if `scancel` is provided at that path or determine its actual location (using `which scancel`).
562+
551563
```ini
552564
build_permission = -NOT_ALLOWED_GH_ACCOUNT_NAME- [...]
553565
```
@@ -560,11 +572,11 @@ name on GitHub. Thus, one could not - by accident - give build permissions to an
560572
unknown account.
561573

562574
```ini
563-
no_build_permission_comment = The `bot: build ...` command has been used by user `{build_labeler}`, but this person does not have permission to trigger builds.
575+
no_build_permission_comment = GH account `{build_labeler}` is not authorized to trigger or cancel build jobs.
564576
```
565577

566578
`no_build_permission_comment` defines a comment (template) that is used when
567-
the account trying to trigger build jobs has no permission to do so.
579+
the account trying to trigger or cancel build jobs has no permission to do so.
568580

569581
```ini
570582
allow_update_submit_opts = false

RELEASE_NOTES

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
11
This file contains a description of the major changes to the EESSI
22
build-and-deploy bot. For more detailed information, please see the git log.
33

4+
v0.11.0 (28 January 2026)
5+
--------------------------
6+
7+
This is a minor release of the EESSI build-and-deploy bot.
8+
9+
Bug fixes:
10+
* consider all builds for `bot: status [last_build]` command (#357)
11+
* this also replaces running `curl` by using the `requests` library for one `curl` call
12+
13+
Improvements:
14+
* adds support for new command `bot: cancel jobid:[JOBID] ...` (#359)
15+
* only the owner of a job can cancel it
16+
* multiple jobs can be cancelled by specifying multiple `jobid:[JOBID]`
17+
arguments separated by space
18+
19+
Changes to 'app.cfg' settings (see README.md and app.cfg.example for details):
20+
* CHANGED (required) 'no_build_permission_comment' in section '[buildenv]'
21+
Note! sites using the old value may see misleading comments added by the bot,
22+
but the bot will work without the change.
23+
* NEW (required) 'cancel_command' in section '[buildenv]'
24+
25+
426
v0.10.0 (13 November 2025)
527
--------------------------
628

app.cfg.example

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
# Also see documentation at https://github.com/EESSI/eessi-bot-software-layer/blob/main/README.md#step5.5
1919

2020
[github]
21+
# API timeout, time limit for requests to GitHub's REST API
22+
api_timeout = 10
23+
2124
# replace '123456' with the ID of your GitHub App; see https://github.com/settings/apps
2225
app_id = 123456
2326

@@ -155,13 +158,16 @@ slurm_params = --hold
155158
# full path to the job submission command
156159
submit_command = /usr/bin/sbatch
157160

161+
# full path to the job cancellation command
162+
cancel_command = /usr/bin/scancel
163+
158164
# defines which GitHub accounts have the permission to trigger
159165
# build jobs, i.e., for which accounts the bot acts on `bot: build ...`
160166
# commands. If the value is left empty, everyone can trigger build jobs.
161167
build_permission = -NOT_ALLOWED_GH_ACCOUNT_NAME-
162168

163169
# template for comment when user who set a label has no permission to trigger build jobs
164-
no_build_permission_comment = Label `bot:build` has been set by user `{build_labeler}`, but this person does not have permission to trigger builds
170+
no_build_permission_comment = GH account `{build_labeler}` is not authorized to trigger or cancel build jobs.
165171

166172
# whether or not to allow updating the submit options via custom module det_submit_opts
167173
# Should only be enabled (true) with care because this will result in code from the target

containers/Dockerfile.smee-client

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
ARG smee_client_version=4.4.1
2-
# ARG smee_client_version_commit=b837fa85fd05853731160e21356ffd30c8c3e791 # v4.4.1
3-
4-
# pinning base image to specific hash (corresponding to lts-alpine)
1+
# pin base image to specific hash (corresponding to lts-alpine)
52
FROM node@sha256:f36fed0b2129a8492535e2853c64fbdbd2d29dc1219ee3217023ca48aebd3787
6-
ARG smee_client_version
7-
# ARG smee_client_version_commit
83

9-
# Then install
10-
RUN npm install --global smee-client@${smee_client_version}
4+
# create app dir for locked installation
5+
WORKDIR /app
6+
7+
# copy lockfile and manifest
8+
COPY containers/package.json containers/package-lock.json ./
9+
10+
# install exactly what's in the lockfile (change version in package.json and update
11+
# lockfile via 'npm install --package-lock-only')
12+
RUN npm ci --omit=dev
13+
14+
# expose CLI by symlinking
15+
RUN ln -sf /app/node_modules/.bin/smee /usr/local/bin/smee
16+
1117
ENTRYPOINT ["smee"]
1218
CMD ["--help"]

containers/package-lock.json

Lines changed: 62 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

containers/package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "smee-wrapper",
3+
"private": true,
4+
"version": "1.0.0",
5+
"license": "GPL-2.0-only",
6+
"dependencies": {
7+
"smee-client": "4.4.1"
8+
}
9+
}

eessi_bot_event_handler.py

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929

3030
# Local application imports (anything from EESSI/eessi-bot-software-layer)
3131
from connections import github
32-
from tasks.build import check_build_permission, get_node_types, request_bot_build_issue_comments, \
33-
submit_build_jobs
32+
from tasks.build import cancel_jobs, check_build_permission, get_job_ids, get_node_types, \
33+
get_work_dirs, request_bot_build_issue_comments, submit_build_jobs
3434
from tasks.deploy import deploy_built_artefacts, determine_job_dirs
3535
from tasks.clean_up import move_to_trash_bin
3636
from tools import config
@@ -53,6 +53,7 @@
5353
config.BUILDENV_SETTING_BUILD_JOB_SCRIPT, # required
5454
config.BUILDENV_SETTING_BUILD_LOGS_DIR, # optional+recommended
5555
config.BUILDENV_SETTING_BUILD_PERMISSION, # optional+recommended
56+
config.BUILDENV_SETTING_CANCEL_COMMAND, # required
5657
config.BUILDENV_SETTING_CONTAINER_CACHEDIR, # optional+recommended
5758
# config.BUILDENV_SETTING_CLONE_GIT_REPO_VIA, # optional
5859
# config.BUILDENV_SETTING_CVMFS_CUSTOMIZATIONS, # optional
@@ -95,13 +96,15 @@
9596
config.SECTION_EVENT_HANDLER: [
9697
config.EVENT_HANDLER_SETTING_LOG_PATH], # required
9798
config.SECTION_GITHUB: [
99+
config.GITHUB_SETTING_API_TIMEOUT, # required
98100
config.GITHUB_SETTING_APP_ID, # required
99101
config.GITHUB_SETTING_APP_NAME, # required
100102
config.GITHUB_SETTING_INSTALLATION_ID, # required
101103
config.GITHUB_SETTING_PRIVATE_KEY], # required
102104
# the poll interval setting is required for the alternative job handover
103105
# protocol (delayed_begin)
104106
config.SECTION_JOB_MANAGER: [
107+
config.JOB_MANAGER_SETTING_POLL_COMMAND, # required
105108
config.JOB_MANAGER_SETTING_POLL_INTERVAL], # required
106109
config.SECTION_REPO_TARGETS: [
107110
config.REPO_TARGETS_SETTING_REPOS_CFG_DIR], # required
@@ -507,7 +510,7 @@ def handle_bot_command_help(self, event_info, bot_command):
507510
help_msg += "\n - Commands must be sent with a **new** comment (edits of existing comments are ignored)."
508511
help_msg += "\n - A comment may contain multiple commands, one per line."
509512
help_msg += "\n - Every command begins at the start of a line and has the syntax `bot: COMMAND [ARGUMENTS]*`"
510-
help_msg += "\n - Currently supported COMMANDs are: `help`, `build`, `show_config`, `status`"
513+
help_msg += "\n - Currently supported COMMANDs are: `help`, `build`, `show_config`, `status`, `cancel`"
511514
help_msg += "\n"
512515
help_msg += "\n For more information, see https://www.eessi.io/docs/bot"
513516
return help_msg
@@ -679,6 +682,61 @@ def handle_bot_command_status(self, event_info, bot_command):
679682
else:
680683
return "\n - failed to create status comment"
681684

685+
def handle_bot_command_cancel(self, event_info, bot_command):
686+
"""
687+
Handles bot command 'cancel' by parsing 'jobid:' arguments and
688+
cancelling the jobs.
689+
690+
Args:
691+
event_info (dict): event received by event_handler
692+
bot_command (EESSIBotCommand): command to be handled
693+
694+
Returns:
695+
comment (string): list of cancelled jobs if any, error message if not
696+
"""
697+
self.log("processing bot command 'cancel'")
698+
699+
request_body = event_info["raw_request_body"]
700+
repo_name = request_body["repository"]["full_name"]
701+
pr_number = request_body["issue"]["number"]
702+
user = request_body["comment"]["user"]["login"]
703+
704+
gh = github.get_instance()
705+
pr = gh.get_repo(repo_name).get_pull(pr_number)
706+
707+
# Jobs can only be cancelled by the user who submitted the job
708+
# -> No need to proceed if user cannot submit jobs
709+
if not check_build_permission(pr, event_info):
710+
self.log(f"User '{user}' does not have build permission - skipping cancellation.")
711+
return f"\n - User `{user}` cannot submit or cancel build jobs."
712+
713+
# Get valid 'jobid:' arguments
714+
job_ids = get_job_ids(bot_command.action_filters)
715+
if len(job_ids) == 0:
716+
self.log("Got no valid job IDs")
717+
return "\n - No valid job IDs were given."
718+
719+
# Get working directories of jobs
720+
work_dirs = get_work_dirs(job_ids, self.cfg)
721+
if len(work_dirs) == 0:
722+
self.log("None of the given jobs are cancellable")
723+
return "\n - No cancellable jobs were given."
724+
725+
# Log skipped jobs
726+
for job_id in job_ids:
727+
if job_id not in work_dirs.keys():
728+
log(f"Skipping job {job_id} - not found")
729+
730+
# Cancel jobs
731+
cancelled_jobs = cancel_jobs(work_dirs, user, pr, self.cfg)
732+
if len(cancelled_jobs) == 0:
733+
return "\n - No jobs were cancelled."
734+
else:
735+
comment = ""
736+
for job_id in cancelled_jobs:
737+
comment += f"\n - cancelled job `{job_id}`"
738+
return comment
739+
682740
def start(self, app, port=3000):
683741
"""
684742
Logs startup information to shell and log file and starts the app using

eessi_bot_job_manager.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
config.FINISHED_JOB_COMMENTS_SETTING_JOB_RESULT_UNKNOWN_FMT, # required
5858
config.FINISHED_JOB_COMMENTS_SETTING_JOB_TEST_UNKNOWN_FMT], # required
5959
config.SECTION_GITHUB: [
60+
# config.GITHUB_SETTING_API_TIMEOUT, # unused
6061
config.GITHUB_SETTING_APP_ID, # required
6162
# config.GITHUB_SETTING_APP_NAME, # unused
6263
config.GITHUB_SETTING_INSTALLATION_ID, # required

0 commit comments

Comments
 (0)