Changeset View
Changeset View
Standalone View
Standalone View
helpers/check-abi.py
Show All 36 Lines | 32 | def candidate(self): | |||
---|---|---|---|---|---|
37 | if not self.candidates: | 37 | if not self.candidates: | ||
38 | return None | 38 | return None | ||
39 | 39 | | |||
40 | # get a list of tagged candidates | 40 | # get a list of tagged candidates | ||
41 | released = list(filter(lambda i: i['scmRevision'] in HASH2TAG, self.candidates)) | 41 | released = list(filter(lambda i: i['scmRevision'] in HASH2TAG, self.candidates)) | ||
42 | if released: | 42 | if released: | ||
43 | # get the first released version, that is available | 43 | # get the first released version, that is available | ||
44 | candidate = min(released, key=lambda i: HASH2TAG[i['scmRevision']]) | 44 | candidate = min(released, key=lambda i: HASH2TAG[i['scmRevision']]) | ||
45 | logging.info("Found tag %s(%s) to check against.", HASH2TAG[candidate['scmRevision']].version, candidate['scmRevision']) | ||||
45 | else: | 46 | else: | ||
46 | #TODO: we may want to return None, as the library was never released so far. | 47 | #TODO: we may want to return None, as the library was never released so far. | ||
47 | 48 | | |||
48 | # get oldest candidate. | 49 | # get oldest candidate. | ||
49 | candidate = min(self.candidates, key=lambda e:e['timestamp']) | 50 | candidate = min(self.candidates, key=lambda e:e['timestamp']) | ||
50 | logging.warning("No released version was found, just use the oldest commit.") | 51 | logging.warning("No released version was found, just use the oldest commit.") | ||
51 | 52 | | |||
52 | # the candidate needs to be older than the current build. | 53 | # the candidate needs to be older than the current build. | ||
Show All 23 Lines | |||||
76 | scmRevision = '' | 77 | scmRevision = '' | ||
77 | if os.getenv('GIT_COMMIT') != '': | 78 | if os.getenv('GIT_COMMIT') != '': | ||
78 | scmRevision = os.getenv('GIT_COMMIT') | 79 | scmRevision = os.getenv('GIT_COMMIT') | ||
79 | 80 | | |||
80 | if not scmRevision: | 81 | if not scmRevision: | ||
81 | scmRevision = subprocess.check_output(["git", "log", "--format=%H", "-n 1", "HEAD"]).strip().decode() | 82 | scmRevision = subprocess.check_output(["git", "log", "--format=%H", "-n 1", "HEAD"]).strip().decode() | ||
82 | 83 | | |||
83 | # get all tags that are in the current commit | 84 | # get all tags that are in the current commit | ||
84 | tags = subprocess.check_output(["git", "tag", "--contains", scmRevision]).strip().decode().splitlines() | 85 | tags = subprocess.check_output(["git", "tag", "--merged", scmRevision]).strip().decode().splitlines() | ||
86 | | ||||
87 | # we are not interessed in the commit for annotatated tags itself, we want to know what commit was tagged. | ||||
88 | commitedTags = [i+"^{}" for i in tags] | ||||
bcooksley: Can we use a more descriptive variable name here please?
There are other parts of the codebase… | |||||
85 | 89 | | |||
86 | # resolve tags -> git hashes | 90 | # resolve tags -> git hashes | ||
87 | taghashes = subprocess.check_output(["git", "rev-parse", *tags]).strip().decode().splitlines() | 91 | tagHashes = subprocess.check_output(["git", "rev-parse", *commitedTags]).strip().decode().splitlines() | ||
88 | HASH2TAG = {taghashes[pos]:Version(tag) for pos, tag in enumerate(tags)} | 92 | HASH2TAG = {tagHashes[pos]:Version(tag) for pos, tag in enumerate(tags)} | ||
89 | 93 | | |||
90 | # Do we want to check for newer SONAMEs on other buildGroups | 94 | # Do we want to check for newer SONAMEs on other buildGroups | ||
91 | keepBuildGroup = False | 95 | keepBuildGroup = False | ||
92 | if arguments.branchGroup != "kf5-qt5": | 96 | if arguments.branchGroup != "kf5-qt5": | ||
93 | keepBuildGroup = True | 97 | keepBuildGroup = True | ||
94 | 98 | | |||
95 | # Find all libraries, that are build with the same git commit | 99 | # Find all libraries, that are build with the same git commit | ||
96 | libraries = [] | 100 | libraries = [] | ||
Show All 34 Lines | |||||
131 | 135 | | |||
132 | # Check every libraries ABI and do not fail, if one is not fine. | 136 | # Check every libraries ABI and do not fail, if one is not fine. | ||
133 | # Safe the overall retval state | 137 | # Safe the overall retval state | ||
134 | retval = 0 | 138 | retval = 0 | ||
135 | 139 | | |||
136 | for l in libraries: | 140 | for l in libraries: | ||
137 | library = l.library | 141 | library = l.library | ||
138 | libname = library['libname'] | 142 | libname = library['libname'] | ||
143 | logging.info("Do an ABI check for %s", libname) | ||||
139 | candidate = l.candidate() | 144 | candidate = l.candidate() | ||
140 | if not candidate: | 145 | if not candidate: | ||
141 | logging.info("Did not found any older build for %s, nothing to check ABI against.",libname) | 146 | logging.info("Did not found any older build for %s, nothing to check ABI against.",libname) | ||
142 | continue | 147 | continue | ||
143 | 148 | | |||
144 | # get the packages, we want to test against each other | 149 | # get the packages, we want to test against each other | ||
145 | newLibraryPath, _ = ourArchive.retrievePackage(l.packageName) | 150 | newLibraryPath, _ = ourArchive.retrievePackage(l.packageName) | ||
146 | oldLibraryPath, _ = ourArchive.retrievePackage(candidate['packageName']) | 151 | oldLibraryPath, _ = ourArchive.retrievePackage(candidate['packageName']) | ||
147 | 152 | | |||
148 | logging.info("Let's do a ABI check %s against %s", library['scmRevision'], candidate['scmRevision']) | 153 | logging.info("check %s(old) -> %s(new)", candidate['scmRevision'], library['scmRevision']) | ||
149 | 154 | | |||
150 | # check ABI and write compat reports | 155 | # check ABI and write compat reports | ||
151 | cmd = ["abi-compliance-checker", | 156 | cmd = ["abi-compliance-checker", | ||
152 | "-report-path", "compat_reports/{libname}_compat_report.html".format(libname=libname), | 157 | "-report-path", "compat_reports/{libname}_compat_report.html".format(libname=libname), | ||
153 | "-l", libname, | 158 | "-l", libname, | ||
154 | "--old", oldLibraryPath, | 159 | "--old", oldLibraryPath, | ||
155 | "--new", newLibraryPath] | 160 | "--new", newLibraryPath] | ||
156 | ret = subprocess.call(cmd) | 161 | ret = subprocess.call(cmd) | ||
157 | 162 | | |||
158 | if ret != 0: | 163 | if ret != 0: | ||
159 | logging.error("abi-compliance-checker exited with %s", ret) | 164 | logging.error("abi-compliance-checker exited with %s", ret) | ||
160 | retval = ret | 165 | retval = ret | ||
161 | 166 | | |||
162 | # We had an issue with one of the ABIs | 167 | # We had an issue with one of the ABIs | ||
163 | if retval != 0: | 168 | if retval != 0: | ||
164 | sys.exit(retval) | 169 | sys.exit(retval) |
Can we use a more descriptive variable name here please?
There are other parts of the codebase which have used _ as a function.