Skip to content
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

fix(build), provide artifacts from previous build tasks to app-deploy #8400

Merged
merged 1 commit into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions scopes/harmony/application/deploy.task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {
TaskResults,
BuiltTaskResult,
CAPSULE_ARTIFACTS_DIR,
ArtifactList,
Artifact,
} from '@teambit/builder';
import { compact, join } from 'lodash';
import { Capsule } from '@teambit/isolator';
Expand All @@ -31,14 +33,21 @@ export class DeployTask implements BuildTask {
const originalSeedersIds = context.capsuleNetwork.originalSeedersCapsules.map((c) => c.component.id.toString());
const { capsuleNetwork } = context;

const builderData = this.builder.pipelineResultsToBuilderData(context.components, context.previousTasksResults);

const components = await mapSeries(capsuleNetwork.originalSeedersCapsules, async (capsule) => {
const component = capsule.component;
const compBuilderData = builderData.getValueByComponentId(component.id);
const artifactsObjects = compBuilderData?.artifacts || [];
const artifactsObjectsList = ArtifactList.fromArtifactObjects(artifactsObjects);
if (originalSeedersIds && originalSeedersIds.length && !originalSeedersIds.includes(component.id.toString())) {
return undefined;
}
const apps = await this.application.loadAppsFromComponent(component, capsule.path);
if (!apps || !apps.length) return undefined;
const appDeployments = await mapSeries(compact(apps), async (app) => this.runForOneApp(app, capsule, context));
const appDeployments = await mapSeries(compact(apps), async (app) =>
this.runForOneApp(app, capsule, context, artifactsObjectsList)
);
const deploys = compact(appDeployments);
return { component, deploys };
});
Expand Down Expand Up @@ -67,7 +76,8 @@ export class DeployTask implements BuildTask {
private async runForOneApp(
app: Application,
capsule: Capsule,
context: BuildContext
context: BuildContext,
artifacts: ArtifactList<Artifact>
): Promise<ApplicationDeployment | void | undefined> {
const aspectId = this.application.getAppAspect(app.name);
if (!aspectId) return undefined;
Expand All @@ -81,7 +91,7 @@ export class DeployTask implements BuildTask {
const buildDeployContexts = metadata.find((ctx) => ctx.name === app.name && ctx.appType === app.applicationType);
if (!buildDeployContexts) return undefined;

const artifacts = this.builder.getArtifacts(capsule.component);
// const artifacts = this.builder.getArtifacts(capsule.component);
const appContext = await this.application.createAppBuildContext(capsule.component.id, app.name, capsule.path);
const artifactsDir = this.getArtifactDirectory();
const appBuildContext = AppBuildContext.create({
Expand Down
2 changes: 1 addition & 1 deletion scopes/pipelines/builder/builder.main.runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class BuilderMain {
await Promise.all(storeP);
}

private pipelineResultsToBuilderData(
pipelineResultsToBuilderData(
components: Component[],
buildPipelineResults: TaskResults[]
): ComponentMap<RawBuilderData> {
Expand Down