Merge ~fourdollars/pc-enablement/+git/oem-scripts:master into ~oem-solutions-engineers/pc-enablement/+git/oem-scripts:master

Proposed by Shih-Yuan Lee
Status: Merged
Approved by: Bin Li
Approved revision: fe9395e87373c5d266cf873fb26eefedabd8242c
Merged at revision: 59b79f6d5626be954044a2460b338e0a9c77ab14
Proposed branch: ~fourdollars/pc-enablement/+git/oem-scripts:master
Merge into: ~oem-solutions-engineers/pc-enablement/+git/oem-scripts:master
Diff against target: 323 lines (+76/-94)
4 files modified
bootstrap-meta (+2/-3)
debian/tests/mir-bug (+2/-2)
mir-bug (+72/-87)
oem_scripts/__init__.py (+0/-2)
Reviewer Review Type Date Requested Status
Bin Li Approve
Review via email: mp+446617@code.launchpad.net
To post a comment you must log in.
Revision history for this message
OEM Taipei Bot (oem-taipei-bot) wrote :

[autopkgtest]
pkg-iot-meta PASS
pkg-somerville-meta PASS
pkg-stella-meta PASS
pkg-sutton-meta PASS
bug-bind PASS
get-private-ppa PASS
lp-api PASS
lp-bug PASS
pkg-list PASS
review-merge-proposal PASS
run-autopkgtest PASS
setup-apt-dir PASS
bootstrap-meta PASS
mir-bug PASS
oem-meta-packages PASS
git-url-insteadof-setting PASS
lp-dl-attm PASS
recovery-from-iso.sh PASS

https://oem-share.canonical.com/partners/lyoncore/share/artifacts/oem-scripts/oem-scripts-1.83-fe9395e-in-linux-container-jammy

Revision history for this message
Bin Li (binli) wrote :

LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/bootstrap-meta b/bootstrap-meta
2index c523795..77a15c3 100755
3--- a/bootstrap-meta
4+++ b/bootstrap-meta
5@@ -31,7 +31,6 @@ from copy import copy
6 from logging import info, warning, error, critical
7 from oem_scripts import (
8 ALLOWED_KERNEL_META_LIST,
9- SUBSCRIBER_LIST,
10 TAG_LIST,
11 _get_items_from_git,
12 _run_command,
13@@ -295,8 +294,8 @@ class BootstrapMetaSRU(BootstrapMeta):
14
15 subscriptions = list(map(lambda x: x.person.name, bug.subscriptions))
16 tags = copy(bug.tags)
17- if ready or release:
18- for subscriber in SUBSCRIBER_LIST:
19+ if ready and release:
20+ for subscriber in ("oem-solutions-engineers", "ubuntu-sponsors"):
21 if subscriber not in subscriptions:
22 bug.subscribe(person=lp.people[subscriber])
23 if "oem-solutions-engineers" not in subscriptions:
24diff --git a/debian/tests/mir-bug b/debian/tests/mir-bug
25index 94610c8..9f880d8 100644
26--- a/debian/tests/mir-bug
27+++ b/debian/tests/mir-bug
28@@ -67,7 +67,7 @@ mir-bug update --yes --skip "$AUTOPKGTEST_ARTIFACTS"/jellyfish-tentacool.json
29 payload=$(lp-api get bugs/"$BUG_ID")
30 for link in $(lp-api .subscriptions_collection_link <<< "$payload" | jq -r '.entries|.[]|.self_link'); do
31 case "$(basename "$link")" in
32- (ubuntu-sponsors|ubuntu-desktop)
33+ (ubuntu-sponsors|ubuntu-desktop|ubuntu-archive)
34 echo "FAIL: '$link' shall not be subscribed by 'mir-bug update --yes --skip'."
35 ERR=1
36 ;;
37@@ -77,7 +77,7 @@ mir-bug update --yes --skip --ready "$AUTOPKGTEST_ARTIFACTS"/jellyfish-tentacool
38 payload=$(lp-api get bugs/"$BUG_ID")
39 for link in $(lp-api .subscriptions_collection_link <<< "$payload" | jq -r '.entries|.[]|.self_link'); do
40 case "$(basename "$link")" in
41- (ubuntu-sponsors|ubuntu-desktop)
42+ (ubuntu-sponsors|ubuntu-desktop|ubuntu-archive)
43 echo "FAIL: '$link' shall not be subscribed by 'mir-bug update --yes --skip --ready'."
44 ERR=1
45 ;;
46diff --git a/mir-bug b/mir-bug
47index 6049d74..6f85169 100755
48--- a/mir-bug
49+++ b/mir-bug
50@@ -37,7 +37,6 @@ from distro_info import UbuntuDistroInfo
51 from glob import glob
52 from logging import debug, info, warning, error, critical
53 from oem_scripts import (
54- SUBSCRIBER_LIST,
55 TAG_LIST,
56 _get_items_from_git,
57 _run_command,
58@@ -115,7 +114,7 @@ update.add_argument(
59 update.add_argument(
60 "--release",
61 action="store_true",
62- help="Also affects 'Ubuntu', and subscribe 'ubuntu-sponsors'.",
63+ help="Also affects 'Ubuntu', and subscribe 'ubuntu-archive'.",
64 )
65
66 check = subparsers.add_parser(
67@@ -141,10 +140,12 @@ check.add_argument(
68 check.add_argument(
69 "--ready",
70 action="store_true",
71- help="Check if the bug is Fix Committed, also affects 'Ubuntu', and subscribe 'ubuntu-sponsors' and 'ubuntu-desktop'.",
72+ help="Check if the oem-priority bug is Fix Committed, and doesn't also affect 'Ubuntu', and doesn't subscribe 'ubuntu-archive', 'ubuntu-sponsors' and 'ubuntu-desktop'.",
73 )
74 check.add_argument(
75- "--release", action="store_true", help="Check if the bug is ready to release."
76+ "--release",
77+ action="store_true",
78+ help="Check if the bug is ready to release and subscribed 'ubuntu-archive'.",
79 )
80
81 collect = subparsers.add_parser("collect", help="[-h] [--ubuntu-certified] jsonFile")
82@@ -411,7 +412,7 @@ def update_bug(
83 task.importance = "Critical"
84 task.lp_save()
85
86- update_bug_status(bug, pkg_name, yes, series)
87+ check_and_update_bug_status(bug, pkg_name, series, yes=yes, update=True)
88
89 check_and_update_bug_subscriptions(lp, bug, update=True, yes=yes)
90
91@@ -475,7 +476,7 @@ def check_bug(
92 need_fixing = True
93 if check_bug_importance(bug) is False:
94 need_fixing = True
95- if check_bug_status(bug, pkg_name, series) is False:
96+ if check_and_update_bug_status(bug, pkg_name, series, update=False) is False:
97 need_fixing = True
98 if check_and_update_bug_subscriptions(lp, bug) is False:
99 need_fixing = True
100@@ -598,97 +599,61 @@ def check_bug_importance(bug) -> bool:
101 return result
102
103
104-def _expected_status(target_name: str, status: str, expected: str) -> bool:
105- if status != expected:
106+def _expected_task_status(bug_task, expected_status: str) -> bool:
107+ if bug_task.status != expected_status:
108 error(
109- f"The '{target_name}' status is expected to be '{expected}' instead of '{status}'."
110+ f"The '{bug_task.bug_target_name}' status is expected to be '{expected_status}' instead of '{bug_task.status}'."
111 )
112 return False
113 return True
114
115
116-def check_bug_status(bug, pkg_name: str, series: str) -> bool:
117- info("Checking bug status...")
118- result = True
119- saw_ubuntu_task = False
120- for task in bug.bug_tasks:
121- if task.bug_target_name == "oem-priority":
122- if args.ready:
123- if (
124- _expected_status(task.bug_target_name, task.status, "Fix Committed")
125- is False
126- ):
127- result = False
128- else:
129- if (
130- _expected_status(task.bug_target_name, task.status, "In Progress")
131- is False
132- ):
133- result = False
134- elif (
135- task.bug_target_name == "ubuntu"
136- or f"{pkg_name} (Ubuntu)" in task.bug_target_name
137- or f"{pkg_name} (Ubuntu {series.capitalize()})" in task.bug_target_name
138- ):
139- saw_ubuntu_task = True
140- if args.release:
141- if (
142- _expected_status(task.bug_target_name, task.status, "In Progress")
143- is False
144- ):
145- result = False
146- elif args.ready:
147- if (
148- _expected_status(task.bug_target_name, task.status, "Confirmed")
149- is False
150- ):
151- result = False
152- else:
153- if (
154- _expected_status(task.bug_target_name, task.status, "Incomplete")
155- is False
156- ):
157- result = False
158- else:
159- critical(f"It is unexpected to have '{task.bug_target_name}' task")
160- if args.ready and saw_ubuntu_task is False:
161- result = False
162- error("There is no 'ubuntu' status.")
163- return result
164-
165-
166-def _ok_to_change_status(
167- target_name: str, orig_status: str, new_status: str, yes: bool
168-) -> bool:
169- if orig_status == new_status:
170+def _ok_to_change_task_status(bug_task, new_status: str, yes: bool) -> bool:
171+ if bug_task.status == new_status:
172 return False
173 if yes_or_ask(
174 yes,
175- f"Would you like to change the '{target_name}' status from '{orig_status}' to '{new_status}'?",
176+ f"Would you like to change the '{bug_task.bug_target_name}' status from '{bug_task.status}' to '{new_status}'?",
177 ):
178 return True
179 return False
180
181
182-def _change_task_status(task, new_status: str, yes: bool) -> bool:
183- if _expected_status(
184- task.bug_target_name, task.status, new_status
185- ) is False and _ok_to_change_status(
186- task.bug_target_name, task.status, new_status, yes
187- ):
188- task.status = new_status
189- task.lp_save()
190+def _check_and_change_task_status(
191+ task, new_status: str, yes=False, update=False
192+) -> bool:
193+ if update:
194+ if not _expected_task_status(task, new_status) and _ok_to_change_task_status(
195+ task, new_status, yes
196+ ):
197+ task.status = new_status
198+ task.lp_save()
199+ return True
200+ else:
201+ return _expected_task_status(task, new_status)
202
203
204-def update_bug_status(bug, pkg_name: str, yes: bool, series: str) -> None:
205- info("Updating bug status...")
206+def check_and_update_bug_status(
207+ bug, pkg_name: str, series: str, yes=False, update=False
208+) -> None:
209+ if update:
210+ info("Updating bug status...")
211+ else:
212+ info("Checking bug status...")
213+ result = True
214 saw_ubuntu_task = False
215 for bug_task in bug.bug_tasks:
216 if bug_task.bug_target_name == "oem-priority":
217 if args.ready:
218- _change_task_status(bug_task, "Fix Committed", yes)
219+ if not _check_and_change_task_status(
220+ bug_task, "Fix Committed", yes=yes, update=update
221+ ):
222+ result = False
223 else:
224- _change_task_status(bug_task, "In Progress", yes)
225+ if not _check_and_change_task_status(
226+ bug_task, "In Progress", yes=yes, update=update
227+ ):
228+ result = False
229 elif (
230 bug_task.bug_target_name == "ubuntu"
231 or f"{pkg_name} (Ubuntu)" in bug_task.bug_target_name
232@@ -696,10 +661,16 @@ def update_bug_status(bug, pkg_name: str, yes: bool, series: str) -> None:
233 ):
234 saw_ubuntu_task = True
235 if args.release:
236- _change_task_status(bug_task, "In Progress", yes)
237+ if not _check_and_change_task_status(
238+ bug_task, "In Progress", yes=yes, update=update
239+ ):
240+ result = False
241 elif args.ready:
242- _change_task_status(bug_task, "Confirmed", yes)
243- elif yes_or_ask(
244+ if not _check_and_change_task_status(
245+ bug_task, "Confirmed", yes=yes, update=update
246+ ):
247+ result = False
248+ elif update and yes_or_ask(
249 yes,
250 f"Would you like to delete the '{bug_task.bug_target_name}' bug_task? (Don't affect '{bug_task.bug_target_display_name}')",
251 ):
252@@ -710,22 +681,36 @@ def update_bug_status(bug, pkg_name: str, yes: bool, series: str) -> None:
253 f"{bug_task.bug_target_name} can not be deleted, so changing the status to Incomplete instead."
254 )
255 debug(e)
256- _change_task_status(bug_task, "Incomplete", yes)
257+ _check_and_change_task_status(
258+ bug_task, "Incomplete", yes=yes, update=update
259+ )
260 except lazr.restfulclient.errors.Unauthorized as e:
261 warning(
262 f"{bug_task.bug_target_name} can not be deleted, so changing the status to Incomplete instead."
263 )
264 debug(e)
265- _change_task_status(bug_task, "Incomplete", yes)
266+ _check_and_change_task_status(
267+ bug_task, "Incomplete", yes=yes, update=update
268+ )
269 else:
270- _change_task_status(bug_task, "Incomplete", yes)
271+ if not _check_and_change_task_status(
272+ bug_task, "Incomplete", yes=yes, update=update
273+ ):
274+ result = False
275 else:
276- warning(f"{bug_task.bug_target_name} {bug_task.status}")
277- if args.release and args.ready and saw_ubuntu_task is False:
278+ warning(
279+ f"It is unexpected to see the '{bug_task.bug_target_name}' task and the '{bug_task.status}' status."
280+ )
281+ if update and args.release and args.ready and saw_ubuntu_task is False:
282 bug.addTask(target=lp.projects["Ubuntu"])
283 for bug_task in bug.bug_tasks:
284 if bug_task.bug_target_name == "ubuntu":
285- _change_task_status(bug_task, "In Progress", yes)
286+ _check_and_change_task_status(
287+ bug_task, "In Progress", yes=True, update=True
288+ )
289+ if not update and not args.release and not args.ready and saw_ubuntu_task:
290+ result = False
291+ return result
292
293
294 def check_and_update_bug_subscriptions(lp, bug, update=False, yes=False) -> bool:
295@@ -738,7 +723,7 @@ def check_and_update_bug_subscriptions(lp, bug, update=False, yes=False) -> bool
296 for subscription in bug.subscriptions:
297 subscriptions.append(subscription.person.name)
298 if not args.ready or not args.release:
299- for subscriber in ("ubuntu-sponsors", "ubuntu-desktop"):
300+ for subscriber in ("ubuntu-archive", "ubuntu-sponsors", "ubuntu-desktop"):
301 if subscriber == subscription.person.name:
302 if subscription.canBeUnsubscribedByUser():
303 error(f"'{subscriber}' should not be in the subscriptions.")
304@@ -753,7 +738,7 @@ def check_and_update_bug_subscriptions(lp, bug, update=False, yes=False) -> bool
305 f"'{subscriber}' should not be in the subscriptions, and {lp.me.name} doesn't have the permission to unsubscribe it."
306 )
307 if args.ready and args.release:
308- for subscriber in SUBSCRIBER_LIST:
309+ for subscriber in ("oem-solutions-engineers", "ubuntu-archive"):
310 if subscriber not in subscriptions:
311 error(f"'{subscriber}' is not in the subscriptions.")
312 if update and yes_or_ask(
313diff --git a/oem_scripts/__init__.py b/oem_scripts/__init__.py
314index a3aaceb..c8a6ffe 100644
315--- a/oem_scripts/__init__.py
316+++ b/oem_scripts/__init__.py
317@@ -41,8 +41,6 @@ ALLOWED_KERNEL_META_LIST = (
318 "linux-generic",
319 )
320
321-SUBSCRIBER_LIST = ("oem-solutions-engineers", "ubuntu-sponsors", "ubuntu-desktop")
322-
323 TAG_LIST = ["oem-meta-packages", "oem-priority", f"oem-scripts-{__version__}"]
324
325

Subscribers

People subscribed via source and target branches