@@ -43,16 +43,12 @@ class RunsOnConfig(TypedDict):
43
43
44
44
45
45
class GitHubActionPackage (TypedDict ):
46
- """Processed package for GitHub Actions matrix."""
46
+ """Final package output for GitHub Actions matrix."""
47
47
48
48
attr : str
49
49
name : str
50
50
system : str
51
- already_cached : bool
52
51
runs_on : RunsOnConfig
53
- drvPath : str
54
- neededSubstitutes : List [str ]
55
- neededBuilds : List [str ]
56
52
postgresql_version : NotRequired [str ]
57
53
58
54
@@ -94,9 +90,7 @@ def build_nix_eval_command(max_workers: int, flake_outputs: List[str]) -> List[s
94
90
return nix_eval_cmd
95
91
96
92
97
- def parse_nix_eval_line (
98
- line : str , drv_paths : Set [str ]
99
- ) -> Optional [GitHubActionPackage ]:
93
+ def parse_nix_eval_line (line : str , drv_paths : Set [str ]) -> Optional [NixEvalJobsOutput ]:
100
94
"""Parse a single line of nix-eval-jobs output"""
101
95
if not line .strip ():
102
96
return None
@@ -106,25 +100,13 @@ def parse_nix_eval_line(
106
100
if data ["drvPath" ] in drv_paths :
107
101
return None
108
102
drv_paths .add (data ["drvPath" ])
109
-
110
- runs_on_config = BUILD_RUNNER_MAP [data ["system" ]]
111
-
112
- return {
113
- "attr" : f"{ data ['attr' ]} " ,
114
- "name" : data ["name" ],
115
- "system" : data ["system" ],
116
- "already_cached" : data .get ("cacheStatus" ) != "notBuilt" ,
117
- "runs_on" : runs_on_config ,
118
- "drvPath" : data ["drvPath" ],
119
- "neededSubstitutes" : data .get ("neededSubstitutes" , []),
120
- "neededBuilds" : data .get ("neededBuilds" , []),
121
- }
103
+ return data
122
104
except json .JSONDecodeError :
123
105
print (f"Skipping invalid JSON line: { line } " , file = sys .stderr )
124
106
return None
125
107
126
108
127
- def run_nix_eval_jobs (cmd : List [str ]) -> Generator [GitHubActionPackage , None , None ]:
109
+ def run_nix_eval_jobs (cmd : List [str ]) -> Generator [NixEvalJobsOutput , None , None ]:
128
110
"""Run nix-eval-jobs and yield parsed package data."""
129
111
print (f"Running command: { ' ' .join (cmd )} " , file = sys .stderr )
130
112
@@ -146,21 +128,21 @@ def run_nix_eval_jobs(cmd: List[str]) -> Generator[GitHubActionPackage, None, No
146
128
sys .exit (process .returncode )
147
129
148
130
149
- def is_extension_pkg (pkg : GitHubActionPackage ) -> bool :
131
+ def is_extension_pkg (pkg : NixEvalJobsOutput ) -> bool :
150
132
"""Check if the package is a postgresql extension package."""
151
133
attrs = pkg ["attr" ].split ("." )
152
134
return attrs [- 2 ] == "exts"
153
135
154
136
155
137
# thank you buildbot-nix https://github.com/nix-community/buildbot-nix/blob/985d069a2a45cf4a571a4346107671adc2bd2a16/buildbot_nix/buildbot_nix/build_trigger.py#L297
156
- def sort_pkgs_by_closures (jobs : List [GitHubActionPackage ]) -> List [GitHubActionPackage ]:
138
+ def sort_pkgs_by_closures (jobs : List [NixEvalJobsOutput ]) -> List [NixEvalJobsOutput ]:
157
139
sorted_jobs = []
158
140
159
141
# Prepare job dependencies
160
142
job_set = {job ["drvPath" ] for job in jobs }
161
143
job_closures = {
162
- k ["drvPath" ]: set (k [ "neededSubstitutes" ] )
163
- .union (set (k [ "neededBuilds" ] ))
144
+ k ["drvPath" ]: set (k . get ( "neededSubstitutes" , []) )
145
+ .union (set (k . get ( "neededBuilds" , []) ))
164
146
.intersection (job_set )
165
147
.difference ({k ["drvPath" ]})
166
148
for k in jobs
@@ -196,13 +178,12 @@ def main() -> None:
196
178
197
179
gh_action_packages = sort_pkgs_by_closures (list (run_nix_eval_jobs (cmd )))
198
180
199
- def clean_package_for_output (pkg : GitHubActionPackage ) -> dict :
200
- """Remove debug fields from package for final output """
201
- returned_pkg = {
181
+ def clean_package_for_output (pkg : NixEvalJobsOutput ) -> GitHubActionPackage :
182
+ """Convert nix-eval-jobs output to GitHub Actions matrix package """
183
+ returned_pkg : GitHubActionPackage = {
202
184
"attr" : pkg ["attr" ],
203
185
"name" : pkg ["name" ],
204
186
"system" : pkg ["system" ],
205
- "runs_on" : pkg ["runs_on" ],
206
187
}
207
188
if is_extension_pkg (pkg ):
208
189
# Extract PostgreSQL version from attribute path
@@ -213,7 +194,7 @@ def clean_package_for_output(pkg: GitHubActionPackage) -> dict:
213
194
# Group packages by system
214
195
grouped_by_system = defaultdict (list )
215
196
for pkg in gh_action_packages :
216
- if not pkg [ "already_cached" ] :
197
+ if pkg . get ( "cacheStatus" ) == "notBuilt" :
217
198
grouped_by_system [pkg ["system" ]].append (clean_package_for_output (pkg ))
218
199
219
200
# Create output with system-specific matrices
0 commit comments