Skip to content

Commit

Permalink
Merge pull request #938 from googlefonts/project-board-update
Browse files Browse the repository at this point in the history
traffic jam: Also update the Google Fonts board
  • Loading branch information
m4rc1e authored May 3, 2024
2 parents 72be23d + 4222d6c commit c8b04de
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Lib/gftools/push/servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ def __init__(

@property
def last_push(self):
return datetime.fromtimestamp(self.family_versions_data["lastUpdate"]["seconds"])
return datetime.fromtimestamp(
self.family_versions_data["lastUpdate"]["seconds"]
)

def compare_push_item(self, item: Items):
server_item = self.find_item(item)
Expand Down
53 changes: 50 additions & 3 deletions Lib/gftools/push/trafficjam.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
import os
from configparser import ConfigParser
from dataclasses import dataclass
from dataclasses import dataclass, field
from enum import Enum
from io import TextIOWrapper
from pathlib import Path
Expand Down Expand Up @@ -33,6 +33,13 @@
TO_SANDBOX_ID = config["board_meta"]["to_sandbox_id"]
TO_PRODUCTION_ID = config["board_meta"]["to_production_id"]
BLOCKED_ID = config["board_meta"]["blocked_id"]

GF_BOARD_ID = config["gf_board_meta"]["board_id"]
GF_BOARD_STATUS_FIELD_ID = config["gf_board_meta"]["board_id"]
GF_BOARD_PR_GF_ID = config["gf_board_meta"]["pr_gf_id"]
GF_BOARD_IN_DEV_ID = config["gf_board_meta"]["in_dev_id"]
GF_BOARD_IN_SANDBOX_ID = config["gf_board_meta"]["in_sandbox_id"]
GF_BOARD_LIVE_ID = config["gf_board_meta"]["live_id"]
else:
TRAFFIC_JAM_ID = os.environ.get("TRAFFIC_JAM_ID")
STATUS_FIELD_ID = os.environ.get("STATUS_FIELD_ID")
Expand All @@ -45,6 +52,13 @@
TO_PRODUCTION_ID = os.environ.get("TO_PRODUCTION_ID")
BLOCKED_ID = os.environ.get("BLOCKED_ID")

GF_BOARD_ID = os.environ.get("GF_BOARD_ID")
GF_BOARD_STATUS_FIELD_ID = os.environ.get("GF_BOARD_STATUS_FIELD_ID")
GF_BOARD_PR_GF_ID = os.environ.get("GF_BOARD_PR_GF_ID")
GF_BOARD_IN_DEV_ID = os.environ.get("GF_BOARD_IN_DEV_ID")
GF_BOARD_IN_SANDBOX_ID = os.environ.get("GF_BOARD_IN_SANDBOX_ID")
GF_BOARD_LIVE_ID = os.environ.get("GF_BOARD_LIVE_ID")


class STATUS_OPTION_IDS(Enum):
PR_GF = PR_GF_ID
Expand All @@ -53,6 +67,13 @@ class STATUS_OPTION_IDS(Enum):
LIVE = LIVE_ID


class GF_BOARD_STATUS_OPTION_IDS(Enum):
PR_GF = GF_BOARD_PR_GF_ID
IN_DEV = GF_BOARD_IN_DEV_ID
IN_SANDBOX = GF_BOARD_IN_SANDBOX_ID
LIVE = GF_BOARD_LIVE_ID


class LIST_OPTION_IDS(Enum):
TO_SANDBOX = TO_SANDBOX_ID
TO_PRODUCTION = TO_PRODUCTION_ID
Expand Down Expand Up @@ -145,6 +166,16 @@ def from_string(string: str): # type: ignore[misc]
name
}
}
closingIssuesReferences(first: 10) {
nodes {
url
projectItems(first: 10) {
nodes {
id
}
}
}
}
merged
closed
}
Expand Down Expand Up @@ -181,6 +212,7 @@ class PushItem:
push_list: Optional[PushList] = None
merged: Optional[bool] = None
id_: Optional[str] = None
linked_issues: list = field(default_factory=lambda: [])

def __hash__(self) -> int:
return hash(self.path)
Expand Down Expand Up @@ -227,7 +259,16 @@ def set_server(self, server: STATUS_OPTION_IDS):
STATUS_FIELD_ID,
server.value,
)
g._run_graphql(mutation, {})
# Update the projects board as well
for linked_issue in self.linked_issues:
for project_item in linked_issue["projectItems"]["nodes"]:
mutation = GOOGLE_FONTS_UPDATE_ITEM % (
GF_BOARD_ID,
project_item["id"],
GF_BOARD_STATUS_FIELD_ID,
getattr(GF_BOARD_STATUS_OPTION_IDS, server.name).value,
)
g._run_graphql(mutation, {})

def set_pushlist(self, listt: LIST_OPTION_IDS):
from gftools.gfgithub import GitHubClient
Expand Down Expand Up @@ -522,6 +563,8 @@ def from_traffic_jam(cls, fp=None):
continue
labels = [i["name"] for i in item["content"]["labels"]["nodes"]]

linked_issues = item["content"]["closingIssuesReferences"]["nodes"]

files = [Path(i["path"]) for i in item["content"]["files"]["nodes"]]
url = item["content"]["url"]
merged = item["content"]["merged"]
Expand All @@ -548,5 +591,9 @@ def from_traffic_jam(cls, fp=None):
cat = PushCategory.OTHER

for f in files:
results.add(PushItem(Path(f), cat, status, url, push_list, merged, id_))
results.add(
PushItem(
Path(f), cat, status, url, push_list, merged, id_, linked_issues
)
)
return results

0 comments on commit c8b04de

Please sign in to comment.