Skip to content

Commit 3f8eccb

Browse files
committed
ci: split checks build jobs by system architecture
Refactor GitHub Actions workflow to run build checks in parallel across different architectures (aarch64-linux, aarch64-darwin) with separate job matrices.
1 parent f101cfc commit 3f8eccb

File tree

2 files changed

+51
-21
lines changed

2 files changed

+51
-21
lines changed

.github/workflows/nix-build.yml

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,32 @@ jobs:
105105
set -Eeu
106106
echo matrix="$(python scripts/github-matrix.py checks)" >> "$GITHUB_OUTPUT"
107107
108+
build-checks-aarch64-linux:
109+
name: ${{matrix.postgresql_version}}.${{ matrix.name }} (aarch64-darwin)
110+
needs: checks-matrix
111+
runs-on: ${{ matrix.runs_on.group && matrix.runs_on || matrix.runs_on.labels }}
112+
if: ${{ fromJSON(needs.checks-matrix.outputs.matrix).aarch64_linux != null }}
113+
strategy:
114+
fail-fast: false
115+
max-parallel: 5
116+
matrix: ${{ fromJSON(needs.checks-matrix.outputs.matrix).aarch64_linux }}
117+
steps:
118+
- name: Checkout Repo
119+
uses: actions/checkout@v4
120+
- name: Build Nix Package
121+
uses: ./.github/actions/nix-build-setup
122+
with:
123+
attr: ${{ matrix.attr }}
108124

109-
build-checks:
110-
name: ${{ matrix.name }} (${{ matrix.system }})
111-
needs: [checks-matrix]
125+
build-checks-aarch64-darwin:
126+
name: ${{matrix.postgresql_version}}.${{ matrix.name }} (aarch64-darwin)
127+
needs: checks-matrix
112128
runs-on: ${{ matrix.runs_on.group && matrix.runs_on || matrix.runs_on.labels }}
113-
if: |
114-
!cancelled() &&
115-
(needs.checks-matrix.result == 'skipped' || needs.checks-matrix.result == 'success')
129+
if: ${{ fromJSON(needs.checks-matrix.outputs.matrix).aarch64_darwin != null }}
116130
strategy:
117131
fail-fast: false
118-
matrix: ${{fromJSON(needs.checks-matrix.outputs.matrix)}}
132+
max-parallel: 5
133+
matrix: ${{ fromJSON(needs.checks-matrix.outputs.matrix).aarch64_darwin }}
119134
steps:
120135
- name: Checkout Repo
121136
uses: actions/checkout@v4
@@ -124,9 +139,28 @@ jobs:
124139
with:
125140
attr: ${{ matrix.attr }}
126141

142+
# TODO
143+
# build-checks-x86_64-linux:
144+
# name: ${{matrix.postgresql_version}}.${{ matrix.name }} (x86_64-linux)
145+
# needs: checks-matrix
146+
# runs-on: ${{ matrix.runs_on.group && matrix.runs_on || matrix.runs_on.labels }}
147+
# if: ${{ fromJSON(needs.checks-matrix.outputs.matrix).x86_64_linux != null }}
148+
# strategy:
149+
# fail-fast: false
150+
# max-parallel: 5
151+
# matrix: ${{ fromJSON(needs.checks-matrix.outputs.matrix).x86_64_linux }}
152+
# steps:
153+
# - name: Checkout Repo
154+
# uses: actions/checkout@v4
155+
# - name: Build Nix Package
156+
# uses: ./.github/actions/nix-build-setup
157+
# with:
158+
# attr: ${{ matrix.attr }}
159+
127160
run-tests:
128-
needs: build-checks
161+
needs: [build-checks-aarch64-linux, build-checks-aarch64-darwin] #, build-checks-x86_64-linux]
129162
if: |
130163
!cancelled() &&
131-
(needs.build-checks.result == 'skipped' || needs.build-checks.result == 'success')
164+
(needs.build-checks-aarch64-linux.result == 'skipped' || needs.build-checks-aarch64-linux.result == 'success') &&
165+
(needs.build-checks-aarch64-darwin.result == 'skipped' || needs.build-checks-aarch64-darwin.result == 'success')
132166
uses: ./.github/workflows/test.yml

scripts/github-matrix.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ def run_nix_eval_jobs(
144144
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True
145145
) as process:
146146
drv_paths = set()
147-
148147
for line in process.stdout:
149148
package = parse_nix_eval_line(line, drv_paths, target)
150149
if package:
@@ -235,18 +234,15 @@ def clean_package_for_output(pkg: GitHubActionPackage) -> dict:
235234
if is_extension_pkg(pkg) and not pkg["already_cached"]
236235
]
237236

238-
# Group packages by system
239-
grouped_by_system = defaultdict(list)
240-
for pkg in gh_action_packages:
241-
grouped_by_system[pkg["system"]].append(clean_package_for_output(pkg))
237+
# Group packages by system
238+
grouped_by_system = defaultdict(list)
239+
for pkg in gh_action_packages:
240+
grouped_by_system[pkg["system"]].append(clean_package_for_output(pkg))
242241

243-
# Create output with system-specific matrices
244-
gh_output = {}
245-
for system, packages in grouped_by_system.items():
246-
gh_output[system.replace("-", "_")] = {"include": packages}
247-
else:
248-
cleaned_packages = [clean_package_for_output(pkg) for pkg in gh_action_packages]
249-
gh_output = {"include": cleaned_packages}
242+
# Create output with system-specific matrices
243+
gh_output = {}
244+
for system, packages in grouped_by_system.items():
245+
gh_output[system.replace("-", "_")] = {"include": packages}
250246

251247
print(
252248
f"debug: Generated GitHub Actions matrix: {json.dumps(gh_output, indent=2)}",

0 commit comments

Comments
 (0)