Skip to content

Commit

Permalink
fix(build), provide artifacts from previous build tasks to app-deploy (
Browse files Browse the repository at this point in the history
…#8400)

The issue happened when running `bit build --include-tag`, the deploy
method was trying to get the artifacts from the builderData, which
weren't populated yet.
This PR provides the artifacts directly from the previous tasks.
  • Loading branch information
davidfirst authored Jan 12, 2024
1 parent 947b936 commit fd9a8f6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
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

0 comments on commit fd9a8f6

Please sign in to comment.