summaryrefslogtreecommitdiff
path: root/archived/projt-launcher/ci/eval/compare/maintainers.nix
blob: 12ab47f208cd528624c43aee58a96be7f4d5dc8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# =============================================================================
# ProjT Launcher - Maintainer Assignment Module
# =============================================================================
# Maps changed files to their maintainers based on OWNERS file.
# Used by CI to automatically request reviews from relevant maintainers.
# =============================================================================

{
  lib,
}:

{
  # List of changed file paths
  changedPaths ? [ ],
}:

let
  # =============================================================================
  # Maintainer Definitions
  # =============================================================================

  # Project maintainers (GitHub usernames)
  maintainers = {
    YongDo-Hyun = {
      github = "YongDo-Hyun";
      name = "YongDo Hyun";
      areas = [
        "core"
        "ui"
        "minecraft"
        "build"
        "ci"
        "all"
      ];
    };
    grxtor = {
      github = "grxtor";
      name = "GRXTOR";
      areas = [
        "core"
        "ui"
        "minecraft"
        "build"
        "ci"
        "all"
      ];
    };
  };

  # =============================================================================
  # File to Area Mapping
  # =============================================================================

  # Map file paths to areas of responsibility
  getArea =
    filePath:
    if lib.hasPrefix "launcher/ui/" filePath then
      "ui"
    else if lib.hasPrefix "launcher/qtquick/" filePath then
      "ui"
    else if lib.hasPrefix "launcher/minecraft/" filePath then
      "minecraft"
    else if lib.hasPrefix "launcher/modplatform/" filePath then
      "modplatform"
    else if lib.hasPrefix "launcher/java/" filePath then
      "java"
    else if lib.hasPrefix "launcher/net/" filePath then
      "networking"
    else if lib.hasPrefix "launcher/" filePath then
      "core"
    else if lib.hasPrefix "cmake/" filePath then
      "build"
    else if lib.hasSuffix "CMakeLists.txt" filePath then
      "build"
    else if lib.hasPrefix ".github/" filePath then
      "ci"
    else if lib.hasPrefix "ci/" filePath then
      "ci"
    else if lib.hasPrefix "translations/" filePath then
      "translations"
    else if lib.hasPrefix "docs/" filePath then
      "documentation"
    else
      "other";

  # =============================================================================
  # Maintainer Resolution
  # =============================================================================

  # Get maintainers for a specific area
  getMaintainersForArea =
    area:
    lib.filter (m: builtins.elem area m.areas || builtins.elem "all" m.areas) (
      builtins.attrValues maintainers
    );

  # Get maintainers for a file
  getMaintainersForFile = filePath: getMaintainersForArea (getArea filePath);

  # Get all affected maintainers for changed files
  getAffectedMaintainers =
    changedFiles:
    let
      allMaintainers = lib.concatMap getMaintainersForFile changedFiles;
      uniqueByGithub = lib.groupBy (m: m.github) allMaintainers;
    in
    lib.mapAttrsToList (_: ms: builtins.head ms) uniqueByGithub;

  # =============================================================================
  # Change Analysis
  # =============================================================================

  # Group changed files by area
  filesByArea = lib.groupBy getArea changedPaths;

  # Get affected areas
  affectedAreas = builtins.attrNames filesByArea;

  # Get maintainers who should be notified
  maintainersToNotify = getAffectedMaintainers changedPaths;

in
{
  # List of maintainer GitHub usernames to notify
  maintainers = map (m: m.github) maintainersToNotify;

  # Areas affected by changes
  areas = affectedAreas;

  # Detailed mapping of areas to files
  inherit filesByArea;

  # Full maintainer info
  maintainerDetails = maintainersToNotify;

  # Summary for CI output
  summary = {
    totalFiles = builtins.length changedPaths;
    inherit affectedAreas;
    maintainers = map (m: m.github) maintainersToNotify;
  };
}