Skip to content

Commit

Permalink
fix(core): scheduler should notify the life cycle about task scheduling
Browse files Browse the repository at this point in the history
  • Loading branch information
vsavkin committed Jun 16, 2022
1 parent 821362f commit fadd03c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
17 changes: 12 additions & 5 deletions packages/nx/src/tasks-runner/tasks-schedule.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('TasksSchedule', () => {
let app1Build: Task;
let app2Build: Task;
let lib1Build: Task;
let lifeCycle: any;
beforeEach(() => {
app1Build = createMockTask('app1:build');
app2Build = createMockTask('app2:build');
Expand Down Expand Up @@ -88,17 +89,18 @@ describe('TasksSchedule', () => {
hashTaskWithDepsAndContext: () => 'hash',
} as any;

lifeCycle = {
startTask: jest.fn(),
endTask: jest.fn(),
scheduleTask: jest.fn(),
};
taskSchedule = new TasksSchedule(
hasher,
projectGraph,
taskGraph,
workspace as Workspaces,
{
lifeCycle: {
startTask: jest.fn(),
endTask: jest.fn(),
scheduleTask: jest.fn(),
},
lifeCycle,
}
);
});
Expand All @@ -125,6 +127,11 @@ describe('TasksSchedule', () => {
expect(taskSchedule.nextTask()).toEqual(app2Build);
});

it('should invoke lifeCycle.scheduleTask', async () => {
await taskSchedule.scheduleNextTasks();
expect(lifeCycle.scheduleTask).toHaveBeenCalled();
});

it('should not schedule any tasks that still have uncompleted dependencies', async () => {
await taskSchedule.scheduleNextTasks();
taskSchedule.nextTask();
Expand Down
1 change: 1 addition & 0 deletions packages/nx/src/tasks-runner/tasks-schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export class TasksSchedule {
this.notScheduledTaskGraph,
[taskId]
);
this.options.lifeCycle.scheduleTask(task);
this.scheduledTasks.push(taskId);
}

Expand Down

1 comment on commit fadd03c

@vercel
Copy link

@vercel vercel bot commented on fadd03c Jun 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-nrwl.vercel.app
nx-five.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx.dev

Please sign in to comment.