ci(release): handle no folder gracefully (#27)
This commit is contained in:
parent
66adc32ff7
commit
bf4743acac
2 changed files with 18 additions and 0 deletions
|
@ -57,6 +57,12 @@ describe("push-charts", () => {
|
|||
});
|
||||
|
||||
describe("getChangedCharts", () => {
|
||||
test("should return empty if archive folder does not exist", async () => {
|
||||
fs.access.mockRejectedValue(new Error("not found"));
|
||||
child_process.execSync.mockReturnValue(Buffer.from(""));
|
||||
await expect(getChangedChartsArchives(["my-chart"])).resolves.toEqual([]);
|
||||
});
|
||||
|
||||
test("should return changed chart if only one exists", async () => {
|
||||
fs.readdir.mockResolvedValue([myChartDirentMock]);
|
||||
child_process.execSync.mockReturnValue(Buffer.from(""));
|
||||
|
|
|
@ -15,6 +15,11 @@ export async function main(rawArgs: string[]) {
|
|||
const args = rawArgs.slice(2);
|
||||
const archives = await getChangedChartsArchives(args);
|
||||
|
||||
if (archives.length === 0) {
|
||||
console.log("No charts to push");
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("Pushing charts");
|
||||
for (const archive of archives) {
|
||||
const cmd = `helm push "${archive.path}" "oci://ghcr.io/${process.env.GITHUB_REPOSITORY}"`;
|
||||
|
@ -45,6 +50,13 @@ export async function getChangedChartsArchives(
|
|||
}
|
||||
|
||||
async function getChartArchives(): Promise<Record<string, Archive>> {
|
||||
try {
|
||||
await fs.access(CR_RELEASE_PACKAGE_PATH);
|
||||
} catch (e) {
|
||||
console.log("No chart archives found");
|
||||
return {};
|
||||
}
|
||||
|
||||
const archiveList = await fs.readdir(CR_RELEASE_PACKAGE_PATH, {
|
||||
withFileTypes: true,
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue