Skip to content

Commit

Permalink
Merge pull request #155 from trz42/enhancement/bot-side-4-bot-build
Browse files Browse the repository at this point in the history
support for `bot/build.sh` in software layer
  • Loading branch information
boegel authored Mar 17, 2023
2 parents 7212212 + ccccfba commit 7964064
Show file tree
Hide file tree
Showing 6 changed files with 322 additions and 254 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,17 +302,24 @@ Replace `PATH_TO_PRIVATE_KEY` with the path you have noted in [Step 5.3](#step5.
### Section `[buildenv]`
The section `[buildenv]` contains information about the build environment.
```
build_job_script = PATH_TO_EESSI_BOT/scripts/eessi-bot-build.slurm
build_job_script = PATH_TO_EESSI_BOT/scripts/bot-build.slurm
```
This points to the job script which will be submitted by the event handler.
The CVMFS configuration could be commented out unless there’s a need to customize the CVMFS configuration.

```
container_cachedir = PATH_TO_SHARED_DIRECTORY
```
The `container_cachedir` may be used to reuse downloaded container image files
across jobs. Thus, jobs can more quickly launch containers.

```
cvmfs_customizations = { "/etc/cvmfs/default.local": "CVMFS_HTTP_PROXY=\"http://PROXY_DNS_NAME:3128|http://PROXY_IP_ADDRESS:3128\"" }
```
It may happen that we need to customize the CVMFS configuration for the build
job. The value of cvmfs_customizations is a dictionary which maps a file name
to an entry that needs to be appended to that file. In the example line above, the
configuration of `CVMFS_HTTP_PROXY` is appended to the file `/etc/cvmfs/default.local`.
The CVMFS configuration could be commented out unless there is a need to customize the CVMFS configuration.
```
http_proxy = http://PROXY_DNS:3128/
https_proxy = http://PROXY_DNS:3128/
Expand Down
6 changes: 5 additions & 1 deletion app.cfg.example
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ private_key = PATH_TO_PRIVATE_KEY

[buildenv]
# name of the job script used for building an EESSI stack
build_job_script = PATH_TO_EESSI_BOT/scripts/eessi-bot-build.slurm
build_job_script = PATH_TO_EESSI_BOT/scripts/bot-build.slurm

#The container_cachedir may be used to reuse downloaded container image files
#across jobs. Thus, jobs can more quickly launch containers.
container_cachedir = PATH_TO_SHARED_DIRECTORY

# it may happen that we need to customize some CVMFS configuration
# the value of cvmfs_customizations is a dictionary which maps a file
Expand Down
19 changes: 18 additions & 1 deletion eessi_bot_event_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from connections import github
from tools import config
from tools.args import event_handler_parse
from tasks.build import check_build_permission, submit_build_jobs
from tasks.build import check_build_permission, submit_build_jobs, get_repo_cfg
from tasks.deploy import deploy_built_artefacts

from pyghee.lib import PyGHee, create_app, get_event_info, read_event_from_json
Expand Down Expand Up @@ -99,6 +99,23 @@ def handle_pull_request_opened_event(self, event_info, pr):
Handle opening of a pull request.
"""
self.log("PR opened: waiting for label bot:build")
app_name = self.cfg['github']['app_name']
# TODO check if PR already has a comment with arch targets and
# repositories
repo_cfg = get_repo_cfg(self.cfg)
comment = f"Instance `{app_name}` is configured to build:"
for arch in repo_cfg['repo_target_map'].keys():
for repo_id in repo_cfg['repo_target_map'][arch]:
comment += f"\n- arch `{'/'.join(arch.split('/')[1:])}` for repo `{repo_id}`"

self.log(f"PR opened: comment '{comment}'")

# create comment to pull request
repo_name = pr.base.repo.full_name
gh = github.get_instance()
repo = gh.get_repo(repo_name)
pull_request = repo.get_pull(pr.number)
pull_request.create_issue_comment(comment)

def handle_pull_request_event(self, event_info, log_file=None):
"""
Expand Down
31 changes: 31 additions & 0 deletions scripts/bot-build.slurm
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
#
# Slurm job script to call bot/build.sh in target pull request.
#
# This file is part of the EESSI build-and-deploy bot,
# see https://github.com/EESSI/eessi-bot-software-layer
#
# The bot helps with requests to add software installations to the
# EESSI software layer, see https://github.com/EESSI/software-layer
#
# author: Kenneth Hoste (@boegel)
# author: Thomas Roeblitz (@trz42)
#
# license: GPLv2
#

# ASSUMPTIONs:
# - working directory has been prepared by the bot with a checkout of a
# pull request (OR by some other means)
# - the working directory contains a directory 'cfg' where the main config
# file 'job.cfg' has been deposited
# - the directory may contain any additional files references in job.cfg,
# for example, repos.cfg and configuration file bundles for repositories

echo "Starting bot-build.slurm"
if [ -f bot/build.sh ]; then
echo "bot/build.sh script found in '${PWD}', so running it!"
bot/build.sh
else
fatal_error "could not find bot/build.sh script in '${PWD}'"
fi
186 changes: 0 additions & 186 deletions scripts/eessi-bot-build.slurm

This file was deleted.

Loading

0 comments on commit 7964064

Please sign in to comment.