Skip to content

Commit 8df2d29

Browse files
authored
fix(ci): declare shallow base repositories to Nix (#16)
1 parent b2e2598 commit 8df2d29

4 files changed

Lines changed: 16 additions & 3 deletions

File tree

‎README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ check, rather than maintaining a second CI allowlist. This follows the
143143

144144
On pull requests and merge groups, `actions/flake-checks` compares every current
145145
check derivation with the event's base commit. The action performs a bounded
146-
fetch when a shallow checkout does not contain that commit. It skips a build only
146+
fetch when a shallow checkout does not contain that commit and marks its local
147+
Git flake URL as shallow for Nix evaluation. It skips a build only
147148
when both derivation paths are identical. New checks, changed checks, unavailable
148149
history, and base evaluation failures retain the conservative full-build
149150
behavior. The optional `base-revision` input overrides event discovery for manual

‎scripts/run-flake-checks.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ def available() -> bool:
7373
["git", "rev-parse", "--show-toplevel"], text=True
7474
).strip()
7575
return (
76-
"git+" + Path(root).resolve().as_uri() + "?submodules=1&rev=" + revision.lower()
76+
"git+"
77+
+ Path(root).resolve().as_uri()
78+
+ "?shallow=1&submodules=1&rev="
79+
+ revision.lower()
7780
)
7881

7982

‎scripts/test-nix-attribute-selection.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@
5959
base_revision = subprocess.check_output(
6060
["git", "rev-parse", "HEAD"], text=True
6161
).strip()
62+
shallow_file = Path(
63+
subprocess.check_output(
64+
["git", "rev-parse", "--git-path", "shallow"], text=True
65+
).strip()
66+
)
67+
shallow_file.write_text(base_revision + "\n")
6268
base_source = checks.resolve_base_source(base_revision)
6369

6470
paths = [checks.check_derivation(system, name) for name in names]

‎tests/test_flake_checks.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ def test_fetches_a_missing_base_revision(self, run_command, check_output):
9898

9999
source = FLAKE_CHECKS.resolve_base_source("a" * 40)
100100

101-
self.assertEqual(source, "git+file:///repo?submodules=1&rev=" + "a" * 40)
101+
self.assertEqual(
102+
source,
103+
"git+file:///repo?shallow=1&submodules=1&rev=" + "a" * 40,
104+
)
102105
self.assertEqual(
103106
run_command.call_args_list[1].args[0],
104107
["git", "fetch", "--no-tags", "--depth=1", "origin", "a" * 40],

0 commit comments

Comments
 (0)