From ed334d93c074075c7f37d035dd766e818f966b90 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 22 2017 08:42:49 +0000 Subject: [PATCH 1/3] Trigger a new run of pagure-ci via comment If someone comments on a PR with: "Pretty please pagure-ci rebuild" then we'll trigger another run of pagure-ci for that PR --- diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index 3b48fa7..93fc569 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -1139,6 +1139,14 @@ def add_pull_request_comment(session, request, commit, tree_id, filename, redis=REDIS, ) + if comment.strip().lower() == "pretty please pagure-ci rebuild": + # Send notification to the CI server + if REDIS and request.project.ci_hook and PAGURE_CI: + REDIS.publish('pagure.ci', json.dumps({ + 'ci_type': request.project.ci_hook.ci_type, + 'pr': request.to_json(public=True, with_comments=False) + })) + return 'Comment added' From a054245c49252525b41f0e549a8a0a803bbf95d7 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 22 2017 08:42:49 +0000 Subject: [PATCH 2/3] Add a Tips and tricks section to the pagure-ci doc And the first trick is how to manually re-trigger a run of pagure-ci --- diff --git a/doc/usage/pagure_ci.rst b/doc/usage/pagure_ci.rst index 8176c5b..046fe66 100644 --- a/doc/usage/pagure_ci.rst +++ b/doc/usage/pagure_ci.rst @@ -17,3 +17,14 @@ Contents: :maxdepth: 2 pagure_ci_jenkins + + +Tips and tricks +--------------- + +* How to re-trigger a run of pagure-ci on a pull-request? + +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``! From 6706a27cb4516afb404d7515f55acc5be95e1810 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 22 2017 08:42:49 +0000 Subject: [PATCH 3/3] 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: