Skip to content

Commit c773365

Browse files
Copilotpelikhan
andcommitted
Remove legacy upload-assets handling from JavaScript
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
1 parent f16295e commit c773365

2 files changed

Lines changed: 5 additions & 32 deletions

File tree

pkg/workflow/js/upload_assets.cjs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,25 +76,17 @@ async function main() {
7676
return;
7777
}
7878

79-
// Find all upload-asset items (singular is the standard)
79+
// Find all upload-asset items
8080
const uploadItems = result.items.filter(/** @param {any} item */ item => item.type === "upload_asset");
8181

82-
// Handle legacy upload-assets (plural, hyphenated) with warning
83-
const legacyUploadAssetsItems = result.items.filter(/** @param {any} item */ item => item.type === "upload-assets");
84-
if (legacyUploadAssetsItems.length > 0) {
85-
core.warning(`Found ${legacyUploadAssetsItems.length} item(s) with legacy type "upload-assets" (plural). This type is deprecated. Use "upload_asset" (singular) instead.`);
86-
}
87-
88-
const allUploadItems = [...uploadItems, ...legacyUploadAssetsItems];
89-
90-
if (allUploadItems.length === 0) {
82+
if (uploadItems.length === 0) {
9183
core.info("No upload-asset items found in agent output");
9284
core.setOutput("upload_count", "0");
9385
core.setOutput("branch_name", normalizedBranchName);
9486
return;
9587
}
9688

97-
core.info(`Found ${allUploadItems.length} upload-asset item(s)`);
89+
core.info(`Found ${uploadItems.length} upload-asset item(s)`);
9890

9991
let uploadCount = 0;
10092
let hasChanges = false;
@@ -124,7 +116,7 @@ async function main() {
124116
}
125117

126118
// Process each asset
127-
for (const asset of allUploadItems) {
119+
for (const asset of uploadItems) {
128120
try {
129121
const { fileName, sha, size, targetFileName } = asset;
130122

@@ -182,7 +174,7 @@ async function main() {
182174
core.info(`Successfully uploaded ${uploadCount} assets to branch ${normalizedBranchName}`);
183175
}
184176

185-
for (const asset of allUploadItems) {
177+
for (const asset of uploadItems) {
186178
if (asset.fileName && asset.sha && asset.size && asset.url) {
187179
core.summary.addRaw(`- [\`${asset.fileName}\`](${asset.url}) → \`${asset.targetFileName}\` (${asset.size} bytes)`);
188180
}

pkg/workflow/js/upload_assets.test.cjs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,25 +62,6 @@ const mockCore = { debug: vi.fn(), info: vi.fn(), notice: vi.fn(), warning: vi.f
6262
(expect(branchNameCall).toBeDefined(), expect(branchNameCall[1]).toBe("assets/my-branch"));
6363
});
6464
}),
65-
describe("legacy upload-assets type handling", () => {
66-
it("should warn about legacy upload-assets type (plural hyphenated)", async () => {
67-
((process.env.GH_AW_ASSETS_BRANCH = "assets/test-workflow"), (process.env.GH_AW_SAFE_OUTPUTS_STAGED = "false"));
68-
const assetDir = "/tmp/gh-aw/safeoutputs/assets";
69-
fs.existsSync(assetDir) || fs.mkdirSync(assetDir, { recursive: !0 });
70-
const assetPath = path.join(assetDir, "test.png");
71-
fs.writeFileSync(assetPath, "fake png data");
72-
const crypto = require("crypto"),
73-
fileContent = fs.readFileSync(assetPath),
74-
agentOutput = {
75-
items: [{ type: "upload-assets", fileName: "test.png", sha: crypto.createHash("sha256").update(fileContent).digest("hex"), size: fileContent.length, targetFileName: "test.png", url: "https://example.com/test.png" }],
76-
};
77-
setAgentOutput(agentOutput);
78-
(mockExec.exec.mockImplementation(async () => 0), await executeScript());
79-
const warningCalls = mockCore.warning.mock.calls.filter(call => call[0].includes("legacy type"));
80-
(expect(warningCalls.length).toBeGreaterThan(0), expect(warningCalls[0][0]).toContain("upload-assets"), expect(warningCalls[0][0]).toContain("deprecated"));
81-
fs.existsSync(assetPath) && fs.unlinkSync(assetPath);
82-
});
83-
}),
8465
describe("branch prefix validation", () => {
8566
(it("should allow creating orphaned branch with 'assets/' prefix when branch doesn't exist", async () => {
8667
(fs.existsSync("test.png") && fs.unlinkSync("test.png"), (process.env.GH_AW_ASSETS_BRANCH = "assets/test-workflow"), (process.env.GH_AW_SAFE_OUTPUTS_STAGED = "false"));

0 commit comments

Comments
 (0)