Skip to content

Commit

Permalink
fix: don't assume MODULE.bazel file in ruleset repo
Browse files Browse the repository at this point in the history
  • Loading branch information
kormide committed Jun 11, 2024
1 parent b3e277c commit 1361ae7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/application/release-event-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export class ReleaseEventHandler {
console.log(`Attempting publish to fork ${bcrFork.canonicalName}.`);

try {
await createEntryService.createEntryFiles(
const {moduleName} = await createEntryService.createEntryFiles(
rulesetRepo,
bcr,
tag,
Expand All @@ -270,7 +270,7 @@ export class ReleaseEventHandler {
bcrFork,
bcr,
branch,
rulesetRepo.getModuleName(moduleRoot),
moduleName,
releaseUrl
);

Expand Down
12 changes: 12 additions & 0 deletions src/domain/create-entry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,18 @@ describe("createEntryFiles", () => {
);
});

test("returns the module name from the release archive", async () => {
mockRulesetFiles({extractedModuleName: "foomodule"});

const tag = "v1.2.3";
const rulesetRepo = await RulesetRepository.create("repo", "owner", tag);
const bcrRepo = CANONICAL_BCR;

const result = await createEntryService.createEntryFiles(rulesetRepo, bcrRepo, tag, ".");

expect(result.moduleName).toEqual("foomodule");
});

test("cleans up the release archive extraction", async () => {
mockRulesetFiles();

Expand Down
4 changes: 3 additions & 1 deletion src/domain/create-entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class CreateEntryService {
bcrRepo: Repository,
tag: string,
moduleRoot: string
): Promise<void> {
): Promise<{moduleName: string}> {
await Promise.all([rulesetRepo.checkout(tag), bcrRepo.checkout("main")]);

const version = RulesetRepository.getVersionFromTag(tag);
Expand Down Expand Up @@ -105,6 +105,8 @@ export class CreateEntryService {
rulesetRepo.presubmitPath(moduleRoot),
path.join(bcrVersionEntryPath, "presubmit.yml")
);

return {moduleName: moduleFile.moduleName };
} finally {
releaseArchive.cleanup();
}
Expand Down
6 changes: 0 additions & 6 deletions src/domain/ruleset-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import yaml from "yaml";
import { Configuration } from "./config.js";
import { UserFacingError } from "./error.js";
import { MetadataFile, MetadataFileError } from "./metadata-file.js";
import { ModuleFile } from "./module-file.js";
import { Repository } from "./repository.js";
import {
SourceTemplate,
Expand Down Expand Up @@ -251,11 +250,6 @@ export class RulesetRepository extends Repository {
public get config(): Configuration {
return this._config;
}

public getModuleName(moduleRoot: string): string {
return new ModuleFile(path.join(this.diskPath, moduleRoot, "MODULE.bazel"))
.moduleName;
}
}

function validatePresubmitFile(
Expand Down

0 comments on commit 1361ae7

Please sign in to comment.