Skip to content

Commit 9d41b1e

Browse files
committed
fix(ci): do not hide cached builds
1 parent 3b6cb7f commit 9d41b1e

File tree

4 files changed

+34
-12
lines changed

4 files changed

+34
-12
lines changed

.github/actions/nix-build-setup/action.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,23 @@ inputs:
88
description: 'AWS role session duration in seconds'
99
required: false
1010
default: '3600'
11+
cached:
12+
description: 'Whether to use cached builds'
13+
required: false
14+
default: 'false'
1115

1216
runs:
1317
using: 'composite'
1418
steps:
1519
- name: aws-oidc
20+
if: ${{ inputs.cached == 'false' }}
1621
uses: aws-actions/[email protected]
1722
with:
1823
aws-region: us-east-2
1924
role-to-assume: arn:aws:iam::279559813984:role/supabase-github-oidc-role # Shared Services
2025
role-session-name: gha-oidc-${{ github.run_id }}
2126
- name: aws-creds
27+
if: ${{ inputs.cached == 'false' }}
2228
uses: aws-actions/[email protected]
2329
with:
2430
disable-retry: true
@@ -29,6 +35,7 @@ runs:
2935
role-skip-session-tagging: true
3036
role-duration-seconds: ${{ inputs.aws-role-duration }}
3137
- name: Write creds files
38+
if: ${{ inputs.cached == 'false' }}
3239
shell: bash
3340
run: |
3441
umask 006
@@ -39,5 +46,10 @@ runs:
3946
aws_session_token = ${AWS_SESSION_TOKEN}
4047
EOF
4148
- name: nix build
49+
if: ${{ inputs.cached == 'false' }}
4250
shell: bash
4351
run: nix build -L .#${{ inputs.attr }}
52+
- name: nix build
53+
if: ${{ inputs.cached == 'true' }}
54+
shell: bash
55+
run: echo "Skipping build of ${{ inputs.attr }} as it's marked cached"

.github/workflows/nix-build.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ jobs:
3030
run: |
3131
set -Eeu
3232
echo matrix="$(python scripts/github-matrix.py extensions)" >> "$GITHUB_OUTPUT"
33-
# XXX debugging
34-
exit 1
3533
3634
build-extensions-aarch64-linux:
3735
name: ${{matrix.postgresql_version}}.${{ matrix.name }} (aarch64-linux)
@@ -49,6 +47,7 @@ jobs:
4947
uses: ./.github/actions/nix-build-setup
5048
with:
5149
attr: ${{ matrix.attr }}
50+
cached: ${{ matrix.is_cached }}
5251

5352
build-extensions-aarch64-darwin:
5453
name: ${{matrix.postgresql_version}}.${{ matrix.name }} (aarch64-darwin)
@@ -66,6 +65,7 @@ jobs:
6665
uses: ./.github/actions/nix-build-setup
6766
with:
6867
attr: ${{ matrix.attr }}
68+
cached: ${{ matrix.is_cached }}
6969

7070
build-extensions-x86_64-linux:
7171
name: ${{matrix.postgresql_version}}.${{ matrix.name }} (x86_64-linux)
@@ -83,6 +83,7 @@ jobs:
8383
uses: ./.github/actions/nix-build-setup
8484
with:
8585
attr: ${{ matrix.attr }}
86+
cached: ${{ matrix.is_cached }}
8687

8788

8889
checks-matrix:
@@ -117,6 +118,7 @@ jobs:
117118
uses: ./.github/actions/nix-build-setup
118119
with:
119120
attr: ${{ matrix.attr }}
121+
cached: ${{ matrix.is_cached }}
120122

121123
run-tests:
122124
needs: build-checks

nix/packages/postgres.nix

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,12 @@
158158
# install.
159159
# - exts: an attrset containing all the extensions, mapped to their
160160
# package names.
161-
makePostgres = version: lib.recurseIntoAttrs {
162-
bin = makePostgresBin version;
163-
exts = makeOurPostgresPkgsSet version;
164-
};
161+
makePostgres =
162+
version:
163+
lib.recurseIntoAttrs {
164+
bin = makePostgresBin version;
165+
exts = makeOurPostgresPkgsSet version;
166+
};
165167
basePackages = {
166168
psql_15 = makePostgres "15";
167169
psql_17 = makePostgres "17";

scripts/github-matrix.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class GitHubActionPackage(TypedDict):
4646
attr: str
4747
name: str
4848
system: str
49-
already_cached: bool
49+
is_cached: bool
5050
runs_on: RunsOnConfig
5151
postgresql_version: NotRequired[str]
5252

@@ -103,17 +103,21 @@ def parse_nix_eval_line(
103103
try:
104104
data: NixEvalJobsOutput = json.loads(line)
105105
if data["drvPath"] in drv_paths:
106-
return None
107-
drv_paths.add(data["drvPath"])
106+
print(f"Skipping duplicate drvPath: {data['drvPath']}", file=sys.stderr)
107+
data["cacheStatus"] = "cached"
108+
else:
109+
drv_paths.add(data["drvPath"])
108110

109111
runs_on_config = BUILD_RUNNER_MAP[data["system"]]
110112

111113
return {
112114
"attr": f"{target}.{data['attr']}",
113115
"name": data["name"],
114116
"system": data["system"],
115-
"already_cached": data.get("cacheStatus") != "notBuilt",
117+
"is_cached": data.get("cacheStatus") != "notBuilt",
116118
"runs_on": runs_on_config,
119+
"drvPath": data["drvPath"], # For debugging purposes
120+
"outputs": data.get("outputs", {}), # For debugging purposes
117121
}
118122
except json.JSONDecodeError:
119123
print(f"Skipping invalid JSON line: {line}", file=sys.stderr)
@@ -133,8 +137,7 @@ def run_nix_eval_jobs(
133137

134138
for line in process.stdout:
135139
package = parse_nix_eval_line(line, drv_paths, target)
136-
if package and not package["already_cached"]:
137-
print(f"Found package: {package['attr']}", file=sys.stderr)
140+
if package:
138141
yield package
139142

140143
if process.returncode and process.returncode != 0:
@@ -186,6 +189,9 @@ def main() -> None:
186189
grouped_by_system[system] = []
187190
grouped_by_system[system].append(pkg)
188191

192+
print("Grouped packages by system:", file=sys.stderr)
193+
print(json.dumps(grouped_by_system, indent=2), file=sys.stderr)
194+
189195
# Create output with system-specific matrices
190196
gh_output = {}
191197
for system, packages in grouped_by_system.items():

0 commit comments

Comments
 (0)