From fe7c399d74f2f5d8c8065ecccc634279d9eaffd8 Mon Sep 17 00:00:00 2001 From: seylu <98249191+seyLu@users.noreply.github.com> Date: Sat, 2 Sep 2023 12:17:17 +0800 Subject: [PATCH] feat: add more labels and backwards compatibility --- ...efault_labels.yaml => _remove_labels.yaml} | 0 labels/affects_labels.yaml | 20 ++++ labels/labels.yaml | 56 ++++++++++ labels/priority_labels.yaml | 4 +- labels/state_labels.yaml | 10 ++ labels/type_labels.yaml | 12 +- scripts/_dump_labels.py | 103 ++++++++++++++++-- scripts/setup_issue_label.py | 4 +- 8 files changed, 188 insertions(+), 21 deletions(-) rename labels/{remove_default_labels.yaml => _remove_labels.yaml} (100%) create mode 100644 labels/affects_labels.yaml create mode 100644 labels/labels.yaml create mode 100644 labels/state_labels.yaml diff --git a/labels/remove_default_labels.yaml b/labels/_remove_labels.yaml similarity index 100% rename from labels/remove_default_labels.yaml rename to labels/_remove_labels.yaml diff --git a/labels/affects_labels.yaml b/labels/affects_labels.yaml new file mode 100644 index 0000000..88afff6 --- /dev/null +++ b/labels/affects_labels.yaml @@ -0,0 +1,20 @@ +- name: 'Affects: Game Assets' + color: '#fbbc9d' + description: Issues relating directly to art and game assets. +- name: 'Affects: Game Logic/Controls' + color: '#fbbc9d' + description: Issues relating directly to game logic and controls. +- name: 'Affects: Game Performance' + color: '#fbbc9d' + description: Issues relating directly to squeezing game performance. +- name: 'Affects: Game Rendering' + color: '#fbbc9d' + description: Issues relating directly to game rendering. +- name: 'Affects: Infra' + color: '#fbbc9d' + description: Related to configuration, automation, CI, etc. +- name: 'Affects: Player Experience' + color: '#fbbc9d' + description: Issues relating directly to game design & player experience. +- name: 'Affects: Project Management' + color: '#fbbc9d' diff --git a/labels/labels.yaml b/labels/labels.yaml new file mode 100644 index 0000000..6c31eee --- /dev/null +++ b/labels/labels.yaml @@ -0,0 +1,56 @@ +- name: 'Priority: Critical' + color: '#7c0a02' +- name: 'Priority: High' + color: '#b22222' +- name: 'Priority: Medium' + color: '#ff8597' +- name: 'Priority: Low' + color: '#ffccc9' +- name: 'Type: Bug' + color: '#ff9900' + description: Something isn't working. +- name: 'Type: Documentation' + color: '#ff9900' + description: Improvements or additions to documentation. +- name: 'Type: Feature Request' + color: '#ff9900' + description: Issue describes a feature or enhancement we'd like to implement. +- name: 'Type: Question' + color: '#ff9900' + description: This issue doesn't require code. A question needs an answer. +- name: 'Type: Refactor/Clean-up' + color: '#ff9900' + description: Issues related to reorganization/clean-up of data or code (e.g. for + maintainability). +- name: 'Type: Suggestion' + color: '#ff9900' +- name: 'State: Blocked' + color: '#e07bf9' + description: Work has stopped, waiting for something (Info, Dependent fix, etc. + See comments). +- name: 'State: In Review' + color: '#e07bf9' + description: This issue is waiting for review to finish. +- name: 'State: Work In Progress' + color: '#e07bf9' + description: This issue is being actively worked on. +- name: 'Affects: Game Assets' + color: '#fbbc9d' + description: Issues relating directly to art and game assets. +- name: 'Affects: Game Logic/Controls' + color: '#fbbc9d' + description: Issues relating directly to game logic and controls. +- name: 'Affects: Game Performance' + color: '#fbbc9d' + description: Issues relating directly to squeezing game performance. +- name: 'Affects: Game Rendering' + color: '#fbbc9d' + description: Issues relating directly to game rendering. +- name: 'Affects: Infra' + color: '#fbbc9d' + description: Related to configuration, automation, CI, etc. +- name: 'Affects: Player Experience' + color: '#fbbc9d' + description: Issues relating directly to game design & player experience. +- name: 'Affects: Project Management' + color: '#fbbc9d' diff --git a/labels/priority_labels.yaml b/labels/priority_labels.yaml index 49a4427..5e1980e 100644 --- a/labels/priority_labels.yaml +++ b/labels/priority_labels.yaml @@ -3,6 +3,6 @@ - name: 'Priority: High' color: '#b22222' - name: 'Priority: Medium' - color: '#e88a1a' + color: '#ff8597' - name: 'Priority: Low' - color: '#f1bc31' + color: '#ffccc9' diff --git a/labels/state_labels.yaml b/labels/state_labels.yaml new file mode 100644 index 0000000..2378492 --- /dev/null +++ b/labels/state_labels.yaml @@ -0,0 +1,10 @@ +- name: 'State: Blocked' + color: '#e07bf9' + description: Work has stopped, waiting for something (Info, Dependent fix, etc. + See comments). +- name: 'State: In Review' + color: '#e07bf9' + description: This issue is waiting for review to finish. +- name: 'State: Work In Progress' + color: '#e07bf9' + description: This issue is being actively worked on. diff --git a/labels/type_labels.yaml b/labels/type_labels.yaml index 3815919..145fc34 100644 --- a/labels/type_labels.yaml +++ b/labels/type_labels.yaml @@ -1,18 +1,18 @@ - name: 'Type: Bug' - color: '#d73a4a' + color: '#ff9900' description: Something isn't working. - name: 'Type: Documentation' - color: '#a2eeef' + color: '#ff9900' description: Improvements or additions to documentation. - name: 'Type: Feature Request' - color: '#e88a1a' + color: '#ff9900' description: Issue describes a feature or enhancement we'd like to implement. - name: 'Type: Question' - color: '#d876e3' + color: '#ff9900' description: This issue doesn't require code. A question needs an answer. - name: 'Type: Refactor/Clean-up' - color: '#a0855b' + color: '#ff9900' description: Issues related to reorganization/clean-up of data or code (e.g. for maintainability). - name: 'Type: Suggestion' - color: '#ac8daf' + color: '#ff9900' diff --git a/scripts/_dump_labels.py b/scripts/_dump_labels.py index 556c8ce..62fcf1c 100644 --- a/scripts/_dump_labels.py +++ b/scripts/_dump_labels.py @@ -27,7 +27,7 @@ @dataclass(frozen=True) class LABELS: - REMOVE_DEFAULT: tuple[str, ...] = ( + _REMOVE: tuple[str, ...] = ( "bug", "dependencies", "documentation", @@ -46,42 +46,95 @@ class LABELS: }, { "name": "Priority: Medium", - "color": "#e88a1a", + "color": "#ff8597", }, { "name": "Priority: Low", - "color": "#f1bc31", + "color": "#ffccc9", }, ) TYPE: tuple[dict[str, str], ...] = ( { "name": "Type: Bug", - "color": "#d73a4a", + "color": "#ff9900", "description": "Something isn't working.", }, { "name": "Type: Documentation", - "color": "#a2eeef", + "color": "#ff9900", "description": "Improvements or additions to documentation.", }, { "name": "Type: Feature Request", - "color": "#e88a1a", + "color": "#ff9900", "description": "Issue describes a feature or enhancement we'd like to implement.", }, { "name": "Type: Question", - "color": "#d876e3", + "color": "#ff9900", "description": "This issue doesn't require code. A question needs an answer.", }, { "name": "Type: Refactor/Clean-up", - "color": "#a0855b", + "color": "#ff9900", "description": "Issues related to reorganization/clean-up of data or code (e.g. for maintainability).", }, { "name": "Type: Suggestion", - "color": "#ac8daf", + "color": "#ff9900", + }, + ) + STATE: tuple[dict[str, str], ...] = ( + { + "name": "State: Blocked", + "color": "#e07bf9", + "description": "Work has stopped, waiting for something (Info, Dependent fix, etc. See comments).", + }, + { + "name": "State: In Review", + "color": "#e07bf9", + "description": "This issue is waiting for review to finish.", + }, + { + "name": "State: Work In Progress", + "color": "#e07bf9", + "description": "This issue is being actively worked on.", + }, + ) + AFFECTS: tuple[dict[str, str], ...] = ( + { + "name": "Affects: Game Assets", + "color": "#fbbc9d", + "description": "Issues relating directly to art and game assets.", + }, + { + "name": "Affects: Game Logic/Controls", + "color": "#fbbc9d", + "description": "Issues relating directly to game logic and controls.", + }, + { + "name": "Affects: Game Performance", + "color": "#fbbc9d", + "description": "Issues relating directly to squeezing game performance.", + }, + { + "name": "Affects: Game Rendering", + "color": "#fbbc9d", + "description": "Issues relating directly to game rendering.", + }, + { + "name": "Affects: Infra", + "color": "#fbbc9d", + "description": "Related to configuration, automation, CI, etc.", + }, + { + "name": "Affects: Player Experience", + "color": "#fbbc9d", + "description": "Issues relating directly to game design & player experience.", + }, + { + "name": "Affects: Project Management", + "color": "#fbbc9d", }, ) @@ -113,12 +166,22 @@ class LABELS: if os.path.isfile(file_path): os.remove(file_path) + # @TODO remove + legacy_labels: tuple[dict[str, str], ...] = () + for field in LABELS.__dataclass_fields__: - labels = getattr(LABELS, field) + labels: tuple[dict[str, str], ...] | tuple[str, ...] = getattr(LABELS, field) labels_file: str = os.path.join(LABELS_PATH, f"{field.lower()}_labels.{EXT}") + # @TODO remove + if not ( + isinstance(labels, tuple) + and all(isinstance(label, str) for label in labels) + ): + legacy_labels += labels # type: ignore + with open(labels_file, "w+") as f: - logging.info(f"Dumping to {labels_file}.") + logging.info(f"Dumping to {f.name}.") if EXT == "yaml": print( @@ -132,4 +195,22 @@ class LABELS: elif EXT == "json": json.dump(labels, f, indent=2) + # backwards compatibility + # @TODO remove + legacy_labels_file: str = os.path.join(LABELS_PATH, f"labels.{EXT}") + with open(legacy_labels_file, "w+") as f: + logging.info(f"Dumping to {f.name}.") + + if EXT == "yaml": + print( + yaml.dump( + data=list(legacy_labels), + default_flow_style=False, + sort_keys=False, + ), + file=f, + ) + elif EXT == "json": + json.dump(legacy_labels, f, indent=2) + logging.info("Finished dumping of labels.") diff --git a/scripts/setup_issue_label.py b/scripts/setup_issue_label.py index ca0c893..0fba2ac 100644 --- a/scripts/setup_issue_label.py +++ b/scripts/setup_issue_label.py @@ -39,12 +39,12 @@ def validate_env(env: str) -> str: @dataclass(frozen=True) class BasePath: CWD: str = os.path.dirname(__file__) - CONFIG: str = "config" + LABELS: str = "labels" @dataclass(frozen=True) class LabelFile: - _BASE_FILE: str = os.path.join(BasePath.CWD, "..", BasePath.CONFIG, "labels") + _BASE_FILE: str = os.path.join(BasePath.CWD, "..", BasePath.LABELS, "labels") YAML: str = f"{_BASE_FILE}.yaml" JSON: str = f"{_BASE_FILE}.json"