Skip to content

Commit e93a270

Browse files
jfrocheyvan-sraka
authored andcommitted
feat: optimize CI runner selection based on package size
Dynamically assign larger runners (32vcpu) for Rust and PostGIS extensions while using smaller runners (8vcpu) for standard packages.
1 parent 304dee2 commit e93a270

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

scripts/github-matrix.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,14 @@ class GitHubActionPackage(TypedDict):
5454

5555
BUILD_RUNNER_MAP: Dict[str, RunsOnConfig] = {
5656
"aarch64-linux": {
57-
"group": "self-hosted-runners-nix",
58-
"labels": ["aarch64-linux"],
57+
"labels": ["blacksmith-8vcpu-ubuntu-2404-arm"],
5958
},
6059
"aarch64-darwin": {
6160
"group": "self-hosted-runners-nix",
6261
"labels": ["aarch64-darwin"],
6362
},
6463
"x86_64-linux": {
65-
"labels": ["blacksmith-32vcpu-ubuntu-2404"],
64+
"labels": ["blacksmith-8vcpu-ubuntu-2404"],
6665
},
6766
}
6867

@@ -162,6 +161,30 @@ def sort_pkgs_by_closures(jobs: List[NixEvalJobsOutput]) -> List[NixEvalJobsOutp
162161
return sorted_jobs
163162

164163

164+
def is_large_pkg(pkg: NixEvalJobsOutput) -> bool:
165+
"""Determine if a package is considered large based on its attribute path."""
166+
RUST_EXTENSIONS = ["exts.wrappers", "exts.pg_jsonschema", "exts.pg_graphql"]
167+
LARGE_C_EXTENSION = ["exts.postgis"]
168+
return any(
169+
indicator in pkg["attr"] for indicator in RUST_EXTENSIONS + LARGE_C_EXTENSION
170+
)
171+
172+
173+
def get_runner_for_package(pkg: NixEvalJobsOutput) -> RunsOnConfig:
174+
"""Determine the appropriate GitHub Actions runner for a package."""
175+
system = pkg["system"]
176+
if is_large_pkg(pkg):
177+
# Use larger runners for large packages for x86_64-linux and aarch64-linux
178+
if system == "x86_64-linux":
179+
return {"labels": ["blacksmith-32vcpu-ubuntu-2404"]}
180+
elif system == "aarch64-linux":
181+
return {"labels": ["blacksmith-32vcpu-ubuntu-2404-arm"]}
182+
if system in BUILD_RUNNER_MAP:
183+
return BUILD_RUNNER_MAP[system]
184+
else:
185+
raise ValueError(f"No runner configuration for system: {system}")
186+
187+
165188
def main() -> None:
166189
parser = argparse.ArgumentParser(
167190
description="Generate GitHub Actions matrix for Nix builds"
@@ -184,6 +207,7 @@ def clean_package_for_output(pkg: NixEvalJobsOutput) -> GitHubActionPackage:
184207
"attr": pkg["attr"],
185208
"name": pkg["name"],
186209
"system": pkg["system"],
210+
"runs_on": get_runner_for_package(pkg),
187211
}
188212
if is_extension_pkg(pkg):
189213
# Extract PostgreSQL version from attribute path

0 commit comments

Comments
 (0)