Skip to content

Commit ed9415b

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 dc80fb9 commit ed9415b

File tree

2 files changed

+58
-20
lines changed

2 files changed

+58
-20
lines changed

.github/workflows/nix-build.yml

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787
checks-matrix:
8888
needs: [build-extensions-aarch64-linux, build-extensions-aarch64-darwin] #, build-extensions-x86_64-linux]
8989
if: |
90-
!cancelled() &&
90+
!cancelled() &&
9191
(needs.build-extensions-aarch64-linux.result == 'skipped' || needs.build-extensions-aarch64-linux.result == 'success') &&
9292
(needs.build-extensions-aarch64-darwin.result == 'skipped' || needs.build-extensions-aarch64-darwin.result == 'success')
9393
runs-on:
@@ -105,17 +105,40 @@ 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: |
113+
!cancelled() &&
114+
${{ fromJSON(needs.checks-matrix.outputs.matrix).aarch64_linux != null }} &&
115+
(needs.build-extensions-aarch64-linux.result == 'skipped' || needs.build-extensions-aarch64-linux.result == 'success') &&
116+
(needs.build-extensions-aarch64-darwin.result == 'skipped' || needs.build-extensions-aarch64-darwin.result == 'success')
117+
strategy:
118+
fail-fast: false
119+
max-parallel: 5
120+
matrix: ${{ fromJSON(needs.checks-matrix.outputs.matrix).aarch64_linux }}
121+
steps:
122+
- name: Checkout Repo
123+
uses: actions/checkout@v4
124+
- name: Build Nix Package
125+
uses: ./.github/actions/nix-build-setup
126+
with:
127+
attr: ${{ matrix.attr }}
108128

109-
build-checks:
110-
name: ${{ matrix.name }} (${{ matrix.system }})
111-
needs: [checks-matrix]
129+
build-checks-aarch64-darwin:
130+
name: ${{matrix.postgresql_version}}.${{ matrix.name }} (aarch64-darwin)
131+
needs: checks-matrix
112132
runs-on: ${{ matrix.runs_on.group && matrix.runs_on || matrix.runs_on.labels }}
113133
if: |
114134
!cancelled() &&
115-
(needs.checks-matrix.result == 'skipped' || needs.checks-matrix.result == 'success')
135+
${{ fromJSON(needs.checks-matrix.outputs.matrix).aarch64_darwin != null }} &&
136+
(needs.build-extensions-aarch64-linux.result == 'skipped' || needs.build-extensions-aarch64-linux.result == 'success') &&
137+
(needs.build-extensions-aarch64-darwin.result == 'skipped' || needs.build-extensions-aarch64-darwin.result == 'success')
116138
strategy:
117139
fail-fast: false
118-
matrix: ${{fromJSON(needs.checks-matrix.outputs.matrix)}}
140+
max-parallel: 5
141+
matrix: ${{ fromJSON(needs.checks-matrix.outputs.matrix).aarch64_darwin }}
119142
steps:
120143
- name: Checkout Repo
121144
uses: actions/checkout@v4
@@ -124,9 +147,28 @@ jobs:
124147
with:
125148
attr: ${{ matrix.attr }}
126149

150+
# TODO
151+
# build-checks-x86_64-linux:
152+
# name: ${{matrix.postgresql_version}}.${{ matrix.name }} (x86_64-linux)
153+
# needs: checks-matrix
154+
# runs-on: ${{ matrix.runs_on.group && matrix.runs_on || matrix.runs_on.labels }}
155+
# if: ${{ fromJSON(needs.checks-matrix.outputs.matrix).x86_64_linux != null }}
156+
# strategy:
157+
# fail-fast: false
158+
# max-parallel: 5
159+
# matrix: ${{ fromJSON(needs.checks-matrix.outputs.matrix).x86_64_linux }}
160+
# steps:
161+
# - name: Checkout Repo
162+
# uses: actions/checkout@v4
163+
# - name: Build Nix Package
164+
# uses: ./.github/actions/nix-build-setup
165+
# with:
166+
# attr: ${{ matrix.attr }}
167+
127168
run-tests:
128-
needs: build-checks
169+
needs: [build-checks-aarch64-linux, build-checks-aarch64-darwin] #, build-checks-x86_64-linux]
129170
if: |
130171
!cancelled() &&
131-
(needs.build-checks.result == 'skipped' || needs.build-checks.result == 'success')
172+
(needs.build-checks-aarch64-linux.result == 'skipped' || needs.build-checks-aarch64-linux.result == 'success') &&
173+
(needs.build-checks-aarch64-darwin.result == 'skipped' || needs.build-checks-aarch64-darwin.result == 'success')
132174
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)