1
0
Fork 0
mirror of https://gitlab.wikimedia.org/ladsgroup/Phabricator-maintenance-bot synced 2024-10-30 08:47:10 +01:00
Phabricator-maintenance-bot/project_grouper.py

332 lines
9.8 KiB
Python
Raw Normal View History

2020-12-25 11:21:08 +01:00
"""
Adds tasks in configured projects to other configured projects
"""
from lib import Client
# To get it on a list run this on herald rule page
# const items = document.getElementsByClassName('herald-list-item')[0].getElementsByClassName('phui-handle')
# for (i in items) {console.log(items[i].text)};
2020-12-25 11:21:08 +01:00
rules = [
{
2020-12-26 10:34:50 +01:00
# H175 - see T136921
2020-12-25 11:21:08 +01:00
'add': 'Design',
'in': ['WMF-Design', 'WMDE-Design'],
},
2020-12-26 10:34:50 +01:00
{
# H232
'add': 'artificial-intelligence',
'in': ['editquality-modeling', 'draftquality-modeling', 'articlequality-modeling', 'revscoring'],
},
{
# H193 - see T146701
'add': 'accessibility',
'in': ['ios-app-feature-accessibility'],
},
{
# H174
'add': 'upstream',
'in': ['phabricator-upstream'],
},
{
# H24 - see T86536
'add': 'universallanguageselector',
'in': ['uls-compactlinks'],
},
{
# H15 - note that #producrement tasks are private -> rule can't be disabled
2021-05-24 20:47:59 +02:00
'add': 'SRE',
2020-12-26 10:34:50 +01:00
'in': [
'ops-eqiad',
'ops-codfw',
'ops-esams',
'ops-ulsfo',
# 'hardware-requests', archived project
'SRE-Access-Requests',
'vm-requests',
'ops-eqord',
'ops-eqdfw',
# 'procurement', always in S4
'ops-eqsin',
'DNS',
'LDAP-Access-Requests',
'Wikimedia-Mailing-lists',
],
2021-05-24 20:47:59 +02:00
'once': True
2020-12-26 10:34:50 +01:00
},
{
# H14 - see T85596
'add': 'Social-Tools',
'in': [
'BlogPage',
'Challenge',
2020-12-26 10:34:50 +01:00
'Comments',
'FanBoxes',
'ImageRating',
2020-12-26 10:34:50 +01:00
'LinkFilter',
'MiniInvite',
'NewSignupPage',
# 'NewUsersList', archived project
'PictureGame',
2020-12-26 10:34:50 +01:00
'PollNY',
'QuizGame',
# 'RandomFeaturedUser', archived project
'RandomGameUnit',
# 'RandomUsersWithAvatars', archived project
2020-12-26 10:34:50 +01:00
'SocialProfile',
'SiteMetrics',
'SportsTeams',
# 'TopLists', archived project
'video_non-wmf',
2020-12-26 10:34:50 +01:00
'VoteNY',
'WikiForum',
'WikiTextLoggedInOut',
],
},
{
# H10 - see T76954
'add': 'VisualEditor',
'in': [
'VisualEditor-ContentEditable',
'VisualEditor-ContentLanguage',
'VisualEditor-CopyPaste',
'VisualEditor-DataModel',
'VisualEditor-EditingTools',
'VisualEditor-Initialisation',
'VisualEditor-InterfaceLanguage',
'VisualEditor-MediaWiki',
'VisualEditor-MediaWiki-Links',
'VisualEditor-MediaWiki-Media',
'VisualEditor-MediaWiki-Mobile',
'VisualEditor-MediaWiki-References',
'VisualEditor-MediaWiki-Templates',
'VisualEditor-Performance',
'VisualEditor-Tables',
'TemplateData',
'VisualEditor-MediaWiki-Plugins',
'VisualEditor-LanguageTool',
'VisualEditor-Links',
'VisualEditor-Media',
'VisualEditor-MediaWiki-2017WikitextEditor',
'VisualEditor-VisualDiffs',
],
2021-04-14 17:29:47 +02:00
},
{
# H30
'add': 'wikidata',
'in': [
'Wikibase-Quality-Constraints',
'DataValues',
'DataValues-JavaScript',
'MediaWiki-extensions-WikibaseClient',
'MediaWiki-extensions-WikibaseView',
'Wikibase-DataModel',
'Wikibase-DataModel-JavaScript',
'Wikibase-DataModel-Serialization',
'Wikibase-Internal-Serialization',
'Wikibase-JavaScript-Api',
'Wikibase-Serialization-JavaScript',
'Wikidata-Query-Service',
'Tool-Wikidata-Periodic-Table',
'Wikidata.org',
'DataTypes',
'MediaWiki-extensions-WikibaseRepository',
'SDC General',
'ValueView',
'Wikidata-Gadgets',
'ArticlePlaceholder',
'Wikidata Lexicographical data',
'Automated list generation',
'Wikidata Query UI',
'Wikibase-Containers',
'Soweego',
'Wikidata Mobile',
'Wikidata-Campsite',
'Wikibase-registry',
'wikiba.se website',
'Wikibase-Lua',
'MediaWiki-extensions-PropertySuggester',
'Wikidata-Campsite (Wikidata-Campsite-Iteration-∞)',
'RL Module Terminators Trailblazing',
'Wikidata-Bridge',
'Shape Expressions',
'Wikidata Tainted References',
'Wikidata Design System',
'Wikidata - Reference Treasure Hunt',
'Item Quality Scoring Improvement',
'Wikibase - Automated Configuration Detection (WikibaseManifest)',
'Wikidata Query Builder',
2021-06-02 11:23:36 +02:00
'Wikidata - Visualisation of Reliability Metrics',
'Item Quality Evaluator',
'wdwb-tech',
2021-06-04 13:59:17 +02:00
'Cognate',
2021-06-14 17:07:25 +02:00
'Mismatch Finder',
'Wikidata analytics',
2021-08-28 19:11:20 +02:00
'Wikidata-Termbox',
'Special:NewLexeme revival',
2022-07-05 16:39:52 +02:00
'Wikidata Dev Team',
'Wikidata data quality and trust',
'Wikidata-UX',
'Wikidata Integration in Wikimedia projects',
2024-03-30 14:56:07 +01:00
'Wikidata Sitelinks',
'Wikidata Change Dispatching & Watchlists',
],
'once': True
},
{
'add': 'Wikidata Lexicographical data',
'in': [
'Special:NewLexeme revival',
],
'once': True
},
{
# H337
'add': 'Research',
'in': [
'address-knowledge-gaps',
'Research-foundational',
'Knowledge-Integrity',
],
'once': True
},
{
# H314
'add': 'Pywikibot',
'in': [
'Pywikibot-archivebot.py',
'Pywikibot-category.py',
'Pywikibot-compat',
'Pywikibot-copyright.py',
'Pywikibot-delinker.py',
'Pywikibot-cosmetic-changes.py',
'Pywikibot-Documentation',
'Pywikibot-General',
'Pywikibot-i18n',
'Pywikibot-interwiki.py',
'Pywikibot-login.py',
'Pywikibot-network',
'Pywikibot-Scripts',
'Pywikibot-pagegenerators.py',
'Pywikibot-redirect.py',
'Pywikibot-replace.py',
'Pywikibot-solve-disambiguation.py',
'Pywikibot-tests',
'Pywikibot-textlib.py',
'Pywikibot-weblinkchecker.py',
'Pywikibot-Wikidata',
'Pywikibot-xmlreader.py',
],
'once': True
},
{
# H285
'add': 'Product-Analytics',
'in': [
'Discovery-Analysis',
],
'once': True
},
{
# H216
'add': 'WMDE-FUN-Team',
'in': [
'WMDE-Fundraising-Tech',
],
'once': True
},
{
# H131
'add': 'Traffic',
'in': [
'HTTPS',
'DNS',
'Domains',
],
'once': True
},
{
# H131
'add': 'Traffic',
'in': [
'HTTPS',
'DNS',
'Domains',
],
'once': True
},
{
# H109
'add': 'Commons',
'in': [
'MediaWiki-File-management',
'MediaWiki-extensions-GWToolset',
],
'once': True
},
{
# Keep all Abstract Wikipedia work on the team board
'add': 'abstract_wikipedia',
'in': [
'abstract_wikipedia_ux',
'wikifunctions',
'wikilambda',
'function-evaluator',
'function-orchestrator',
'function-schemata',
'tool-ducttape',
],
},
{
# https://phabricator.wikimedia.org/T295397
'add': 'Data-Engineering',
'in': [
'Event-Platform',
'Analytics-Wikistats',
],
'once': True
},
{
'add': 'growthexperiments-mentorship',
'in': [
'growthexperiments-mentordashboard',
'growthexperiments-personalizedpraise'
],
},
2020-12-25 11:21:08 +01:00
]
client = Client.newFromCreds()
for rule in rules:
handled_tasks = []
wanted_project_phid = client.lookupPhid('#' + rule['add'].replace(' ', '_'))
subprojects = set(client.getSubprojects(wanted_project_phid) + [wanted_project_phid])
2020-12-25 11:21:08 +01:00
for project_name in rule['in']:
project_name = project_name.replace(' ', '_')
try:
project_phid = client.lookupPhid('#' + project_name)
except:
continue
2020-12-25 11:21:08 +01:00
for task_phid in client.getTasksWithProject(project_phid):
# if a task is in multiple 'in' projects, still only process it once
if task_phid in handled_tasks:
continue
task = client.taskDetails(task_phid)
if subprojects.intersection(set(task['projectPHIDs'])):
continue
if rule.get('once') == True:
is_already_added = False
transactions = client.getTransactions(task_phid)
for transaction in transactions:
operations = transaction.get(
'fields', {}).get('operations', [])
for operation in operations:
if operation.get('operation') == 'add' and operation.get('phid') == wanted_project_phid:
is_already_added = True
break
if is_already_added == True:
continue
handled_tasks.append(task_phid)
client.addTaskProject(task_phid, wanted_project_phid)