Skip to content

Commit 87c4039

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 87c4039

File tree

2 files changed

+53
-19
lines changed

2 files changed

+53
-19
lines changed

.github/workflows/nix-build.yml

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,36 @@ 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+
strategy:
116+
fail-fast: false
117+
max-parallel: 5
118+
matrix: ${{ fromJSON(needs.checks-matrix.outputs.matrix).aarch64_linux }}
119+
steps:
120+
- name: Checkout Repo
121+
uses: actions/checkout@v4
122+
- name: Build Nix Package
123+
uses: ./.github/actions/nix-build-setup
124+
with:
125+
attr: ${{ matrix.attr }}
108126

109-
build-checks:
110-
name: ${{ matrix.name }} (${{ matrix.system }})
111-
needs: [checks-matrix]
127+
build-checks-aarch64-darwin:
128+
name: ${{matrix.postgresql_version}}.${{ matrix.name }} (aarch64-darwin)
129+
needs: checks-matrix
112130
runs-on: ${{ matrix.runs_on.group && matrix.runs_on || matrix.runs_on.labels }}
113131
if: |
114132
!cancelled() &&
115-
(needs.checks-matrix.result == 'skipped' || needs.checks-matrix.result == 'success')
133+
${{ fromJSON(needs.checks-matrix.outputs.matrix).aarch64_darwin != null }}
116134
strategy:
117135
fail-fast: false
118-
matrix: ${{fromJSON(needs.checks-matrix.outputs.matrix)}}
136+
max-parallel: 5
137+
matrix: ${{ fromJSON(needs.checks-matrix.outputs.matrix).aarch64_darwin }}
119138
steps:
120139
- name: Checkout Repo
121140
uses: actions/checkout@v4
@@ -124,9 +143,28 @@ jobs:
124143
with:
125144
attr: ${{ matrix.attr }}
126145

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