Skip to content

Commit f159d77

Browse files
committed
unify the task executor across dev & prod
1 parent 01d2dcc commit f159d77

File tree

7 files changed

+403
-456
lines changed

7 files changed

+403
-456
lines changed

apps/webapp/app/v3/marqs/sharedQueueConsumer.server.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,10 @@ export class SharedQueueConsumer {
300300
return;
301301
}
302302

303-
if (existingTaskRun.status !== "PENDING") {
303+
if (
304+
existingTaskRun.status !== "PENDING" &&
305+
existingTaskRun.status !== "RETRYING_AFTER_FAILURE"
306+
) {
304307
logger.debug("Task run is not pending, aborting", {
305308
queueMessage: message.data,
306309
messageId: message.messageId,

packages/cli-v3/src/commands/deploy.ts

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,17 @@ export async function deployCommand(dir: string, anyOptions: unknown) {
144144

145145
await printStandloneInitialBanner(true);
146146

147-
const { config } = await readConfig(dir, {
147+
const resolvedConfig = await readConfig(dir, {
148148
configFile: options.data.config,
149149
projectRef: options.data.projectRef,
150150
});
151151

152-
logger.debug("Resolved config", { config });
152+
logger.debug("Resolved config", { resolvedConfig });
153153

154154
const apiClient = new CliApiClient(authorization.config.apiUrl, authorization.config.accessToken);
155155

156156
const deploymentEnv = await apiClient.getProjectEnv({
157-
projectRef: config.project,
157+
projectRef: resolvedConfig.config.project,
158158
env: options.data.env,
159159
});
160160

@@ -168,19 +168,25 @@ export async function deployCommand(dir: string, anyOptions: unknown) {
168168
);
169169

170170
intro(
171-
`Preparing to deploy "${deploymentEnv.data.name}" (${config.project}) to ${options.data.env}`
171+
`Preparing to deploy "${deploymentEnv.data.name}" (${resolvedConfig.config.project}) to ${options.data.env}`
172172
);
173173

174174
// Step 1: Build the project into a temporary directory
175-
const compilation = await compileProject(config, options.data);
175+
const compilation = await compileProject(
176+
resolvedConfig.config,
177+
options.data,
178+
resolvedConfig.status === "file" ? resolvedConfig.path : undefined
179+
);
176180

177181
logger.debug("Compilation result", { compilation });
178182

179183
const environmentVariablesSpinner = spinner();
180184

181185
environmentVariablesSpinner.start("Checking environment variables");
182186

183-
const environmentVariables = await environmentClient.getEnvironmentVariables(config.project);
187+
const environmentVariables = await environmentClient.getEnvironmentVariables(
188+
resolvedConfig.config.project
189+
);
184190

185191
if (!environmentVariables.success) {
186192
environmentVariablesSpinner.stop(`Failed to fetch environment variables, skipping check`);
@@ -197,7 +203,7 @@ export async function deployCommand(dir: string, anyOptions: unknown) {
197203
)}. Aborting deployment. ${chalk.bgBlueBright(
198204
terminalLink(
199205
"Manage env vars",
200-
`${authorization.config.apiUrl}/projects/v3/${config.project}/environment-variables`
206+
`${authorization.config.apiUrl}/projects/v3/${resolvedConfig.config.project}/environment-variables`
201207
)
202208
)}`
203209
);
@@ -239,11 +245,11 @@ export async function deployCommand(dir: string, anyOptions: unknown) {
239245
return buildAndPushSelfHostedImage({
240246
imageTag: deploymentResponse.data.imageTag,
241247
cwd: compilation.path,
242-
projectId: config.project,
248+
projectId: resolvedConfig.config.project,
243249
deploymentId: deploymentResponse.data.id,
244250
deploymentVersion: version,
245251
contentHash: deploymentResponse.data.contentHash,
246-
projectRef: config.project,
252+
projectRef: resolvedConfig.config.project,
247253
buildPlatform: options.data.buildPlatform,
248254
});
249255
}
@@ -263,11 +269,11 @@ export async function deployCommand(dir: string, anyOptions: unknown) {
263269
buildToken: deploymentResponse.data.externalBuildData.buildToken,
264270
buildProjectId: deploymentResponse.data.externalBuildData.projectId,
265271
cwd: compilation.path,
266-
projectId: config.project,
272+
projectId: resolvedConfig.config.project,
267273
deploymentId: deploymentResponse.data.id,
268274
deploymentVersion: deploymentResponse.data.version,
269275
contentHash: deploymentResponse.data.contentHash,
270-
projectRef: config.project,
276+
projectRef: resolvedConfig.config.project,
271277
loadImage: options.data.loadImage,
272278
buildPlatform: options.data.buildPlatform,
273279
});
@@ -321,7 +327,7 @@ export async function deployCommand(dir: string, anyOptions: unknown) {
321327

322328
const deploymentLink = terminalLink(
323329
"View deployment",
324-
`${authorization.config.apiUrl}/projects/v3/${config.project}/deployments/${finishedDeployment.id}`
330+
`${authorization.config.apiUrl}/projects/v3/${resolvedConfig.config.project}/deployments/${finishedDeployment.id}`
325331
);
326332

327333
switch (finishedDeployment.status) {
@@ -584,7 +590,11 @@ function extractImageDigest(outputs: string[]) {
584590
}
585591
}
586592

587-
async function compileProject(config: ResolvedConfig, options: DeployCommandOptions) {
593+
async function compileProject(
594+
config: ResolvedConfig,
595+
options: DeployCommandOptions,
596+
configPath?: string
597+
) {
588598
if (!options.skipTypecheck) {
589599
await typecheckProject(config, options);
590600
}
@@ -605,10 +615,24 @@ async function compileProject(config: ResolvedConfig, options: DeployCommandOpti
605615
importResolve("./workers/prod/worker-setup.js", import.meta.url)
606616
).href.replace("file://", "");
607617

608-
const workerContents = workerFacade
618+
let workerContents = workerFacade
609619
.replace("__TASKS__", createTaskFileImports(taskFiles))
610620
.replace("__WORKER_SETUP__", `import { tracingSDK } from "${workerSetupPath}";`);
611621

622+
if (configPath) {
623+
logger.debug("Importing project config from", { configPath });
624+
625+
workerContents = workerContents.replace(
626+
"__IMPORTED_PROJECT_CONFIG__",
627+
`import importedConfig from "${configPath}";`
628+
);
629+
} else {
630+
workerContents = workerContents.replace(
631+
"__IMPORTED_PROJECT_CONFIG__",
632+
`const importedConfig = undefined;`
633+
);
634+
}
635+
612636
const result = await build({
613637
stdin: {
614638
contents: workerContents,

0 commit comments

Comments
 (0)