From 6706a27cb4516afb404d7515f55acc5be95e1810 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 22 2017 08:42:49 +0000 Subject: Allow to manually triggering a run of pagure-ci via a list of sentences And store this list of sentences in the configuration file so we can build on variants. --- diff --git a/doc/configuration.rst b/doc/configuration.rst index 46782fb..8496dde 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -623,6 +623,24 @@ the groups of forks of that users. Defaults to: ``[]`` +TRIGGER_CI +~~~~~~~~~~ + +A run of pagure-ci can be manually triggered if some key sentences are added +as comment to a pull-request. This allows to re-run a test that failed due +to some network outage or other unexpected issues unrelated to the test +suite. + +This configuration key allows to define all the sentences that can be used +to trigger this pagure-ci run. + +Defaults to: ``['pretty please pagure-ci rebuild']`` + +.. note:: The sentences defined in this configuration key should be lower + case only! + + + Deprecated configuration keys ----------------------------- diff --git a/doc/usage/pagure_ci.rst b/doc/usage/pagure_ci.rst index 046fe66..a2a8047 100644 --- a/doc/usage/pagure_ci.rst +++ b/doc/usage/pagure_ci.rst @@ -28,3 +28,6 @@ To manually trigger a run of pagure-ci on a given pull-request, simply add a comment saying: ``pretty please pagure-ci rebuild``. .. note:: To always have this handy, you can save it in the ``Quick Replies``! + +.. note:: This trigger can also be configured per pagure instance via the + configuration file. diff --git a/pagure/default_config.py b/pagure/default_config.py index 62f639f..78930b9 100644 --- a/pagure/default_config.py +++ b/pagure/default_config.py @@ -252,3 +252,5 @@ USER_NAMESPACE = False # List of groups whose projects should not be shown on the user's info page # unless the user has direct access to it. EXCLUDE_GROUP_INDEX = [] + +TRIGGER_CI = ['pretty please pagure-ci rebuild'] diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index 93fc569..f01dd5f 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -1073,7 +1073,8 @@ def add_group_to_project( def add_pull_request_comment(session, request, commit, tree_id, filename, row, comment, user, requestfolder, - notify=True, notification=False): + notify=True, notification=False, + trigger_ci=None): ''' Add a comment to a pull-request. ''' user_obj = get_user(session, user) @@ -1139,7 +1140,7 @@ def add_pull_request_comment(session, request, commit, tree_id, filename, redis=REDIS, ) - if comment.strip().lower() == "pretty please pagure-ci rebuild": + if trigger_ci and comment.strip().lower() in trigger_ci: # Send notification to the CI server if REDIS and request.project.ci_hook and PAGURE_CI: REDIS.publish('pagure.ci', json.dumps({ diff --git a/pagure/ui/fork.py b/pagure/ui/fork.py index 6b0177b..2f60f5a 100644 --- a/pagure/ui/fork.py +++ b/pagure/ui/fork.py @@ -527,6 +527,7 @@ def pull_request_add_comment( comment=comment, user=flask.g.fas_user.username, requestfolder=APP.config['REQUESTS_FOLDER'], + trigger_ci=APP.config['TRIGGER_CI'], ) SESSION.commit() if not is_js: