From f98b0ece93d87a24156b6c5bde759826746c1323 Mon Sep 17 00:00:00 2001 From: Nico Jensch Date: Sun, 24 Nov 2024 14:46:43 +0100 Subject: [PATCH] chore(backend): set cooldown to 7 days by default --- backend/src/config/repo-manager.config.ts | 3 ++- backend/src/interfaces/repo-manager.ts | 2 +- .../src/repo-manager/repo-manager.service.ts | 23 +++++++++---------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/backend/src/config/repo-manager.config.ts b/backend/src/config/repo-manager.config.ts index 8b10224..d073d2b 100644 --- a/backend/src/config/repo-manager.config.ts +++ b/backend/src/config/repo-manager.config.ts @@ -1,10 +1,11 @@ import { registerAs } from "@nestjs/config"; export default registerAs("repoMan", () => ({ + cooldownDays: process.env.REPOMANAGER_COOLDOWN_DAYS ?? 7, gitAuthor: process.env.GIT_AUTHOR ?? "Temeraire", gitEmail: process.env.GIT_EMAIL ?? "ci@chaotic.cx", gitUsername: process.env.GIT_USERNAME ?? "git", - globalBlacklist: process.env.REPOMANAGER_NEVER_REBUILD ?? "[]", + globalBlocklist: process.env.REPOMANAGER_NEVER_REBUILD ?? "[]", globalTriggers: process.env.REPOMANAGER_ALWAYS_REBUILD ?? "[]", regenDatabase: process.env.REPOMANAGER_REGEN_DB ?? false, schedulerInterval: process.env.REPOMANAGER_SCHEDULE ?? "0 * * * *", diff --git a/backend/src/interfaces/repo-manager.ts b/backend/src/interfaces/repo-manager.ts index 18eebcd..33c1e76 100644 --- a/backend/src/interfaces/repo-manager.ts +++ b/backend/src/interfaces/repo-manager.ts @@ -48,7 +48,7 @@ export interface RepoSettings { gitAuthor: string; gitEmail: string; gitUsername: string; - globalBlacklist: string[]; + globalBlocklist: string[]; globalTriggers: string[]; regenDatabase: boolean; } diff --git a/backend/src/repo-manager/repo-manager.service.ts b/backend/src/repo-manager/repo-manager.service.ts index 44d306c..3495f8f 100644 --- a/backend/src/repo-manager/repo-manager.service.ts +++ b/backend/src/repo-manager/repo-manager.service.ts @@ -179,15 +179,15 @@ export class RepoManagerService { * Create a new RepoManager instance. * @returns A new RepoManager instance */ - createRepoManager(globalTriggers?: string[], globalBlackList?: string[]): RepoManager { + createRepoManager(globalTriggers?: string[], globalBlocklist?: string[]): RepoManager { const repoSettings: RepoSettings = { gitAuthor: this.configService.getOrThrow("repoMan.gitAuthor"), gitEmail: this.configService.getOrThrow("repoMan.gitEmail"), gitUsername: this.configService.getOrThrow("repoMan.gitUsername"), globalTriggers: globalTriggers ?? JSON.parse(this.configService.getOrThrow("repoMan.globalTriggers")), - globalBlacklist: - globalBlackList ?? JSON.parse(this.configService.getOrThrow("repoMan.globalBlacklist")), + globalBlocklist: + globalBlocklist ?? JSON.parse(this.configService.getOrThrow("repoMan.globalBlocklist")), regenDatabase: this.configService.getOrThrow("repoMan.regenDatabase"), }; @@ -578,12 +578,12 @@ class RepoManager { // additionally process blocklisted packages const globalTriggerList: { list: string[]; blacklist: string[] } = await this.checkGlobalTriggers(repoDir); const allGlobalTriggers: string[] = [...this.repoManagerSettings.globalTriggers, ...globalTriggerList.list]; - const allGlobalBlacklist: string[] = [ - ...this.repoManagerSettings.globalBlacklist, + const allGlobalBlocklist: string[] = [ + ...this.repoManagerSettings.globalBlocklist, ...globalTriggerList.blacklist, ]; const globalArchRebuildPkg: ArchlinuxPackage[] = this.changedArchPackages.filter((pkg) => { - return allGlobalTriggers.includes(pkg.pkgname) && !allGlobalBlacklist.includes(pkg.pkgname); + return allGlobalTriggers.includes(pkg.pkgname) && !allGlobalBlocklist.includes(pkg.pkgname); }); // Additionally, filter out the .so providing Arch packages from our changed package list @@ -766,8 +766,10 @@ class RepoManager { */ async bumpPackages(needsRebuild: RepoUpdateRunParams[], repoDir: string): Promise { const alreadyBumped: PackageBumpEntry[] = []; + + // Set cooldown to one week by default, overridable via config const date = new Date(); - date.setDate(date.getDate() - 1); + date.setDate(date.getDate() - this.configService.get("repoMan.bumpCooldown")); const packageBumpsLastDay: PackageBump[] = await this.dbConnections.packageBump.find({ where: { timestamp: MoreThanOrEqual(date) }, @@ -775,7 +777,7 @@ class RepoManager { relations: ["pkg"], }); - Logger.log(`Found ${packageBumpsLastDay.length} bumps in the last day`, "RepoManager"); + Logger.log(`Found ${packageBumpsLastDay.length} bumps in the last ${this.configService.get("repoMan.bumpCooldown")} days`, "RepoManager"); // Let's only consider Chaotic rebuilds for now, as Arch ones usually don't occur as often (-git packages) const relevantBumps: PackageBump[] = packageBumpsLastDay.filter((bump) => { @@ -796,7 +798,7 @@ class RepoManager { // We also don't want to rebuild packages that have already been bumped within a day const needsSkip = relevantBumps.find((bump) => bump.pkg.id === param.pkg.id) !== undefined; if (needsSkip) { - Logger.warn(`Already bumped ${param.pkg.pkgname} during the last day, skipping`, "RepoManager"); + Logger.warn(`Already bumped ${param.pkg.pkgname} during the last ${this.configService.get("repoMan.bumpCooldown")} days, skipping`, "RepoManager"); continue; } @@ -1497,9 +1499,6 @@ class RepoManager { pkg.pkgname, ); - Logger.log(pkg.metadata, "CheckDeps"); - Logger.log(soNameList, "CheckDeps"); - if ( pkg.metadata?.deps?.includes(build.pkgbase.pkgname) || soNameList.find((soName) => pkg.metadata?.deps?.includes(soName))