Skip to content

Commit bc95d1b

Browse files
authored
refactor(releases): move git metadata from builds to releases (#1555)
* refactor(packages): move build metadata from builds to releases - Update schema to move branch_name, commit_message, and commit_author from PackageBuild to PackageRelease - Update UI components to use release metadata instead of build metadata - Fix route paths to use "releases" instead of "release" - Remove mock package builds data - Set default sidebar state to collapsed in preview page * feat(sidebar): add GitHub connection option for package owners - Introduced a new UI element for package owners to connect their GitHub repository if not already linked. - Updated the sidebar to conditionally render the GitHub connection option with an icon and a button. - Refactored the logic for displaying the GitHub repository link. * refactor(releases): move git metadata from builds to releases Update PackageReleasesDashboard to use release branch info instead of build Remove branch_name, commit_message, and commit_author from package build mapping Add these fields to package release mapping instead Update related tests to reflect these changes
1 parent 818e2a0 commit bc95d1b

18 files changed

Lines changed: 142 additions & 255 deletions

File tree

bun-tests/fake-snippets-api/routes/package_builds/get.test.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ test("GET /api/package_builds/get - returns 403 for unauthorized package build a
7171
build_error_last_updated_at: new Date().toISOString(),
7272
build_logs: null,
7373
preview_url: "https://preview.tscircuit.com/pb_test",
74-
branch_name: "main",
75-
commit_message: "Test build",
76-
commit_author: "jane.doe",
7774
})
7875

7976
const res = await axios.get(
@@ -126,9 +123,6 @@ test("GET /api/package_builds/get - successfully returns package build with logs
126123
).toISOString(),
127124
build_logs: buildLogs.join(" "),
128125
preview_url: "https://preview.tscircuit.com/pb_1a2b3c4d",
129-
branch_name: "main",
130-
commit_message: "Add new LED component with improved brightness control",
131-
commit_author: "john.doe",
132126
})
133127

134128
const res = await axios.get(
@@ -174,9 +168,6 @@ test("GET /api/package_builds/get - returns package build without logs when incl
174168
build_error_last_updated_at: new Date().toISOString(),
175169
build_logs: "Some build logs",
176170
preview_url: "https://preview.tscircuit.com/pb_test",
177-
branch_name: "main",
178-
commit_message: "Test build",
179-
commit_author: "john.doe",
180171
})
181172

182173
const res = await axios.get(
@@ -222,9 +213,6 @@ test("GET /api/package_builds/get - handles build with errors", async () => {
222213
build_error_last_updated_at: new Date().toISOString(),
223214
build_logs: null,
224215
preview_url: null,
225-
branch_name: "feature/new-component",
226-
commit_message: "Add broken component",
227-
commit_author: "john.doe",
228216
})
229217

230218
const res = await axios.get(
@@ -274,9 +262,6 @@ test("GET /api/package_builds/get - handles build in progress", async () => {
274262
build_error_last_updated_at: new Date().toISOString(),
275263
build_logs: null,
276264
preview_url: null,
277-
branch_name: "main",
278-
commit_message: "Building in progress",
279-
commit_author: "john.doe",
280265
})
281266

282267
const res = await axios.get(

bun-tests/fake-snippets-api/routes/package_builds/list.test.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,6 @@ test("GET /api/package_builds/list - returns created builds", async () => {
125125
).toISOString(),
126126
build_logs: null,
127127
preview_url: "https://preview.tscircuit.com/pb_1a2b3c4d",
128-
branch_name: "main",
129-
commit_message: "Add new LED component with improved brightness control",
130-
commit_author: "john.doe",
131128
})
132129

133130
const res = await axios.get(
@@ -175,9 +172,6 @@ test("GET /api/package_builds/list - sorts builds by created_at descending", asy
175172
).toISOString(),
176173
build_logs: null,
177174
preview_url: "https://preview.tscircuit.com/pb_1",
178-
branch_name: "main",
179-
commit_message: "First build",
180-
commit_author: "john.doe",
181175
})
182176

183177
db.addPackageBuild({
@@ -210,9 +204,6 @@ test("GET /api/package_builds/list - sorts builds by created_at descending", asy
210204
).toISOString(),
211205
build_logs: null,
212206
preview_url: "https://preview.tscircuit.com/pb_2",
213-
branch_name: "main",
214-
commit_message: "Second build",
215-
commit_author: "john.doe",
216207
})
217208

218209
const res = await axios.get(
@@ -286,9 +277,6 @@ test("GET /api/package_builds/list - returns created builds with logs or not", a
286277
).toISOString(),
287278
build_logs: buildLogs.join(" "),
288279
preview_url: "https://preview.tscircuit.com/pb_1a2b3c4d",
289-
branch_name: "main",
290-
commit_message: "Add new LED component with improved brightness control",
291-
commit_author: "john.doe",
292280
})
293281

294282
const resWithoutLogs = await axios.get(

fake-snippets-api/lib/db/db-client.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,13 @@ const initializer = combine(databaseSchema.parse({}), (set, get) => ({
242242
snippet: Omit<
243243
z.input<typeof snippetSchema>,
244244
"snippet_id" | "package_release_id"
245-
> & { creator_account_id?: string; github_repo_full_name?: string },
245+
> & {
246+
creator_account_id?: string
247+
github_repo_full_name?: string
248+
branch_name?: string
249+
commit_message?: string
250+
commit_author?: string
251+
},
246252
): Snippet => {
247253
const timestamp = Date.now()
248254
const currentTime = new Date(timestamp).toISOString()
@@ -291,6 +297,9 @@ const initializer = combine(databaseSchema.parse({}), (set, get) => ({
291297
is_locked: false,
292298
created_at: currentTime,
293299
updated_at: currentTime,
300+
branch_name: snippet.branch_name,
301+
commit_message: snippet.commit_message,
302+
commit_author: snippet.commit_author,
294303
has_transpiled: true,
295304
transpilation_error: null,
296305
...(snippet.name == "testuser/my-test-board"

fake-snippets-api/lib/db/schema.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@ export const packageReleaseSchema = z.object({
258258

259259
// Latest Build Reference
260260
latest_package_build_id: z.string().nullable().optional(),
261+
branch_name: z.string().nullable().optional(),
262+
commit_message: z.string().nullable().optional(),
263+
commit_author: z.string().nullable().optional(),
261264
})
262265
export type PackageRelease = z.infer<typeof packageReleaseSchema>
263266

@@ -370,9 +373,6 @@ export const packageBuildSchema = z.object({
370373
build_error_last_updated_at: z.string().datetime(),
371374
preview_url: z.string().nullable().optional(),
372375
build_logs: z.string().nullable().optional(),
373-
branch_name: z.string().nullable().optional(),
374-
commit_message: z.string().nullable().optional(),
375-
commit_author: z.string().nullable().optional(),
376376
})
377377
export type PackageBuild = z.infer<typeof packageBuildSchema>
378378

fake-snippets-api/lib/db/seed.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ export const seed = (db: DbClient) => {
3131
unscoped_name: "my-test-board",
3232
github_repo_full_name: "testuser/my-test-board",
3333
owner_name: "testuser",
34+
branch_name: "main",
35+
commit_message: "Attempted build of a555timer-square-wave package",
36+
commit_author: "testuser",
3437
creator_account_id: account_id,
3538
code: `
3639
import { A555Timer } from "@tsci/seveibar.a555timer"
@@ -570,9 +573,6 @@ export default () => (
570573
"3. Code compilation - FAILED\n" +
571574
"Error: Invalid syntax in component declaration\n" +
572575
"Build terminated with errors",
573-
branch_name: "main",
574-
commit_message: "Attempted build of a555timer-square-wave package",
575-
commit_author: "testuser",
576576
})
577577

578578
// Update the package release with the latest build ID
@@ -1116,6 +1116,9 @@ exports.A555Timer = A555Timer;
11161116
name: "testuser/a555timer-square-wave",
11171117
unscoped_name: "a555timer-square-wave",
11181118
owner_name: "testuser",
1119+
branch_name: "main",
1120+
commit_message: "Attempted build of a555timer-square-wave package",
1121+
commit_author: "testuser",
11191122
creator_account_id: account_id,
11201123
code: `
11211124
import { A555Timer } from "@tsci/seveibar.a555timer"
@@ -1659,9 +1662,6 @@ export const SquareWaveModule = () => (
16591662
"3. Code compilation - FAILED\n" +
16601663
"Error: Invalid syntax in component declaration\n" +
16611664
"Build terminated with errors",
1662-
branch_name: "main",
1663-
commit_message: "Attempted build of a555timer-square-wave package",
1664-
commit_author: "testuser",
16651665
})
16661666

16671667
// Add successful build
@@ -1704,9 +1704,6 @@ export const SquareWaveModule = () => (
17041704
"4. Circuit validation - OK\n" +
17051705
"5. Package assembly - OK\n" +
17061706
"Build completed successfully",
1707-
branch_name: "main",
1708-
commit_message: "Initial build of a555timer-square-wave package",
1709-
commit_author: "testuser",
17101707
})
17111708

17121709
// Update the package release with the latest (successful) build ID

fake-snippets-api/lib/public-mapping/public-map-package-build.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ export const publicMapPackageBuild = (
3232
internalPackageBuild.build_error_last_updated_at,
3333
preview_url: internalPackageBuild.preview_url,
3434
build_logs: options.include_logs ? internalPackageBuild.build_logs : null,
35-
branch_name: internalPackageBuild.branch_name,
36-
commit_message: internalPackageBuild.commit_message,
37-
commit_author: internalPackageBuild.commit_author,
3835
}
3936

4037
return result

fake-snippets-api/lib/public-mapping/public-map-package-release.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ export const publicMapPackageRelease = (
2626
: [],
2727
is_pr_preview: Boolean(internal_package_release.is_pr_preview),
2828
github_pr_number: internal_package_release.github_pr_number,
29+
branch_name: internal_package_release.branch_name,
30+
commit_message: internal_package_release.commit_message ?? null,
31+
commit_author: internal_package_release.commit_author ?? null,
2932
}
3033

3134
if (options.include_ai_review && options.db) {

src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,11 @@ function App() {
262262
<Route path="/dev-login" component={DevLoginPage} />
263263
<Route path="/:username" component={UserProfilePage} />
264264
<Route
265-
path="/:author/:packageName/release/:releaseId/builds"
265+
path="/:author/:packageName/releases/:releaseId/builds"
266266
component={ReleaseBuildsPage}
267267
/>
268268
<Route
269-
path="/:author/:packageName/release/:releaseId"
269+
path="/:author/:packageName/releases/:releaseId"
270270
component={ReleaseDetailPage}
271271
/>
272272
<Route

src/components/PackageBreadcrumb.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export function PackageBreadcrumb({
7777
{currentPage === "builds" ? (
7878
<BreadcrumbLink asChild>
7979
<PrefetchPageLink
80-
href={`/${packageName}/release/${releaseVersion}`}
80+
href={`/${packageName}/releases/${releaseVersion}`}
8181
>
8282
{releaseVersion}
8383
</PrefetchPageLink>

src/components/ViewPackagePage/components/sidebar-about-section.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Badge } from "@/components/ui/badge"
2-
import { GitFork, Star, Settings, LinkIcon, Github } from "lucide-react"
2+
import { GitFork, Star, Settings, LinkIcon, Github, Plus } from "lucide-react"
33
import { Skeleton } from "@/components/ui/skeleton"
44
import { useCurrentPackageInfo } from "@/hooks/use-current-package-info"
55
import { usePackageReleaseById } from "@/hooks/use-package-release"
@@ -164,7 +164,7 @@ export default function SidebarAboutSection({
164164
<GitFork className="h-4 w-4 mr-2 text-gray-500 dark:text-[#8b949e]" />
165165
<span>{(packageInfo as any)?.fork_count ?? "0"} forks</span>
166166
</div>
167-
{packageInfo?.github_repo_full_name && (
167+
{packageInfo?.github_repo_full_name ? (
168168
<a
169169
target="_blank"
170170
href={`https://github.com/${packageInfo.github_repo_full_name}`}
@@ -173,6 +173,22 @@ export default function SidebarAboutSection({
173173
<Github className="h-4 w-4 mr-2 text-gray-500 dark:text-[#8b949e]" />
174174
<span>{packageInfo?.github_repo_full_name.split("/")[1]}</span>
175175
</a>
176+
) : (
177+
<>
178+
{isOwner && (
179+
<div
180+
className="flex items-center hover:underline hover:underline-offset-2 cursor-pointer hover:decoration-gray-500"
181+
onClick={openEditPackageDetailsDialog}
182+
title="Connect GitHub"
183+
>
184+
<div className="relative mr-2">
185+
<Github className="h-4 w-4 text-gray-500 dark:text-[#8b949e]" />
186+
<Plus className="h-2 w-2 absolute -bottom-0.5 -right-0.5 text-gray-500 dark:text-[#8b949e] bg-white dark:bg-[#0d1117] rounded-full" />
187+
</div>
188+
<span>Connect GitHub</span>
189+
</div>
190+
)}
191+
</>
176192
)}
177193
</div>
178194
</div>

0 commit comments

Comments
 (0)