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
diff --git a/bootstrap-meta b/bootstrap-meta
index c523795..77a15c3 100755
--- a/bootstrap-meta
+++ b/bootstrap-meta
@@ -31,7 +31,6 @@ from copy import copy
31from logging import info, warning, error, critical31from logging import info, warning, error, critical
32from oem_scripts import (32from oem_scripts import (
33 ALLOWED_KERNEL_META_LIST,33 ALLOWED_KERNEL_META_LIST,
34 SUBSCRIBER_LIST,
35 TAG_LIST,34 TAG_LIST,
36 _get_items_from_git,35 _get_items_from_git,
37 _run_command,36 _run_command,
@@ -295,8 +294,8 @@ class BootstrapMetaSRU(BootstrapMeta):
295294
296 subscriptions = list(map(lambda x: x.person.name, bug.subscriptions))295 subscriptions = list(map(lambda x: x.person.name, bug.subscriptions))
297 tags = copy(bug.tags)296 tags = copy(bug.tags)
298 if ready or release:297 if ready and release:
299 for subscriber in SUBSCRIBER_LIST:298 for subscriber in ("oem-solutions-engineers", "ubuntu-sponsors"):
300 if subscriber not in subscriptions:299 if subscriber not in subscriptions:
301 bug.subscribe(person=lp.people[subscriber])300 bug.subscribe(person=lp.people[subscriber])
302 if "oem-solutions-engineers" not in subscriptions:301 if "oem-solutions-engineers" not in subscriptions:
diff --git a/debian/tests/mir-bug b/debian/tests/mir-bug
index 94610c8..9f880d8 100644
--- a/debian/tests/mir-bug
+++ b/debian/tests/mir-bug
@@ -67,7 +67,7 @@ mir-bug update --yes --skip "$AUTOPKGTEST_ARTIFACTS"/jellyfish-tentacool.json
67payload=$(lp-api get bugs/"$BUG_ID")67payload=$(lp-api get bugs/"$BUG_ID")
68for link in $(lp-api .subscriptions_collection_link <<< "$payload" | jq -r '.entries|.[]|.self_link'); do68for link in $(lp-api .subscriptions_collection_link <<< "$payload" | jq -r '.entries|.[]|.self_link'); do
69 case "$(basename "$link")" in69 case "$(basename "$link")" in
70 (ubuntu-sponsors|ubuntu-desktop)70 (ubuntu-sponsors|ubuntu-desktop|ubuntu-archive)
71 echo "FAIL: '$link' shall not be subscribed by 'mir-bug update --yes --skip'."71 echo "FAIL: '$link' shall not be subscribed by 'mir-bug update --yes --skip'."
72 ERR=172 ERR=1
73 ;;73 ;;
@@ -77,7 +77,7 @@ mir-bug update --yes --skip --ready "$AUTOPKGTEST_ARTIFACTS"/jellyfish-tentacool
77payload=$(lp-api get bugs/"$BUG_ID")77payload=$(lp-api get bugs/"$BUG_ID")
78for link in $(lp-api .subscriptions_collection_link <<< "$payload" | jq -r '.entries|.[]|.self_link'); do78for link in $(lp-api .subscriptions_collection_link <<< "$payload" | jq -r '.entries|.[]|.self_link'); do
79 case "$(basename "$link")" in79 case "$(basename "$link")" in
80 (ubuntu-sponsors|ubuntu-desktop)80 (ubuntu-sponsors|ubuntu-desktop|ubuntu-archive)
81 echo "FAIL: '$link' shall not be subscribed by 'mir-bug update --yes --skip --ready'."81 echo "FAIL: '$link' shall not be subscribed by 'mir-bug update --yes --skip --ready'."
82 ERR=182 ERR=1
83 ;;83 ;;
diff --git a/mir-bug b/mir-bug
index 6049d74..6f85169 100755
--- a/mir-bug
+++ b/mir-bug
@@ -37,7 +37,6 @@ from distro_info import UbuntuDistroInfo
37from glob import glob37from glob import glob
38from logging import debug, info, warning, error, critical38from logging import debug, info, warning, error, critical
39from oem_scripts import (39from oem_scripts import (
40 SUBSCRIBER_LIST,
41 TAG_LIST,40 TAG_LIST,
42 _get_items_from_git,41 _get_items_from_git,
43 _run_command,42 _run_command,
@@ -115,7 +114,7 @@ update.add_argument(
115update.add_argument(114update.add_argument(
116 "--release",115 "--release",
117 action="store_true",116 action="store_true",
118 help="Also affects 'Ubuntu', and subscribe 'ubuntu-sponsors'.",117 help="Also affects 'Ubuntu', and subscribe 'ubuntu-archive'.",
119)118)
120119
121check = subparsers.add_parser(120check = subparsers.add_parser(
@@ -141,10 +140,12 @@ check.add_argument(
141check.add_argument(140check.add_argument(
142 "--ready",141 "--ready",
143 action="store_true",142 action="store_true",
144 help="Check if the bug is Fix Committed, also affects 'Ubuntu', and subscribe 'ubuntu-sponsors' and 'ubuntu-desktop'.",143 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'.",
145)144)
146check.add_argument(145check.add_argument(
147 "--release", action="store_true", help="Check if the bug is ready to release."146 "--release",
147 action="store_true",
148 help="Check if the bug is ready to release and subscribed 'ubuntu-archive'.",
148)149)
149150
150collect = subparsers.add_parser("collect", help="[-h] [--ubuntu-certified] jsonFile")151collect = subparsers.add_parser("collect", help="[-h] [--ubuntu-certified] jsonFile")
@@ -411,7 +412,7 @@ def update_bug(
411 task.importance = "Critical"412 task.importance = "Critical"
412 task.lp_save()413 task.lp_save()
413414
414 update_bug_status(bug, pkg_name, yes, series)415 check_and_update_bug_status(bug, pkg_name, series, yes=yes, update=True)
415416
416 check_and_update_bug_subscriptions(lp, bug, update=True, yes=yes)417 check_and_update_bug_subscriptions(lp, bug, update=True, yes=yes)
417418
@@ -475,7 +476,7 @@ def check_bug(
475 need_fixing = True476 need_fixing = True
476 if check_bug_importance(bug) is False:477 if check_bug_importance(bug) is False:
477 need_fixing = True478 need_fixing = True
478 if check_bug_status(bug, pkg_name, series) is False:479 if check_and_update_bug_status(bug, pkg_name, series, update=False) is False:
479 need_fixing = True480 need_fixing = True
480 if check_and_update_bug_subscriptions(lp, bug) is False:481 if check_and_update_bug_subscriptions(lp, bug) is False:
481 need_fixing = True482 need_fixing = True
@@ -598,97 +599,61 @@ def check_bug_importance(bug) -> bool:
598 return result599 return result
599600
600601
601def _expected_status(target_name: str, status: str, expected: str) -> bool:602def _expected_task_status(bug_task, expected_status: str) -> bool:
602 if status != expected:603 if bug_task.status != expected_status:
603 error(604 error(
604 f"The '{target_name}' status is expected to be '{expected}' instead of '{status}'."605 f"The '{bug_task.bug_target_name}' status is expected to be '{expected_status}' instead of '{bug_task.status}'."
605 )606 )
606 return False607 return False
607 return True608 return True
608609
609610
610def check_bug_status(bug, pkg_name: str, series: str) -> bool:611def _ok_to_change_task_status(bug_task, new_status: str, yes: bool) -> bool:
611 info("Checking bug status...")612 if bug_task.status == new_status:
612 result = True
613 saw_ubuntu_task = False
614 for task in bug.bug_tasks:
615 if task.bug_target_name == "oem-priority":
616 if args.ready:
617 if (
618 _expected_status(task.bug_target_name, task.status, "Fix Committed")
619 is False
620 ):
621 result = False
622 else:
623 if (
624 _expected_status(task.bug_target_name, task.status, "In Progress")
625 is False
626 ):
627 result = False
628 elif (
629 task.bug_target_name == "ubuntu"
630 or f"{pkg_name} (Ubuntu)" in task.bug_target_name
631 or f"{pkg_name} (Ubuntu {series.capitalize()})" in task.bug_target_name
632 ):
633 saw_ubuntu_task = True
634 if args.release:
635 if (
636 _expected_status(task.bug_target_name, task.status, "In Progress")
637 is False
638 ):
639 result = False
640 elif args.ready:
641 if (
642 _expected_status(task.bug_target_name, task.status, "Confirmed")
643 is False
644 ):
645 result = False
646 else:
647 if (
648 _expected_status(task.bug_target_name, task.status, "Incomplete")
649 is False
650 ):
651 result = False
652 else:
653 critical(f"It is unexpected to have '{task.bug_target_name}' task")
654 if args.ready and saw_ubuntu_task is False:
655 result = False
656 error("There is no 'ubuntu' status.")
657 return result
658
659
660def _ok_to_change_status(
661 target_name: str, orig_status: str, new_status: str, yes: bool
662) -> bool:
663 if orig_status == new_status:
664 return False613 return False
665 if yes_or_ask(614 if yes_or_ask(
666 yes,615 yes,
667 f"Would you like to change the '{target_name}' status from '{orig_status}' to '{new_status}'?",616 f"Would you like to change the '{bug_task.bug_target_name}' status from '{bug_task.status}' to '{new_status}'?",
668 ):617 ):
669 return True618 return True
670 return False619 return False
671620
672621
673def _change_task_status(task, new_status: str, yes: bool) -> bool:622def _check_and_change_task_status(
674 if _expected_status(623 task, new_status: str, yes=False, update=False
675 task.bug_target_name, task.status, new_status624) -> bool:
676 ) is False and _ok_to_change_status(625 if update:
677 task.bug_target_name, task.status, new_status, yes626 if not _expected_task_status(task, new_status) and _ok_to_change_task_status(
678 ):627 task, new_status, yes
679 task.status = new_status628 ):
680 task.lp_save()629 task.status = new_status
630 task.lp_save()
631 return True
632 else:
633 return _expected_task_status(task, new_status)
681634
682635
683def update_bug_status(bug, pkg_name: str, yes: bool, series: str) -> None:636def check_and_update_bug_status(
684 info("Updating bug status...")637 bug, pkg_name: str, series: str, yes=False, update=False
638) -> None:
639 if update:
640 info("Updating bug status...")
641 else:
642 info("Checking bug status...")
643 result = True
685 saw_ubuntu_task = False644 saw_ubuntu_task = False
686 for bug_task in bug.bug_tasks:645 for bug_task in bug.bug_tasks:
687 if bug_task.bug_target_name == "oem-priority":646 if bug_task.bug_target_name == "oem-priority":
688 if args.ready:647 if args.ready:
689 _change_task_status(bug_task, "Fix Committed", yes)648 if not _check_and_change_task_status(
649 bug_task, "Fix Committed", yes=yes, update=update
650 ):
651 result = False
690 else:652 else:
691 _change_task_status(bug_task, "In Progress", yes)653 if not _check_and_change_task_status(
654 bug_task, "In Progress", yes=yes, update=update
655 ):
656 result = False
692 elif (657 elif (
693 bug_task.bug_target_name == "ubuntu"658 bug_task.bug_target_name == "ubuntu"
694 or f"{pkg_name} (Ubuntu)" in bug_task.bug_target_name659 or f"{pkg_name} (Ubuntu)" in bug_task.bug_target_name
@@ -696,10 +661,16 @@ def update_bug_status(bug, pkg_name: str, yes: bool, series: str) -> None:
696 ):661 ):
697 saw_ubuntu_task = True662 saw_ubuntu_task = True
698 if args.release:663 if args.release:
699 _change_task_status(bug_task, "In Progress", yes)664 if not _check_and_change_task_status(
665 bug_task, "In Progress", yes=yes, update=update
666 ):
667 result = False
700 elif args.ready:668 elif args.ready:
701 _change_task_status(bug_task, "Confirmed", yes)669 if not _check_and_change_task_status(
702 elif yes_or_ask(670 bug_task, "Confirmed", yes=yes, update=update
671 ):
672 result = False
673 elif update and yes_or_ask(
703 yes,674 yes,
704 f"Would you like to delete the '{bug_task.bug_target_name}' bug_task? (Don't affect '{bug_task.bug_target_display_name}')",675 f"Would you like to delete the '{bug_task.bug_target_name}' bug_task? (Don't affect '{bug_task.bug_target_display_name}')",
705 ):676 ):
@@ -710,22 +681,36 @@ def update_bug_status(bug, pkg_name: str, yes: bool, series: str) -> None:
710 f"{bug_task.bug_target_name} can not be deleted, so changing the status to Incomplete instead."681 f"{bug_task.bug_target_name} can not be deleted, so changing the status to Incomplete instead."
711 )682 )
712 debug(e)683 debug(e)
713 _change_task_status(bug_task, "Incomplete", yes)684 _check_and_change_task_status(
685 bug_task, "Incomplete", yes=yes, update=update
686 )
714 except lazr.restfulclient.errors.Unauthorized as e:687 except lazr.restfulclient.errors.Unauthorized as e:
715 warning(688 warning(
716 f"{bug_task.bug_target_name} can not be deleted, so changing the status to Incomplete instead."689 f"{bug_task.bug_target_name} can not be deleted, so changing the status to Incomplete instead."
717 )690 )
718 debug(e)691 debug(e)
719 _change_task_status(bug_task, "Incomplete", yes)692 _check_and_change_task_status(
693 bug_task, "Incomplete", yes=yes, update=update
694 )
720 else:695 else:
721 _change_task_status(bug_task, "Incomplete", yes)696 if not _check_and_change_task_status(
697 bug_task, "Incomplete", yes=yes, update=update
698 ):
699 result = False
722 else:700 else:
723 warning(f"{bug_task.bug_target_name} {bug_task.status}")701 warning(
724 if args.release and args.ready and saw_ubuntu_task is False:702 f"It is unexpected to see the '{bug_task.bug_target_name}' task and the '{bug_task.status}' status."
703 )
704 if update and args.release and args.ready and saw_ubuntu_task is False:
725 bug.addTask(target=lp.projects["Ubuntu"])705 bug.addTask(target=lp.projects["Ubuntu"])
726 for bug_task in bug.bug_tasks:706 for bug_task in bug.bug_tasks:
727 if bug_task.bug_target_name == "ubuntu":707 if bug_task.bug_target_name == "ubuntu":
728 _change_task_status(bug_task, "In Progress", yes)708 _check_and_change_task_status(
709 bug_task, "In Progress", yes=True, update=True
710 )
711 if not update and not args.release and not args.ready and saw_ubuntu_task:
712 result = False
713 return result
729714
730715
731def check_and_update_bug_subscriptions(lp, bug, update=False, yes=False) -> bool:716def check_and_update_bug_subscriptions(lp, bug, update=False, yes=False) -> bool:
@@ -738,7 +723,7 @@ def check_and_update_bug_subscriptions(lp, bug, update=False, yes=False) -> bool
738 for subscription in bug.subscriptions:723 for subscription in bug.subscriptions:
739 subscriptions.append(subscription.person.name)724 subscriptions.append(subscription.person.name)
740 if not args.ready or not args.release:725 if not args.ready or not args.release:
741 for subscriber in ("ubuntu-sponsors", "ubuntu-desktop"):726 for subscriber in ("ubuntu-archive", "ubuntu-sponsors", "ubuntu-desktop"):
742 if subscriber == subscription.person.name:727 if subscriber == subscription.person.name:
743 if subscription.canBeUnsubscribedByUser():728 if subscription.canBeUnsubscribedByUser():
744 error(f"'{subscriber}' should not be in the subscriptions.")729 error(f"'{subscriber}' should not be in the subscriptions.")
@@ -753,7 +738,7 @@ def check_and_update_bug_subscriptions(lp, bug, update=False, yes=False) -> bool
753 f"'{subscriber}' should not be in the subscriptions, and {lp.me.name} doesn't have the permission to unsubscribe it."738 f"'{subscriber}' should not be in the subscriptions, and {lp.me.name} doesn't have the permission to unsubscribe it."
754 )739 )
755 if args.ready and args.release:740 if args.ready and args.release:
756 for subscriber in SUBSCRIBER_LIST:741 for subscriber in ("oem-solutions-engineers", "ubuntu-archive"):
757 if subscriber not in subscriptions:742 if subscriber not in subscriptions:
758 error(f"'{subscriber}' is not in the subscriptions.")743 error(f"'{subscriber}' is not in the subscriptions.")
759 if update and yes_or_ask(744 if update and yes_or_ask(
diff --git a/oem_scripts/__init__.py b/oem_scripts/__init__.py
index a3aaceb..c8a6ffe 100644
--- a/oem_scripts/__init__.py
+++ b/oem_scripts/__init__.py
@@ -41,8 +41,6 @@ ALLOWED_KERNEL_META_LIST = (
41 "linux-generic",41 "linux-generic",
42)42)
4343
44SUBSCRIBER_LIST = ("oem-solutions-engineers", "ubuntu-sponsors", "ubuntu-desktop")
45
46TAG_LIST = ["oem-meta-packages", "oem-priority", f"oem-scripts-{__version__}"]44TAG_LIST = ["oem-meta-packages", "oem-priority", f"oem-scripts-{__version__}"]
4745
4846

Subscribers

People subscribed via source and target branches