| |
@@ -12,6 +12,7 @@
|
| |
"""
|
| |
from __future__ import unicode_literals
|
| |
|
| |
+ import hashlib
|
| |
import json
|
| |
import os
|
| |
import sys
|
| |
@@ -19,11 +20,13 @@
|
| |
import requests
|
| |
from requests.packages.urllib3.util import retry
|
| |
|
| |
-
|
| |
-
|
| |
- def main(msg):
|
| |
+ def main(msg, pipeline_state='complete', seed='empty'):
|
| |
""" Check if the build was successful and if so, flag the commit in
|
| |
pagure.
|
| |
+
|
| |
+ :param str msg: the fedmsg message body
|
| |
+ :param str pipeline_state: state of the testing, one of 'complete'
|
| |
+ or 'running'
|
| |
"""
|
| |
|
| |
timeout = (30, 30)
|
| |
@@ -37,16 +40,30 @@
|
| |
requests_session.mount(
|
| |
'https://', requests.adapters.HTTPAdapter(max_retries=retry_conf))
|
| |
|
| |
- done_states = {
|
| |
- 'SUCCESS': {'api': 'success', 'human': 'passed'},
|
| |
- 'UNSTABLE': {'api': 'failure', 'human': 'failed'},
|
| |
- 'FAILURE': {'api': 'error', 'human': 'errored'},
|
| |
- }
|
| |
- state = msg['status']
|
| |
- if state not in done_states:
|
| |
- print('Build is not in one of the expected status, ignoring')
|
| |
+ if pipeline_state not in ['complete', 'running']:
|
| |
+ print("Pipeline state is not 'complete' or 'running'.")
|
| |
return
|
| |
|
| |
+ # test complete messages
|
| |
+ if pipeline_state == 'complete':
|
| |
+ done_states = {
|
| |
+ 'SUCCESS': {'api': 'success', 'human': 'passed'},
|
| |
+ 'UNSTABLE': {'api': 'failure', 'human': 'failed'},
|
| |
+ 'FAILURE': {'api': 'error', 'human': 'errored'},
|
| |
+ }
|
| |
+ state = msg['status']
|
| |
+ if state not in done_states:
|
| |
+ print('Build is not in one of the expected status, ignoring')
|
| |
+ return
|
| |
+
|
| |
+ status = done_states[state]['api']
|
| |
+ human_status = done_states[state]['human']
|
| |
+
|
| |
+ # test running messages
|
| |
+ elif pipeline_state == 'running':
|
| |
+ status = 'pending'
|
| |
+ human_status = 'running'
|
| |
+
|
| |
pr_id = msg['rev'].partition('PR-')[2]
|
| |
if not pr_id:
|
| |
print(
|
| |
@@ -54,12 +71,12 @@
|
| |
msg['rev'])
|
| |
return
|
| |
|
| |
-
|
| |
data = {
|
| |
'username': 'Fedora CI',
|
| |
- 'status': done_states[state]['api'],
|
| |
- 'comment': 'Package tests: %s' % (done_states[state]['human']),
|
| |
+ 'status': status,
|
| |
+ 'comment': 'Package tests: %s' % human_status,
|
| |
'url': msg['build_url'],
|
| |
+ 'uid': hashlib.md5(pr_id + seed).hexdigest()
|
| |
}
|
| |
|
| |
pagure_url = 'https://src.fedoraproject.org'
|
| |
@@ -107,4 +124,4 @@
|
| |
if __name__ == '__main__':
|
| |
msg = sys.argv[1]
|
| |
msg = json.loads(msg)
|
| |
- sys.exit(main(msg))
|
| |
+ sys.exit(main(msg, sys.argv[2], sys.argv[3]))
|
| |
This patch adds support for runinng state for Fedora CI.
It keeps only the recent flag around, so running transitions nicely
to complete/error state and vice versa (for reruns).
Resolves https://pagure.io/fedora-ci/general/issue/3
Signed-off-by: Miroslav Vadkerti mvadkert@redhat.com