Skip to content

Commit

Permalink
chore(backend): set cooldown to 7 days by default
Browse files Browse the repository at this point in the history
  • Loading branch information
dr460nf1r3 committed Nov 24, 2024
1 parent 4ab9e0e commit f98b0ec
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
3 changes: 2 additions & 1 deletion backend/src/config/repo-manager.config.ts
Original file line number Diff line number Diff line change
@@ -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 ?? "[email protected]",
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 * * * *",
Expand Down
2 changes: 1 addition & 1 deletion backend/src/interfaces/repo-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export interface RepoSettings {
gitAuthor: string;
gitEmail: string;
gitUsername: string;
globalBlacklist: string[];
globalBlocklist: string[];
globalTriggers: string[];
regenDatabase: boolean;
}
Expand Down
23 changes: 11 additions & 12 deletions backend/src/repo-manager/repo-manager.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>("repoMan.gitAuthor"),
gitEmail: this.configService.getOrThrow<string>("repoMan.gitEmail"),
gitUsername: this.configService.getOrThrow<string>("repoMan.gitUsername"),
globalTriggers:
globalTriggers ?? JSON.parse(this.configService.getOrThrow<string>("repoMan.globalTriggers")),
globalBlacklist:
globalBlackList ?? JSON.parse(this.configService.getOrThrow<string>("repoMan.globalBlacklist")),
globalBlocklist:
globalBlocklist ?? JSON.parse(this.configService.getOrThrow<string>("repoMan.globalBlocklist")),
regenDatabase: this.configService.getOrThrow("repoMan.regenDatabase"),
};

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -766,16 +766,18 @@ class RepoManager {
*/
async bumpPackages(needsRebuild: RepoUpdateRunParams[], repoDir: string): Promise<PackageBumpEntry[]> {
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) },
order: { timestamp: "DESC" },
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) => {
Expand All @@ -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;
}

Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit f98b0ec

Please sign in to comment.