playwright-slack-report-burak 3.1.9 → 3.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/ResultsParser.js +28 -36
- package/package.json +1 -1
|
@@ -383,20 +383,23 @@ class ResultsParser {
|
|
|
383
383
|
}
|
|
384
384
|
|
|
385
385
|
const neededFilesOrdered = [];
|
|
386
|
-
const neededFilesSet = new Set();
|
|
387
386
|
for (let i = 2; i <= this.totalShardCount; i++) {
|
|
388
387
|
neededFilesOrdered.push(`node_summary_${i}.json`, `blob-report-node-${i}.zip`);
|
|
389
|
-
neededFilesSet.add(`node_summary_${i}.json`);
|
|
390
|
-
neededFilesSet.add(`blob-report-node-${i}.zip`);
|
|
391
388
|
}
|
|
392
389
|
|
|
390
|
+
const getShardFromFile = (filename) => {
|
|
391
|
+
const m = filename.match(/node_summary_(\d+)\.json|blob-report-node-(\d+)\.zip/);
|
|
392
|
+
return m ? parseInt(m[1] || m[2], 10) : null;
|
|
393
|
+
};
|
|
394
|
+
|
|
393
395
|
for (const file of neededFilesOrdered) {
|
|
394
396
|
const filePath = path.join(SUMMARIES_DIR, file);
|
|
395
397
|
while (!fs.existsSync(filePath)) {
|
|
396
398
|
if (!fs.existsSync(SUMMARIES_DIR)) {
|
|
397
399
|
fs.mkdirSync(SUMMARIES_DIR, { recursive: true });
|
|
398
400
|
}
|
|
399
|
-
|
|
401
|
+
const shard = getShardFromFile(file);
|
|
402
|
+
if (shard) await this.fetchArtifactForShard(shard);
|
|
400
403
|
if (fs.existsSync(filePath)) break;
|
|
401
404
|
console.warn(`File ${file} not found. Retrying in 10 seconds...`);
|
|
402
405
|
await new Promise(resolve => setTimeout(resolve, 10000));
|
|
@@ -404,13 +407,11 @@ class ResultsParser {
|
|
|
404
407
|
}
|
|
405
408
|
}
|
|
406
409
|
|
|
407
|
-
async
|
|
410
|
+
async fetchArtifactForShard(shard) {
|
|
408
411
|
const githubApiUrl = getGitHubArtifactsApiUrl();
|
|
409
|
-
|
|
410
412
|
if (!AdmZip) {
|
|
411
413
|
throw new Error('adm-zip is required for GitHub Actions artifact extraction. Please install it: npm install adm-zip');
|
|
412
414
|
}
|
|
413
|
-
|
|
414
415
|
try {
|
|
415
416
|
const listResponse = await axios.get(githubApiUrl, {
|
|
416
417
|
headers: {
|
|
@@ -419,38 +420,29 @@ class ResultsParser {
|
|
|
419
420
|
},
|
|
420
421
|
params: { per_page: 100 }
|
|
421
422
|
});
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
fetched.add(baseName);
|
|
441
|
-
console.log(`Successfully fetched ${baseName} from artifact ${artifact.name}`);
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
} catch (searchError) {
|
|
445
|
-
// Continue with next artifact
|
|
423
|
+
const artifact = (listResponse.data.artifacts || []).find(
|
|
424
|
+
(a) => (a.name || '').endsWith(`-artifacts-shard-${shard}`)
|
|
425
|
+
);
|
|
426
|
+
if (!artifact?.archive_download_url) return false;
|
|
427
|
+
const downloadResponse = await axios.get(artifact.archive_download_url, {
|
|
428
|
+
headers: {
|
|
429
|
+
'Authorization': `token ${GITHUB_TOKEN}`,
|
|
430
|
+
'Accept': 'application/vnd.github.v3+json'
|
|
431
|
+
},
|
|
432
|
+
responseType: 'arraybuffer'
|
|
433
|
+
});
|
|
434
|
+
const zip = new AdmZip(downloadResponse.data);
|
|
435
|
+
const targetFiles = [`node_summary_${shard}.json`, `blob-report-node-${shard}.zip`];
|
|
436
|
+
for (const entry of zip.getEntries()) {
|
|
437
|
+
const baseName = path.basename(entry.entryName);
|
|
438
|
+
if (targetFiles.includes(baseName)) {
|
|
439
|
+
fs.writeFileSync(path.join(SUMMARIES_DIR, baseName), entry.getData());
|
|
440
|
+
console.log(`Successfully fetched ${baseName} from shard ${shard}`);
|
|
446
441
|
}
|
|
447
442
|
}
|
|
448
|
-
return
|
|
443
|
+
return true;
|
|
449
444
|
} catch (error) {
|
|
450
|
-
if (error.response
|
|
451
|
-
return false;
|
|
452
|
-
}
|
|
453
|
-
console.error('Failed to fetch artifacts:', error);
|
|
445
|
+
if (error.response?.status === 404) return false;
|
|
454
446
|
throw error;
|
|
455
447
|
}
|
|
456
448
|
}
|
package/package.json
CHANGED