From 63026fde239feba9a4ed895abec88f99e4240aa1 Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Sat, 18 May 2019 17:25:26 +0200 Subject: [PATCH] Move verify-repo-built-successful.py here --- gocd/pkglistgen_staging.gocd.yaml | 242 ++++++-------------------- gocd/pkglistgen_staging.gocd.yaml.erb | 22 +-- gocd/verify-repo-built-successful.py | 51 ++++++ 3 files changed, 114 insertions(+), 201 deletions(-) create mode 100755 gocd/verify-repo-built-successful.py diff --git a/gocd/pkglistgen_staging.gocd.yaml b/gocd/pkglistgen_staging.gocd.yaml index f905151d..fefd4a80 100644 --- a/gocd/pkglistgen_staging.gocd.yaml +++ b/gocd/pkglistgen_staging.gocd.yaml @@ -149,21 +149,15 @@ pipelines: destination: scripts whitelist: - DO_NOT_TRIGGER - citest: - git: https://github.com/coolo/citest.git - auto_update: true - destination: citest - whitelist: - - DO_NOT_TRIGGER stages: - Checks: jobs: Check.Build.Succeeds: resources: - - staging-bot + - staging-bot3 tasks: - script: |- - python ./citest/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard + python3 ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard Repo.Checker: environment_variables: @@ -183,7 +177,7 @@ pipelines: - Enable.images.repo: resources: - - staging-bot + - staging-bot3 tasks: - script: |- osc -A $STAGING_API api -X POST "/source/$STAGING_PROJECT?cmd=remove_flag&repository=images&flag=build" @@ -209,21 +203,15 @@ pipelines: destination: scripts whitelist: - DO_NOT_TRIGGER - citest: - git: https://github.com/coolo/citest.git - auto_update: true - destination: citest - whitelist: - - DO_NOT_TRIGGER stages: - Checks: jobs: Check.Build.Succeeds: resources: - - staging-bot + - staging-bot3 tasks: - script: |- - python ./citest/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard + python3 ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard Repo.Checker: environment_variables: @@ -243,7 +231,7 @@ pipelines: - Enable.images.repo: resources: - - staging-bot + - staging-bot3 tasks: - script: |- osc -A $STAGING_API api -X POST "/source/$STAGING_PROJECT?cmd=remove_flag&repository=images&flag=build" @@ -269,21 +257,15 @@ pipelines: destination: scripts whitelist: - DO_NOT_TRIGGER - citest: - git: https://github.com/coolo/citest.git - auto_update: true - destination: citest - whitelist: - - DO_NOT_TRIGGER stages: - Checks: jobs: Check.Build.Succeeds: resources: - - staging-bot + - staging-bot3 tasks: - script: |- - python ./citest/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard + python3 ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard Repo.Checker: environment_variables: @@ -303,7 +285,7 @@ pipelines: - Enable.images.repo: resources: - - staging-bot + - staging-bot3 tasks: - script: |- osc -A $STAGING_API api -X POST "/source/$STAGING_PROJECT?cmd=remove_flag&repository=images&flag=build" @@ -329,21 +311,15 @@ pipelines: destination: scripts whitelist: - DO_NOT_TRIGGER - citest: - git: https://github.com/coolo/citest.git - auto_update: true - destination: citest - whitelist: - - DO_NOT_TRIGGER stages: - Checks: jobs: Check.Build.Succeeds: resources: - - staging-bot + - staging-bot3 tasks: - script: |- - python ./citest/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard + python3 ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard Repo.Checker: environment_variables: @@ -363,7 +339,7 @@ pipelines: - Enable.images.repo: resources: - - staging-bot + - staging-bot3 tasks: - script: |- osc -A $STAGING_API api -X POST "/source/$STAGING_PROJECT?cmd=remove_flag&repository=images&flag=build" @@ -389,21 +365,15 @@ pipelines: destination: scripts whitelist: - DO_NOT_TRIGGER - citest: - git: https://github.com/coolo/citest.git - auto_update: true - destination: citest - whitelist: - - DO_NOT_TRIGGER stages: - Checks: jobs: Check.Build.Succeeds: resources: - - staging-bot + - staging-bot3 tasks: - script: |- - python ./citest/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard + python3 ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard Repo.Checker: environment_variables: @@ -423,7 +393,7 @@ pipelines: - Enable.images.repo: resources: - - staging-bot + - staging-bot3 tasks: - script: |- osc -A $STAGING_API api -X POST "/source/$STAGING_PROJECT?cmd=remove_flag&repository=images&flag=build" @@ -449,21 +419,15 @@ pipelines: destination: scripts whitelist: - DO_NOT_TRIGGER - citest: - git: https://github.com/coolo/citest.git - auto_update: true - destination: citest - whitelist: - - DO_NOT_TRIGGER stages: - Checks: jobs: Check.Build.Succeeds: resources: - - staging-bot + - staging-bot3 tasks: - script: |- - python ./citest/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard + python3 ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard Repo.Checker: environment_variables: @@ -483,7 +447,7 @@ pipelines: - Enable.images.repo: resources: - - staging-bot + - staging-bot3 tasks: - script: |- osc -A $STAGING_API api -X POST "/source/$STAGING_PROJECT?cmd=remove_flag&repository=images&flag=build" @@ -509,21 +473,15 @@ pipelines: destination: scripts whitelist: - DO_NOT_TRIGGER - citest: - git: https://github.com/coolo/citest.git - auto_update: true - destination: citest - whitelist: - - DO_NOT_TRIGGER stages: - Checks: jobs: Check.Build.Succeeds: resources: - - staging-bot + - staging-bot3 tasks: - script: |- - python ./citest/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard + python3 ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard Repo.Checker: environment_variables: @@ -543,7 +501,7 @@ pipelines: - Enable.images.repo: resources: - - staging-bot + - staging-bot3 tasks: - script: |- osc -A $STAGING_API api -X POST "/source/$STAGING_PROJECT?cmd=remove_flag&repository=images&flag=build" @@ -569,21 +527,15 @@ pipelines: destination: scripts whitelist: - DO_NOT_TRIGGER - citest: - git: https://github.com/coolo/citest.git - auto_update: true - destination: citest - whitelist: - - DO_NOT_TRIGGER stages: - Checks: jobs: Check.Build.Succeeds: resources: - - staging-bot + - staging-bot3 tasks: - script: |- - python ./citest/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard + python3 ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard Repo.Checker: environment_variables: @@ -603,7 +555,7 @@ pipelines: - Enable.images.repo: resources: - - staging-bot + - staging-bot3 tasks: - script: |- osc -A $STAGING_API api -X POST "/source/$STAGING_PROJECT?cmd=remove_flag&repository=images&flag=build" @@ -629,21 +581,15 @@ pipelines: destination: scripts whitelist: - DO_NOT_TRIGGER - citest: - git: https://github.com/coolo/citest.git - auto_update: true - destination: citest - whitelist: - - DO_NOT_TRIGGER stages: - Checks: jobs: Check.Build.Succeeds: resources: - - staging-bot + - staging-bot3 tasks: - script: |- - python ./citest/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard + python3 ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard Repo.Checker: environment_variables: @@ -663,7 +609,7 @@ pipelines: - Enable.images.repo: resources: - - staging-bot + - staging-bot3 tasks: - script: |- osc -A $STAGING_API api -X POST "/source/$STAGING_PROJECT?cmd=remove_flag&repository=images&flag=build" @@ -689,21 +635,15 @@ pipelines: destination: scripts whitelist: - DO_NOT_TRIGGER - citest: - git: https://github.com/coolo/citest.git - auto_update: true - destination: citest - whitelist: - - DO_NOT_TRIGGER stages: - Checks: jobs: Check.Build.Succeeds: resources: - - staging-bot + - staging-bot3 tasks: - script: |- - python ./citest/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard + python3 ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard Repo.Checker: environment_variables: @@ -723,7 +663,7 @@ pipelines: - Enable.images.repo: resources: - - staging-bot + - staging-bot3 tasks: - script: |- osc -A $STAGING_API api -X POST "/source/$STAGING_PROJECT?cmd=remove_flag&repository=images&flag=build" @@ -749,21 +689,15 @@ pipelines: destination: scripts whitelist: - DO_NOT_TRIGGER - citest: - git: https://github.com/coolo/citest.git - auto_update: true - destination: citest - whitelist: - - DO_NOT_TRIGGER stages: - Checks: jobs: Check.Build.Succeeds: resources: - - staging-bot + - staging-bot3 tasks: - script: |- - python ./citest/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard + python3 ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard Repo.Checker: environment_variables: @@ -783,7 +717,7 @@ pipelines: - Enable.images.repo: resources: - - staging-bot + - staging-bot3 tasks: - script: |- osc -A $STAGING_API api -X POST "/source/$STAGING_PROJECT?cmd=remove_flag&repository=images&flag=build" @@ -809,21 +743,15 @@ pipelines: destination: scripts whitelist: - DO_NOT_TRIGGER - citest: - git: https://github.com/coolo/citest.git - auto_update: true - destination: citest - whitelist: - - DO_NOT_TRIGGER stages: - Checks: jobs: Check.Build.Succeeds: resources: - - staging-bot + - staging-bot3 tasks: - script: |- - python ./citest/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard + python3 ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard Repo.Checker: environment_variables: @@ -843,7 +771,7 @@ pipelines: - Enable.images.repo: resources: - - staging-bot + - staging-bot3 tasks: - script: |- osc -A $STAGING_API api -X POST "/source/$STAGING_PROJECT?cmd=remove_flag&repository=images&flag=build" @@ -869,21 +797,15 @@ pipelines: destination: scripts whitelist: - DO_NOT_TRIGGER - citest: - git: https://github.com/coolo/citest.git - auto_update: true - destination: citest - whitelist: - - DO_NOT_TRIGGER stages: - Checks: jobs: Check.Build.Succeeds: resources: - - staging-bot + - staging-bot3 tasks: - script: |- - python ./citest/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard + python3 ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard Repo.Checker: environment_variables: @@ -903,7 +825,7 @@ pipelines: - Enable.images.repo: resources: - - staging-bot + - staging-bot3 tasks: - script: |- osc -A $STAGING_API api -X POST "/source/$STAGING_PROJECT?cmd=remove_flag&repository=images&flag=build" @@ -929,21 +851,15 @@ pipelines: destination: scripts whitelist: - DO_NOT_TRIGGER - citest: - git: https://github.com/coolo/citest.git - auto_update: true - destination: citest - whitelist: - - DO_NOT_TRIGGER stages: - Checks: jobs: Check.Build.Succeeds: resources: - - staging-bot + - staging-bot3 tasks: - script: |- - python ./citest/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard + python3 ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard Repo.Checker: environment_variables: @@ -963,7 +879,7 @@ pipelines: - Enable.images.repo: resources: - - staging-bot + - staging-bot3 tasks: - script: |- osc -A $STAGING_API api -X POST "/source/$STAGING_PROJECT?cmd=remove_flag&repository=images&flag=build" @@ -989,21 +905,15 @@ pipelines: destination: scripts whitelist: - DO_NOT_TRIGGER - citest: - git: https://github.com/coolo/citest.git - auto_update: true - destination: citest - whitelist: - - DO_NOT_TRIGGER stages: - Checks: jobs: Check.Build.Succeeds: resources: - - staging-bot + - staging-bot3 tasks: - script: |- - python ./citest/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard + python3 ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard Repo.Checker: environment_variables: @@ -1023,7 +933,7 @@ pipelines: - Enable.images.repo: resources: - - staging-bot + - staging-bot3 tasks: - script: |- osc -A $STAGING_API api -X POST "/source/$STAGING_PROJECT?cmd=remove_flag&repository=images&flag=build" @@ -1049,21 +959,15 @@ pipelines: destination: scripts whitelist: - DO_NOT_TRIGGER - citest: - git: https://github.com/coolo/citest.git - auto_update: true - destination: citest - whitelist: - - DO_NOT_TRIGGER stages: - Checks: jobs: Check.Build.Succeeds: resources: - - staging-bot + - staging-bot3 tasks: - script: |- - python ./citest/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard + python3 ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard Repo.Checker: environment_variables: @@ -1083,7 +987,7 @@ pipelines: - Enable.images.repo: resources: - - staging-bot + - staging-bot3 tasks: - script: |- osc -A $STAGING_API api -X POST "/source/$STAGING_PROJECT?cmd=remove_flag&repository=images&flag=build" @@ -1161,21 +1065,15 @@ pipelines: destination: scripts whitelist: - DO_NOT_TRIGGER - citest: - git: https://github.com/coolo/citest.git - auto_update: true - destination: citest - whitelist: - - DO_NOT_TRIGGER stages: - Checks: jobs: Check.Build.Succeeds: resources: - - staging-bot + - staging-bot3 tasks: - script: |- - python ./citest/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard + python3 ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard Repo.Checker: environment_variables: @@ -1213,21 +1111,15 @@ pipelines: destination: scripts whitelist: - DO_NOT_TRIGGER - citest: - git: https://github.com/coolo/citest.git - auto_update: true - destination: citest - whitelist: - - DO_NOT_TRIGGER stages: - Checks: jobs: Check.Build.Succeeds: resources: - - staging-bot + - staging-bot3 tasks: - script: |- - python ./citest/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard + python3 ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard Repo.Checker: environment_variables: @@ -1265,21 +1157,15 @@ pipelines: destination: scripts whitelist: - DO_NOT_TRIGGER - citest: - git: https://github.com/coolo/citest.git - auto_update: true - destination: citest - whitelist: - - DO_NOT_TRIGGER stages: - Checks: jobs: Check.Build.Succeeds: resources: - - staging-bot + - staging-bot3 tasks: - script: |- - python ./citest/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard + python3 ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard Repo.Checker: environment_variables: @@ -1317,21 +1203,15 @@ pipelines: destination: scripts whitelist: - DO_NOT_TRIGGER - citest: - git: https://github.com/coolo/citest.git - auto_update: true - destination: citest - whitelist: - - DO_NOT_TRIGGER stages: - Checks: jobs: Check.Build.Succeeds: resources: - - staging-bot + - staging-bot3 tasks: - script: |- - python ./citest/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard + python3 ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard Repo.Checker: environment_variables: @@ -1369,21 +1249,15 @@ pipelines: destination: scripts whitelist: - DO_NOT_TRIGGER - citest: - git: https://github.com/coolo/citest.git - auto_update: true - destination: citest - whitelist: - - DO_NOT_TRIGGER stages: - Checks: jobs: Check.Build.Succeeds: resources: - - staging-bot + - staging-bot3 tasks: - script: |- - python ./citest/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard + python3 ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard Repo.Checker: environment_variables: diff --git a/gocd/pkglistgen_staging.gocd.yaml.erb b/gocd/pkglistgen_staging.gocd.yaml.erb index f3211ff5..09148ee7 100644 --- a/gocd/pkglistgen_staging.gocd.yaml.erb +++ b/gocd/pkglistgen_staging.gocd.yaml.erb @@ -47,21 +47,15 @@ pipelines: destination: scripts whitelist: - DO_NOT_TRIGGER - citest: - git: https://github.com/coolo/citest.git - auto_update: true - destination: citest - whitelist: - - DO_NOT_TRIGGER stages: - Checks: jobs: Check.Build.Succeeds: resources: - - staging-bot + - staging-bot3 tasks: - script: |- - python ./citest/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard + python3 ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard Repo.Checker: environment_variables: @@ -81,7 +75,7 @@ pipelines: - Enable.images.repo: resources: - - staging-bot + - staging-bot3 tasks: - script: |- osc -A $STAGING_API api -X POST "/source/$STAGING_PROJECT?cmd=remove_flag&repository=images&flag=build" @@ -134,21 +128,15 @@ pipelines: destination: scripts whitelist: - DO_NOT_TRIGGER - citest: - git: https://github.com/coolo/citest.git - auto_update: true - destination: citest - whitelist: - - DO_NOT_TRIGGER stages: - Checks: jobs: Check.Build.Succeeds: resources: - - staging-bot + - staging-bot3 tasks: - script: |- - python ./citest/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard + python3 ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r standard Repo.Checker: environment_variables: diff --git a/gocd/verify-repo-built-successful.py b/gocd/verify-repo-built-successful.py new file mode 100755 index 00000000..9306d023 --- /dev/null +++ b/gocd/verify-repo-built-successful.py @@ -0,0 +1,51 @@ +#!/usr/bin/python3 + +from __future__ import print_function + +import argparse +import logging +import sys + +import osc +from osc.core import http_GET, makeurl + +from osclib.core import target_archs +from lxml import etree as ET + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Check if all packages built fine') + parser.add_argument('--apiurl', '-A', type=str, help='API URL of OBS') + parser.add_argument('-p', '--project', type=str, help='Project to check') + parser.add_argument('-r', '--repository', type=str, + help='Repository to check') + + args = parser.parse_args() + + osc.conf.get_config(override_apiurl=args.apiurl) + apiurl = osc.conf.config['apiurl'] + + logging.basicConfig(level=logging.DEBUG) + logger = logging.getLogger(__name__) + + # first check if repo is finished + archs = target_archs(apiurl, args.project, args.repository) + for arch in archs: + url = makeurl(apiurl, ['build', args.project, args.repository, arch], {'view': 'status'}) + root = ET.parse(http_GET(url)).getroot() + if root.get('code') == 'finished': + continue + logger.error('Repository {}/{}/{} is not yet finished'.format(args.project, args.repository, arch)) + logger.debug(ET.tostring(root)) + sys.exit(1) + + # now check if all packages built fine + url = makeurl(apiurl, ['build', args.project, '_result'], + {'view': 'summary', 'repository': args.repository}) + root = ET.parse(http_GET(url)).getroot() + for count in root.findall('.//statuscount'): + if int(count.get('count', 0)) == 0: + continue + if count.get('code') in ['succeeded', 'excluded', 'disabled']: + continue + logger.error('Repository {}/{} is has {} packages'.format(args.project, args.repository, count.get('code'))) + sys.exit(1)