Skip to content

Commit 388e440

Browse files
committed
fix: the problem of downloading html report
1 parent 1279ea9 commit 388e440

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

dist/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95662,9 +95662,8 @@ var __webpack_exports__ = {};
9566295662
const relativePath = external_path_default().relative(process.cwd(), targetFilePath);
9566395663
const pathParts = relativePath.split(external_path_default().sep);
9566495664
const fileNameWithoutExt = external_path_default().parse(fileName).name;
95665-
const fileExt = external_path_default().parse(fileName).ext;
9566695665
const pathHash = hashPath(pathParts, fileNameWithoutExt);
95667-
const artifactName = `${pathHash}-${hash}${fileExt}`;
95666+
const artifactName = `${pathHash}-${hash}`;
9566895667
console.log(`Uploading artifact: ${artifactName}`);
9566995668
console.log(`From file: ${targetFilePath}`);
9567095669
const uploadResponse = await artifactClient.uploadArtifact(artifactName, [
@@ -96132,7 +96131,8 @@ var __webpack_exports__ = {};
9613296131
const fileNameWithoutExt = external_path_default().parse(fileName).name;
9613396132
const fileExt = external_path_default().parse(fileName).ext;
9613496133
const pathHash = hashPath(pathParts, fileNameWithoutExt);
96135-
const expectedArtifactName = `${pathHash}-${commitHash}${fileExt}`;
96134+
const expectedArtifactName = `${pathHash}-${commitHash}`;
96135+
const legacyArtifactName = `${pathHash}-${commitHash}${fileExt}`;
9613696136
console.log(`📋 Searching for artifact with path hash and commit hash: ${expectedArtifactName}`);
9613796137
console.log(` Path hash: ${pathHash}`);
9613896138
console.log(` File path: ${relativePath}`);
@@ -96147,7 +96147,7 @@ var __webpack_exports__ = {};
9614796147
console.log(` Status: ${workflowRun.status}, Conclusion: ${workflowRun.conclusion}`);
9614896148
try {
9614996149
const runArtifacts = await githubService.listArtifactsForWorkflowRun(workflowRun.id);
96150-
const foundArtifact = runArtifacts.artifacts?.find((a)=>a.name === expectedArtifactName);
96150+
const foundArtifact = runArtifacts.artifacts?.find((a)=>a.name === expectedArtifactName || a.name === legacyArtifactName);
9615196151
if (foundArtifact) {
9615296152
artifact = foundArtifact;
9615396153
artifacts = runArtifacts;
@@ -96173,7 +96173,7 @@ var __webpack_exports__ = {};
9617396173
}
9617496174
if (!artifact) {
9617596175
artifacts = await githubService.listArtifacts();
96176-
artifact = artifacts.artifacts.find((a)=>a.name === expectedArtifactName);
96176+
artifact = artifacts.artifacts.find((a)=>a.name === expectedArtifactName || a.name === legacyArtifactName);
9617796177
}
9617896178
if (!artifact) {
9617996179
console.log(`❌ No artifact found matching: ${expectedArtifactName}`);

src/download.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,10 @@ export async function downloadArtifactByCommitHash(
106106
const fileNameWithoutExt = path.parse(fileName).name;
107107
const fileExt = path.parse(fileName).ext;
108108
const pathHash = hashPath(pathParts, fileNameWithoutExt);
109-
const expectedArtifactName = `${pathHash}-${commitHash}${fileExt}`;
110-
109+
// New format (no extension); legacy format includes the file extension
110+
const expectedArtifactName = `${pathHash}-${commitHash}`;
111+
const legacyArtifactName = `${pathHash}-${commitHash}${fileExt}`;
112+
111113
console.log(`📋 Searching for artifact with path hash and commit hash: ${expectedArtifactName}`);
112114
console.log(` Path hash: ${pathHash}`);
113115
console.log(` File path: ${relativePath}`);
@@ -129,7 +131,7 @@ export async function downloadArtifactByCommitHash(
129131

130132
try {
131133
const runArtifacts = await githubService.listArtifactsForWorkflowRun(workflowRun.id);
132-
const foundArtifact = runArtifacts.artifacts?.find((a: any) => a.name === expectedArtifactName);
134+
const foundArtifact = runArtifacts.artifacts?.find((a: any) => a.name === expectedArtifactName || a.name === legacyArtifactName);
133135

134136
if (foundArtifact) {
135137
artifact = foundArtifact;
@@ -158,7 +160,7 @@ export async function downloadArtifactByCommitHash(
158160
// Fallback: if not found in any workflow run, search all repository artifacts
159161
if (!artifact) {
160162
artifacts = await githubService.listArtifacts();
161-
artifact = artifacts.artifacts.find((a: any) => a.name === expectedArtifactName);
163+
artifact = artifacts.artifacts.find((a: any) => a.name === expectedArtifactName || a.name === legacyArtifactName);
162164
}
163165

164166
if (!artifact) {

src/upload.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,22 @@ export function hashPath(pathParts: string[], fileNameWithoutExt: string): strin
1111

1212
export async function uploadArtifact(filePath: string, commitHash?: string) {
1313
const artifactClient = new DefaultArtifactClient();
14-
14+
1515
const hash = commitHash || execSync('git rev-parse --short=10 HEAD', { encoding: 'utf8' }).trim();
16-
16+
1717
const targetFilePath = filePath;
18-
18+
1919
if (!targetFilePath || !fs.existsSync(targetFilePath)) {
2020
throw new Error(`Target file not found: ${targetFilePath}`);
2121
}
2222
const fileName = path.basename(targetFilePath);
23-
23+
2424
const relativePath = path.relative(process.cwd(), targetFilePath);
2525
const pathParts = relativePath.split(path.sep);
2626
const fileNameWithoutExt = path.parse(fileName).name;
27-
const fileExt = path.parse(fileName).ext;
28-
27+
2928
const pathHash = hashPath(pathParts, fileNameWithoutExt);
30-
const artifactName = `${pathHash}-${hash}${fileExt}`;
29+
const artifactName = `${pathHash}-${hash}`;
3130

3231
console.log(`Uploading artifact: ${artifactName}`);
3332
console.log(`From file: ${targetFilePath}`);

0 commit comments

Comments
 (0)