From 223f7a3da37b982c43eaf2da401ec66b2e6be644 Mon Sep 17 00:00:00 2001 From: palubaj Date: Mon, 18 Dec 2023 12:20:45 +0100 Subject: [PATCH] gcts: add command to run AUNIT for GCTS repo This is work in progress. I took an inspiration from the jenkins-library project, more precisely from the `gctsExecuteAbapQualityChecks`. See: https://github.com/SAP/jenkins-library/blob/master/cmd/gctsExecuteABAPQualityChecks.go --- sap/cli/gcts.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/sap/cli/gcts.py b/sap/cli/gcts.py index 6962f2ff..c8e9082c 100644 --- a/sap/cli/gcts.py +++ b/sap/cli/gcts.py @@ -358,6 +358,40 @@ def install_parser(self, arg_parser): self.branch_grp.install_parser(branch_parser) +@RepoCommandGroup.argument('package') +@RepoCommandGroup.command('run-aunit') +def run_aunit(connection, args): + """Run AUNIT for GCTS repository""" + + adt_connection = connection.get_adt_connection() + repo = get_repository(connection, args.package) + objects = repo.list_objects() + # remove object type DEVC, because it is already included in scope packages + # also if you run ATC Checks for DEVC together with other object types, ATC checks will run only for DEVC + # SUSH is removed because this type is not supported yet + objects = [obj for obj in objects if obj['type'] != 'DEVC' and obj['type'] != 'SUSH'] + objfactory = sap.adt.object_factory.ADTObjectFactory(adt_connection) + + sets = sap.adt.objects.ADTObjectSets() + + for obj in objects: + objname = obj['object'] + objtype = obj['type'] + try: + sets.include(objfactory.make(objtype, objname)) + except SAPCliError as ex: + sap.cli.core.printerr(str(ex)) + return 1 + + aunit = sap.adt.AUnit(adt_connection) + aunit_response = aunit.execute(sets) + if aunit_response.status_code != 200: + print('AUNIT fail:', aunit_response.text) + return 1 + + return 0 + + @RepoCommandGroup.argument('url') @RepoCommandGroup.argument('package') @RepoCommandGroup.command('set-url')