uses CI message version 0.2.X
process CI messages as defined on https://pagure.io/fedora-ci/messages/blob/master/f/schemas
This commit is contained in:
parent
8baf2bfc88
commit
4120c9c71d
4 changed files with 45 additions and 20 deletions
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- name: ci.pipeline.allpackages-pr.complete
|
- name: ci.dist-git-pr.test.complete
|
||||||
hosts: localhost
|
hosts: localhost
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
|
|
14
playbooks/org.centos.prod.ci.dist-git-pr.test.error.yml
Normal file
14
playbooks/org.centos.prod.ci.dist-git-pr.test.error.yml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
---
|
||||||
|
- name: ci.dist-git-pr.test.error
|
||||||
|
hosts: localhost
|
||||||
|
gather_facts: false
|
||||||
|
|
||||||
|
vars_files:
|
||||||
|
- "/srv/private/vars_loopabull.yml"
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- debug: var=msg
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- {role: flag_ci_pr, msg: msg, state: "error"}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- name: ci.pipeline.allpackages-pr.package.running
|
- name: ci.dist-git-pr.test.running
|
||||||
hosts: localhost
|
hosts: localhost
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
|
|
|
@ -40,56 +40,69 @@ def main(msg, pipeline_state='complete', seed='empty'):
|
||||||
requests_session.mount(
|
requests_session.mount(
|
||||||
'https://', requests.adapters.HTTPAdapter(max_retries=retry_conf))
|
'https://', requests.adapters.HTTPAdapter(max_retries=retry_conf))
|
||||||
|
|
||||||
if pipeline_state not in ['complete', 'running']:
|
if pipeline_state not in ['complete', 'running', 'error']:
|
||||||
print("Pipeline state is not 'complete' or 'running'.")
|
print("Pipeline state is not 'complete' or 'running' or 'error'.")
|
||||||
|
return
|
||||||
|
|
||||||
|
if 'version' not in msg or not msg['version'].startswith('0.2.'):
|
||||||
|
print('Unsupported msg version, ignoring')
|
||||||
return
|
return
|
||||||
|
|
||||||
commit_hash_text = ''
|
commit_hash_text = ''
|
||||||
# test complete messages
|
# test complete messages
|
||||||
if pipeline_state == 'complete':
|
if pipeline_state == 'complete':
|
||||||
done_states = {
|
done_states = {
|
||||||
'SUCCESS': {'api': 'success', 'human': 'passed'},
|
'passed': {'api': 'success', 'human': 'passed'},
|
||||||
'UNSTABLE': {'api': 'failure', 'human': 'failed'},
|
'error': {'api': 'error', 'human': 'errored'},
|
||||||
'FAILURE': {'api': 'error', 'human': 'errored'},
|
'failed': {'api': 'failure', 'human': 'failed'},
|
||||||
|
'needs_inspection': {'api': 'failure', 'human': 'failed'},
|
||||||
}
|
}
|
||||||
state = msg['status']
|
state = msg['test']['result']
|
||||||
if state not in done_states:
|
if state not in done_states:
|
||||||
print('Build is not in one of the expected status, ignoring')
|
print('Build is not in one of the expected status, ignoring')
|
||||||
return
|
return
|
||||||
|
|
||||||
status = done_states[state]['api']
|
status = done_states[state]['api']
|
||||||
human_status = done_states[state]['human']
|
human_status = done_states[state]['human']
|
||||||
if 'commit_hash' in msg:
|
if 'commit_hash' in msg['artifact']:
|
||||||
commit_hash_text = ' for %s' % msg['commit_hash'][:8]
|
commit_hash_text = ' for %s' % msg['artifact']['commit_hash'][:8]
|
||||||
|
|
||||||
# test running messages
|
# test running messages
|
||||||
elif pipeline_state == 'running':
|
elif pipeline_state == 'running':
|
||||||
status = 'pending'
|
status = 'pending'
|
||||||
human_status = 'running'
|
human_status = 'running'
|
||||||
|
|
||||||
pr_id = str(msg['rev']).partition('PR-')[2]
|
# test error messages
|
||||||
if not pr_id:
|
elif pipeline_state == 'error':
|
||||||
|
status = 'error'
|
||||||
|
human_status = 'errored'
|
||||||
|
|
||||||
|
if 'id' not in msg['artifact']:
|
||||||
print(
|
print(
|
||||||
'Invalid revision: %s, could not extract the PR id from it' %
|
'Invalid message: %s, could not extract the PR id from it' %
|
||||||
msg['rev'])
|
msg['artifact'])
|
||||||
return
|
return
|
||||||
|
pr_id = str(msg['artifact']['id'])
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'username': 'Fedora CI',
|
'username': 'Fedora CI',
|
||||||
'status': status,
|
'status': status,
|
||||||
'comment': 'Package tests%s: %s' % (commit_hash_text, human_status),
|
'comment': 'Package tests%s: %s' % (commit_hash_text, human_status),
|
||||||
'url': msg['build_url'],
|
'url': msg['run']['url'],
|
||||||
'uid': hashlib.md5(pr_id + seed).hexdigest()
|
'uid': hashlib.md5(pr_id + seed).hexdigest()
|
||||||
}
|
}
|
||||||
|
|
||||||
pagure_url = 'https://src.fedoraproject.org'
|
pagure_url = 'https://src.fedoraproject.org'
|
||||||
env_var = 'API_TOKEN'
|
env_var = 'API_TOKEN'
|
||||||
|
|
||||||
|
namespace = msg['artifact']['repository'].split('/')[-2]
|
||||||
|
repo = msg['artifact']['repository'].split('/')[-1]
|
||||||
|
|
||||||
target_url = '/'.join([
|
target_url = '/'.join([
|
||||||
'api',
|
'api',
|
||||||
'0',
|
'0',
|
||||||
msg['namespace'],
|
namespace,
|
||||||
msg['repo'],
|
repo,
|
||||||
'pull-request',
|
'pull-request',
|
||||||
pr_id,
|
pr_id,
|
||||||
'flag'
|
'flag'
|
||||||
|
@ -116,9 +129,7 @@ def main(msg, pipeline_state='complete', seed='empty'):
|
||||||
return 1
|
return 1
|
||||||
else:
|
else:
|
||||||
print('All clear')
|
print('All clear')
|
||||||
print('User-URL: %s' % pagure_url + '/' + '/'.join([
|
print('User-URL: %s' % msg['artifact']['repository'] + '/'.join([
|
||||||
msg['namespace'],
|
|
||||||
msg['repo'],
|
|
||||||
'pull-request',
|
'pull-request',
|
||||||
pr_id,
|
pr_id,
|
||||||
]))
|
]))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue