Skip to content

Commit 21d3f00

Browse files
jankeromnesroboquat
authored andcommitted
[server] In the GitHub App, also skip prebuilds if the repository has no prebuild tasks configured
1 parent 281808d commit 21d3f00

File tree

3 files changed

+16
-24
lines changed

3 files changed

+16
-24
lines changed

components/server/ee/src/prebuilds/github-app-rules.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ export class GithubAppRules {
4444
return false;
4545
}
4646

47-
const hasPrebuildTask = !!config.tasks && config.tasks.find((t) => !!t.before || !!t.init || !!t.prebuild);
48-
if (!hasPrebuildTask) {
49-
return false;
50-
}
51-
5247
const prebuildCfg = this.mergeWithDefaultConfig(config).prebuilds!;
5348
if (isPR) {
5449
if (isFork) {

components/server/ee/src/prebuilds/github-app.spec.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,6 @@ describe("GitHub app", () => {
2626
chai.assert.isFalse(rules.shouldRunPrebuild(undefined, false, true, true));
2727
});
2828

29-
it("should not run prebuilds without tasks to execute", async () => {
30-
const noTaskConfig: WorkspaceConfig = {
31-
tasks: [],
32-
};
33-
const rules = container.get(GithubAppRules) as GithubAppRules;
34-
chai.assert.isFalse(rules.shouldRunPrebuild(noTaskConfig, true, false, false));
35-
chai.assert.isFalse(rules.shouldRunPrebuild(noTaskConfig, false, true, false));
36-
chai.assert.isFalse(rules.shouldRunPrebuild(noTaskConfig, false, false, false));
37-
chai.assert.isFalse(rules.shouldRunPrebuild(noTaskConfig, false, true, true));
38-
});
39-
4029
it("should behave well with individual configuration", async () => {
4130
const rules = container.get(GithubAppRules) as GithubAppRules;
4231

components/server/ee/src/prebuilds/github-app.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,11 @@ export class GithubApp {
274274
user = r.user;
275275
project = r.project;
276276

277-
const runPrebuild = this.appRules.shouldRunPrebuild(config, branch == repo.default_branch, false, false);
277+
const runPrebuild =
278+
this.prebuildManager.shouldPrebuild(config) &&
279+
this.appRules.shouldRunPrebuild(config, branch == repo.default_branch, false, false);
278280
if (!runPrebuild) {
279-
const reason = `Not running prebuild, the user did not enable it for this context`;
281+
const reason = `Not running prebuild, the user did not enable it for this context or did not configure prebuild task(s)`;
280282
log.debug(logCtx, reason, { contextURL });
281283
span.log({ "not-running": reason, config: config });
282284
return;
@@ -448,7 +450,8 @@ export class GithubApp {
448450
const contextURL = pr.html_url;
449451

450452
const isFork = pr.head.repo.id !== pr.base.repo.id;
451-
const runPrebuild = this.appRules.shouldRunPrebuild(config, false, true, isFork);
453+
const runPrebuild =
454+
this.prebuildManager.shouldPrebuild(config) && this.appRules.shouldRunPrebuild(config, false, true, isFork);
452455
let prebuildStartPromise: Promise<StartPrebuildResult> | undefined;
453456
if (runPrebuild) {
454457
const commitInfo = await this.getCommitInfo(user, ctx.payload.repository.html_url, pr.head.sha);
@@ -461,11 +464,16 @@ export class GithubApp {
461464
prebuildStartPromise.catch((err) => log.error(err, "Error while starting prebuild", { contextURL }));
462465
return prebuildStartPromise;
463466
} else {
464-
log.debug({ userId: user.id }, `Not running prebuild, the user did not enable it for this context`, null, {
465-
contextURL,
466-
userId: user.id,
467-
project,
468-
});
467+
log.debug(
468+
{ userId: user.id },
469+
`Not running prebuild, the user did not enable it for this context or did not configure prebuild task(s)`,
470+
null,
471+
{
472+
contextURL,
473+
userId: user.id,
474+
project,
475+
},
476+
);
469477
return;
470478
}
471479
}

0 commit comments

Comments
 (0)