-
-
Notifications
You must be signed in to change notification settings - Fork 1k
feat(webapp/deployments): Vercel improvements & fixes #3037
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+360
−63
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7b296ce
feat(deployments): propagate build metadata and conditionally enqueue
0ski 349feb0
feat(webapp): auto-select and optimize project selector
0ski bb81ce3
feat(analytics): add PostHog tracking to Vercel onboarding
0ski a33b542
feat(schema): fix typings for InitializeDeploymentRequestBody
0ski 146496f
chore(vercel): PR feedback minor tweaks
0ski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,12 @@ import { type AuthenticatedEnvironment } from "~/services/apiAuth.server"; | |
| import { BaseService } from "./baseService.server"; | ||
| import { errAsync, fromPromise, okAsync, type ResultAsync } from "neverthrow"; | ||
| import { type WorkerDeployment, type Project } from "@trigger.dev/database"; | ||
| import { BuildServerMetadata, logger, type GitMeta, type DeploymentEvent } from "@trigger.dev/core/v3"; | ||
| import { | ||
| BuildServerMetadata, | ||
| logger, | ||
| type GitMeta, | ||
| type DeploymentEvent, | ||
| } from "@trigger.dev/core/v3"; | ||
| import { TimeoutDeploymentService } from "./timeoutDeployment.server"; | ||
| import { env } from "~/env.server"; | ||
| import { createRemoteImageBuild } from "../remoteImageBuilder.server"; | ||
|
|
@@ -38,9 +43,20 @@ export class DeploymentService extends BaseService { | |
| public progressDeployment( | ||
| authenticatedEnv: AuthenticatedEnvironment, | ||
| friendlyId: string, | ||
| updates: Partial<Pick<WorkerDeployment, "contentHash" | "runtime"> & { git: GitMeta }> | ||
| updates: Partial< | ||
| Pick<WorkerDeployment, "contentHash" | "runtime"> & { | ||
| git: GitMeta; | ||
| buildServerMetadata: BuildServerMetadata; | ||
| } | ||
| > | ||
| ) { | ||
| const validateDeployment = (deployment: Pick<WorkerDeployment, "id" | "status"> & { buildServerMetadata?: BuildServerMetadata }) => { | ||
| const { buildServerMetadata: newBuildServerMetadata, ...restUpdates } = updates; | ||
|
|
||
| const validateDeployment = ( | ||
| deployment: Pick<WorkerDeployment, "id" | "status"> & { | ||
| buildServerMetadata?: BuildServerMetadata; | ||
| } | ||
| ) => { | ||
| if (deployment.status !== "PENDING" && deployment.status !== "INSTALLING") { | ||
| logger.warn( | ||
| "Attempted progressing deployment that is not in PENDING or INSTALLING status", | ||
|
|
@@ -54,12 +70,24 @@ export class DeploymentService extends BaseService { | |
| return okAsync(deployment); | ||
| }; | ||
|
|
||
| const progressToInstalling = (deployment: Pick<WorkerDeployment, "id">) => | ||
| fromPromise( | ||
| const progressToInstalling = ( | ||
| deployment: Pick<WorkerDeployment, "id"> & { buildServerMetadata?: BuildServerMetadata } | ||
| ) => { | ||
| const existingBuildServerMetadata = deployment.buildServerMetadata; | ||
|
|
||
| return fromPromise( | ||
| this._prisma.workerDeployment.updateMany({ | ||
| where: { id: deployment.id, status: "PENDING" }, // status could've changed in the meantime, we're not locking the row | ||
| data: { | ||
| ...updates, | ||
| ...restUpdates, | ||
| ...(newBuildServerMetadata | ||
| ? { | ||
| buildServerMetadata: { | ||
| ...(existingBuildServerMetadata ?? {}), | ||
| ...newBuildServerMetadata, | ||
| }, | ||
| } | ||
| : {}), | ||
| status: "INSTALLING", | ||
| startedAt: new Date(), | ||
| }, | ||
|
|
@@ -74,6 +102,7 @@ export class DeploymentService extends BaseService { | |
| } | ||
| return okAsync({ id: deployment.id, status: "INSTALLING" as const }); | ||
| }); | ||
| }; | ||
|
|
||
| const progressToBuilding = ( | ||
| deployment: Pick<WorkerDeployment, "id"> & { buildServerMetadata?: BuildServerMetadata } | ||
|
|
@@ -85,13 +114,26 @@ export class DeploymentService extends BaseService { | |
| cause: error, | ||
| })); | ||
|
|
||
| const existingBuildServerMetadata = deployment.buildServerMetadata as | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: can avoid the typeassertion by doing a safe parse in
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call, there is already a safeParse there |
||
| | BuildServerMetadata | ||
| | null | ||
| | undefined; | ||
|
|
||
| return createRemoteBuildIfNeeded | ||
| .andThen((externalBuildData) => | ||
| fromPromise( | ||
| this._prisma.workerDeployment.updateMany({ | ||
| where: { id: deployment.id, status: "INSTALLING" }, // status could've changed in the meantime, we're not locking the row | ||
| data: { | ||
| ...updates, | ||
| ...restUpdates, | ||
| ...(newBuildServerMetadata | ||
| ? { | ||
| buildServerMetadata: { | ||
| ...(existingBuildServerMetadata ?? {}), | ||
| ...newBuildServerMetadata, | ||
| }, | ||
| } | ||
| : {}), | ||
| externalBuildData, | ||
| status: "BUILDING", | ||
| installedAt: new Date(), | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.