Changeset View
Changeset View
Standalone View
Standalone View
helpers/check-abi.py
Show All 15 Lines | |||||
16 | import subprocess | 16 | import subprocess | ||
17 | import sys | 17 | import sys | ||
18 | 18 | | |||
19 | from helperslib import Packages | 19 | from helperslib import Packages | ||
20 | from helperslib.Version import Version | 20 | from helperslib.Version import Version | ||
21 | 21 | | |||
22 | class Library: | 22 | class Library: | ||
23 | def __init__(self, packageName, library): | 23 | def __init__(self, packageName, library): | ||
24 | self.packgeName = packageName | 24 | self.packageName = packageName | ||
25 | self.library = library | 25 | self.library = library | ||
26 | self.candidates = [] | 26 | self.candidates = [] | ||
27 | 27 | | |||
28 | def addCandidate(self, key, entry): | 28 | def addCandidate(self, key, entry): | ||
29 | entry['packageName'] = key | 29 | entry['packageName'] = key | ||
30 | self.candidates.append(entry) | 30 | self.candidates.append(entry) | ||
31 | 31 | | |||
32 | def candidate(self): | 32 | def candidate(self): | ||
Show All 12 Lines | |||||
45 | else: | 45 | else: | ||
46 | #TODO: we may want to return None, as the library was never released so far. | 46 | #TODO: we may want to return None, as the library was never released so far. | ||
47 | 47 | | |||
48 | # get oldest candidate. | 48 | # get oldest candidate. | ||
49 | candidate = min(self.candidates, key=lambda e:e['timestamp']) | 49 | candidate = min(self.candidates, key=lambda e:e['timestamp']) | ||
50 | logging.warning("No released version was found, just use the oldest commit.") | 50 | logging.warning("No released version was found, just use the oldest commit.") | ||
51 | 51 | | |||
52 | # the candidate needs to be older than the current build. | 52 | # the candidate needs to be older than the current build. | ||
53 | if timestamp > candidate['timestamp']: | 53 | if timestamp < candidate['timestamp']: | ||
54 | return None | 54 | return None | ||
55 | 55 | | |||
56 | return candidate | 56 | return candidate | ||
57 | 57 | | |||
58 | 58 | | |||
59 | # Make sure logging is ready to go | 59 | # Make sure logging is ready to go | ||
60 | logging.basicConfig(level=logging.DEBUG) | 60 | logging.basicConfig(level=logging.DEBUG) | ||
61 | 61 | | |||
Show All 30 Lines | |||||
92 | if arguments.branchGroup != "kf5-qt5": | 92 | if arguments.branchGroup != "kf5-qt5": | ||
93 | keepBuildGroup = True | 93 | keepBuildGroup = True | ||
94 | 94 | | |||
95 | # Find all libraries, that are build with the same git commit | 95 | # Find all libraries, that are build with the same git commit | ||
96 | libraries = [] | 96 | libraries = [] | ||
97 | 97 | | |||
98 | for key, entry in ourArchive.serverManifest.items(): | 98 | for key, entry in ourArchive.serverManifest.items(): | ||
99 | try: | 99 | try: | ||
100 | if entry['platform'] != arguments.platform: | ||||
101 | continue | ||||
102 | if entry["branchGroup"] != arguments.branchGroup: | ||||
103 | continue | ||||
100 | if entry["project"] == arguments.project and entry["scmRevision"] == scmRevision: | 104 | if entry["project"] == arguments.project and entry["scmRevision"] == scmRevision: | ||
101 | libraries.append(Library(key,entry)) | 105 | libraries.append(Library(key,entry)) | ||
102 | except KeyError: | 106 | except KeyError: | ||
103 | continue | 107 | continue | ||
104 | 108 | | |||
105 | # Find all availabe reference dumps | 109 | # Find all availabe reference dumps | ||
106 | # * same libname | 110 | # * same libname | ||
107 | # * same SONAME otherwise we have a ABI bump and than it is safe to break ABI | 111 | # * same SONAME otherwise we have a ABI bump and than it is safe to break ABI | ||
Show All 10 Lines | 116 | for key, entry in ourArchive.serverManifest.items(): | |||
118 | if entry["libname"] == libname: | 122 | if entry["libname"] == libname: | ||
119 | # only interested, for builds with the same SONAME | 123 | # only interested, for builds with the same SONAME | ||
120 | if entry['SONAME'] == soname: | 124 | if entry['SONAME'] == soname: | ||
121 | l.addCandidate(key, entry) | 125 | l.addCandidate(key, entry) | ||
122 | elif entry['SONAME'] > soname: | 126 | elif entry['SONAME'] > soname: | ||
123 | # Ignore new SONAMEs on other branchGroups. | 127 | # Ignore new SONAMEs on other branchGroups. | ||
124 | if keepBuildGroup and entry["branchGroup"] != arguments.branchGroup: | 128 | if keepBuildGroup and entry["branchGroup"] != arguments.branchGroup: | ||
125 | continue | 129 | continue | ||
126 | logging.warning("We searched for SONAME = {}, but found a newer SONAME = {} in the builds, that should not happen, as SONAMEs should only rise and never go lower!".format(soname, entry['SONAME'])) | 130 | logging.warning("We searched for SONAME = %s, but found a newer SONAME = %s in the builds, that should not happen, as SONAMEs should only rise and never go lower!", soname, entry['SONAME']) | ||
127 | 131 | | |||
128 | # Check every libraries ABI and do not fail, if one is not fine. | 132 | # Check every libraries ABI and do not fail, if one is not fine. | ||
129 | # Safe the overall retval state | 133 | # Safe the overall retval state | ||
130 | retval = 0 | 134 | retval = 0 | ||
131 | 135 | | |||
132 | for l in libraries: | 136 | for l in libraries: | ||
133 | library = l.library | 137 | library = l.library | ||
134 | libname = library['libname'] | 138 | libname = library['libname'] | ||
135 | candidate = l.candidate() | 139 | candidate = l.candidate() | ||
136 | if not candidate: | 140 | if not candidate: | ||
137 | logging.info("Did not found any older build for {}, nothing to check ABI against.",libname) | 141 | logging.info("Did not found any older build for %s, nothing to check ABI against.",libname) | ||
138 | continue | 142 | continue | ||
139 | 143 | | |||
140 | # get the packages, we want to test against each other | 144 | # get the packages, we want to test against each other | ||
141 | newLibraryPath, _ = ourArchive.retrievePackage(l.packageName) | 145 | newLibraryPath, _ = ourArchive.retrievePackage(l.packageName) | ||
142 | oldLibraryPath, _ = ourArchive.retrievePackage(candidate['packageName']) | 146 | oldLibraryPath, _ = ourArchive.retrievePackage(candidate['packageName']) | ||
143 | 147 | | |||
144 | logging.info("Let's do a ABI check {} against {}", library['scmRevision'], candidate['scmRevision']) | 148 | logging.info("Let's do a ABI check %s against %s", library['scmRevision'], candidate['scmRevision']) | ||
145 | 149 | | |||
146 | # check ABI and write compat reports | 150 | # check ABI and write compat reports | ||
147 | cmd = ["abi-compliance-checker", | 151 | cmd = ["abi-compliance-checker", | ||
148 | "-report-path", "$WORKSPACE/compat_reports/{libname}_compat_report.html".format(libname=libname), | 152 | "-report-path", "$WORKSPACE/compat_reports/{libname}_compat_report.html".format(libname=libname), | ||
149 | "-l", libname, | 153 | "-l", libname, | ||
150 | "--old", oldLibraryPath, | 154 | "--old", oldLibraryPath, | ||
151 | "--new", newLibraryPath] | 155 | "--new", newLibraryPath] | ||
152 | ret = subprocess.call(cmd) | 156 | ret = subprocess.call(cmd) | ||
153 | 157 | | |||
154 | if ret != 0: | 158 | if ret != 0: | ||
155 | logging.error("abi-compliance-checker exited with {ret}", ret=ret) | 159 | logging.error("abi-compliance-checker exited with %s", ret) | ||
156 | retval = ret | 160 | retval = ret | ||
157 | 161 | | |||
158 | # We had an issue with one of the ABIs | 162 | # We had an issue with one of the ABIs | ||
159 | if retval != 0: | 163 | if retval != 0: | ||
160 | sys.exit(retval) | 164 | sys.exit(retval) |