Skip to content

Commit be08160

Browse files
authored
Merge pull request #4 from AztecProtocol/fix/node-version
fix: remove mismatched repo configs, add gregoswap and demo-wallet
2 parents dda53f7 + e77f4c9 commit be08160

4 files changed

Lines changed: 138 additions & 20 deletions

File tree

src/repos/config.ts

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ export interface RepoConfig {
2222
code?: string[];
2323
docs?: string[];
2424
};
25+
/** Override specific sparse paths to come from a different branch instead of the tag */
26+
sparsePathOverrides?: { paths: string[]; branch: string }[];
2527
}
2628

2729
/** Default Aztec version (tag) to use - can be overridden via AZTEC_DEFAULT_VERSION env var */
28-
export const DEFAULT_AZTEC_VERSION = process.env.AZTEC_DEFAULT_VERSION || "v3.0.0-devnet.6-patch.1";
30+
export const DEFAULT_AZTEC_VERSION = process.env.AZTEC_DEFAULT_VERSION || "v4.0.0-devnet.2-patch.1";
2931

3032
/**
3133
* Base Aztec repository configurations (without version)
@@ -35,14 +37,24 @@ const BASE_REPOS: Omit<RepoConfig, "tag">[] = [
3537
name: "aztec-packages",
3638
url: "https://github.com/AztecProtocol/aztec-packages",
3739
sparse: [
38-
"docs/docs",
40+
"docs",
3941
"noir-projects/aztec-nr",
4042
"noir-projects/noir-contracts",
4143
"yarn-project",
4244
"barretenberg/ts/src",
4345
"boxes",
4446
"playground",
4547
],
48+
sparsePathOverrides: [
49+
{
50+
paths: [
51+
"docs/developer_versioned_docs/version-{version}",
52+
"docs/static/aztec-nr-api/devnet",
53+
"docs/static/typescript-api/devnet",
54+
],
55+
branch: "next",
56+
},
57+
],
4658
description: "Main Aztec monorepo - documentation, aztec-nr framework, and reference contracts",
4759
searchPatterns: {
4860
code: ["*.nr", "*.ts"],
@@ -93,25 +105,23 @@ const BASE_REPOS: Omit<RepoConfig, "tag">[] = [
93105
},
94106
},
95107
{
96-
name: "aztec-otc-desk",
97-
url: "https://github.com/aztec-pioneers/aztec-otc-desk",
98-
branch: "main",
99-
description: "Aztec OTC desk for peer-to-peer trading on Aztec",
108+
name: "demo-wallet",
109+
url: "https://github.com/AztecProtocol/demo-wallet",
110+
description: "Aztec demo wallet application",
100111
searchPatterns: {
101112
code: ["*.nr", "*.ts"],
102113
docs: ["*.md"],
103114
},
104115
},
105116
{
106-
name: "aztec-pay",
107-
url: "https://github.com/aztec-pioneers/aztec-pay",
108-
branch: "main",
109-
description: "Aztec Pay - payment solution built on Aztec",
117+
name: "gregoswap",
118+
url: "https://github.com/AztecProtocol/gregoswap",
119+
description: "Gregoswap - token swap application built on Aztec",
110120
searchPatterns: {
111121
code: ["*.nr", "*.ts"],
112122
docs: ["*.md"],
113123
},
114-
},
124+
}
115125
];
116126

117127
/**
@@ -125,6 +135,11 @@ export function getAztecRepos(version?: string): RepoConfig[] {
125135
...repo,
126136
// Only apply version tag to Aztec repos, not Noir repos
127137
tag: repo.url.includes("AztecProtocol") ? tag : undefined,
138+
// Resolve {version} placeholders in sparse path overrides
139+
sparsePathOverrides: repo.sparsePathOverrides?.map((override) => ({
140+
...override,
141+
paths: override.paths.map((p) => p.replace("{version}", tag)),
142+
})),
128143
}));
129144
}
130145

src/utils/git.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,24 @@ export async function cloneRepo(
9090
await repoGit.raw(["sparse-checkout", "set", ...config.sparse]);
9191
await repoGit.fetch(["--depth=1", "origin", `refs/tags/${config.tag}:refs/tags/${config.tag}`]);
9292
await repoGit.checkout(config.tag);
93+
94+
// Apply sparse path overrides from different branches
95+
if (config.sparsePathOverrides) {
96+
for (const override of config.sparsePathOverrides) {
97+
await repoGit.fetch(["--depth=1", "origin", override.branch]);
98+
try {
99+
await repoGit.checkout([`origin/${override.branch}`, "--", ...override.paths]);
100+
} catch (error) {
101+
const repoBase = config.url.replace(/\.git$/, "");
102+
const parentDirs = [...new Set(override.paths.map((p) => p.split("/").slice(0, -1).join("/")))];
103+
const browseLinks = parentDirs.map((d) => `${repoBase}/tree/${override.branch}/${d}`);
104+
throw new Error(
105+
`sparsePathOverrides failed for branch "${override.branch}": could not checkout paths [${override.paths.join(", ")}]. ` +
106+
`Check the actual folder names at: ${browseLinks.join(" , ")}`,
107+
);
108+
}
109+
}
110+
}
93111
} else {
94112
await git.clone(config.url, repoPath, [
95113
"--filter=blob:none",

tests/repos/config.test.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ describe("AZTEC_REPOS", () => {
2626
expect(noir!.sparse!.length).toBeGreaterThan(0);
2727
});
2828

29+
it("aztec-packages has sparsePathOverrides for docs/docs on next branch", () => {
30+
const ap = AZTEC_REPOS.find((r) => r.name === "aztec-packages");
31+
expect(ap?.sparse).toContain("docs");
32+
expect(ap?.sparsePathOverrides).toEqual([
33+
{
34+
paths: [
35+
`docs/developer_versioned_docs/version-${DEFAULT_AZTEC_VERSION}`,
36+
"docs/static/aztec-nr-api/devnet",
37+
"docs/static/typescript-api/devnet",
38+
],
39+
branch: "next",
40+
},
41+
]);
42+
});
43+
2944
it('noir and noir-examples have branch: "master"', () => {
3045
const noir = AZTEC_REPOS.find((r) => r.name === "noir");
3146
const noirExamples = AZTEC_REPOS.find((r) => r.name === "noir-examples");
@@ -44,7 +59,7 @@ describe("getAztecRepos", () => {
4459
(r) => !r.url.includes("AztecProtocol")
4560
);
4661

47-
expect(aztecProtocolRepos).toHaveLength(3);
62+
expect(aztecProtocolRepos).toHaveLength(5);
4863
for (const repo of aztecProtocolRepos) {
4964
expect(repo.tag).toBe(DEFAULT_AZTEC_VERSION);
5065
}
@@ -64,17 +79,13 @@ describe("getAztecRepos", () => {
6479
}
6580
});
6681

67-
it("does not apply tags to noir-lang or aztec-pioneers repos", () => {
82+
it("does not apply tags to noir-lang repos", () => {
6883
const repos = getAztecRepos("v2.0.0");
6984
const noirRepos = repos.filter((r) => r.url.includes("noir-lang"));
70-
const pioneerRepos = repos.filter((r) =>
71-
r.url.includes("aztec-pioneers")
72-
);
7385

7486
expect(noirRepos).toHaveLength(2);
75-
expect(pioneerRepos).toHaveLength(2);
7687

77-
for (const repo of [...noirRepos, ...pioneerRepos]) {
88+
for (const repo of noirRepos) {
7889
expect(repo.tag).toBeUndefined();
7990
}
8091
});
@@ -102,7 +113,7 @@ describe("getRepoNames", () => {
102113
expect(names).toContain("noir-examples");
103114
expect(names).toContain("aztec-examples");
104115
expect(names).toContain("aztec-starter");
105-
expect(names).toContain("aztec-otc-desk");
106-
expect(names).toContain("aztec-pay");
116+
expect(names).toContain("demo-wallet");
117+
expect(names).toContain("gregoswap");
107118
});
108119
});

tests/utils/git.test.ts

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,80 @@ describe("cloneRepo", () => {
146146
expect(mockGitInstance.checkout).toHaveBeenCalledWith("v1.0.0");
147147
});
148148

149+
it("sparse + tag + sparsePathOverrides: fetches override branch and checks out paths", async () => {
150+
const overrideConfig: RepoConfig = {
151+
...sparseConfig,
152+
sparsePathOverrides: [
153+
{
154+
paths: [
155+
"docs/developer_versioned_docs/version-v1.0.0",
156+
"docs/static/api",
157+
],
158+
branch: "next",
159+
},
160+
],
161+
};
162+
mockExistsSync.mockReturnValue(false);
163+
mockGitInstance.clone.mockResolvedValue(undefined);
164+
mockGitInstance.raw.mockResolvedValue(undefined);
165+
mockGitInstance.fetch.mockResolvedValue(undefined);
166+
mockGitInstance.checkout.mockResolvedValue(undefined);
167+
168+
const result = await cloneRepo(overrideConfig);
169+
expect(result).toContain("Cloned aztec-packages");
170+
171+
// Normal tag checkout happens first
172+
expect(mockGitInstance.checkout).toHaveBeenCalledWith("v1.0.0");
173+
174+
// Then override: fetch the branch and checkout paths from it
175+
expect(mockGitInstance.fetch).toHaveBeenCalledWith([
176+
"--depth=1",
177+
"origin",
178+
"next",
179+
]);
180+
expect(mockGitInstance.checkout).toHaveBeenCalledWith([
181+
"origin/next",
182+
"--",
183+
"docs/developer_versioned_docs/version-v1.0.0",
184+
"docs/static/api",
185+
]);
186+
});
187+
188+
it("sparse + tag + sparsePathOverrides: throws descriptive error with GitHub links on failure", async () => {
189+
const overrideConfig: RepoConfig = {
190+
...sparseConfig,
191+
sparsePathOverrides: [
192+
{
193+
paths: [
194+
"docs/developer_versioned_docs/version-v1.0.0",
195+
"docs/static/aztec-nr-api/devnet",
196+
"docs/static/typescript-api/devnet",
197+
],
198+
branch: "next",
199+
},
200+
],
201+
};
202+
mockExistsSync.mockReturnValue(false);
203+
mockGitInstance.clone.mockResolvedValue(undefined);
204+
mockGitInstance.raw.mockResolvedValue(undefined);
205+
mockGitInstance.fetch.mockResolvedValue(undefined);
206+
// Tag checkout succeeds, override checkout fails
207+
mockGitInstance.checkout
208+
.mockResolvedValueOnce(undefined) // tag checkout
209+
.mockRejectedValueOnce(new Error("pathspec did not match"));
210+
211+
try {
212+
await cloneRepo(overrideConfig);
213+
expect.unreachable("should have thrown");
214+
} catch (e: any) {
215+
expect(e.message).toMatch(/sparsePathOverrides failed for branch "next"/);
216+
expect(e.message).toContain("docs/developer_versioned_docs/version-v1.0.0");
217+
expect(e.message).toContain("https://github.com/AztecProtocol/aztec-packages/tree/next/docs/developer_versioned_docs");
218+
expect(e.message).toContain("https://github.com/AztecProtocol/aztec-packages/tree/next/docs/static/aztec-nr-api");
219+
expect(e.message).toContain("https://github.com/AztecProtocol/aztec-packages/tree/next/docs/static/typescript-api");
220+
}
221+
});
222+
149223
it("sparse + commit: clones with sparse flags, fetches commit", async () => {
150224
const commitConfig: RepoConfig = {
151225
...sparseConfig,

0 commit comments

Comments
 (0)