@@ -95841,20 +95841,10 @@ var __webpack_exports__ = {};
9584195841 const hasArtifacts = await this.hasArtifactsForCommit(latestCommitHash);
9584295842 if (hasArtifacts) {
9584395843 console.log(`✅ Commit ${latestCommitHash} has baseline artifacts`);
95844- <<<<<<< HEAD
95845- <<<<<<< HEAD
95846- =======
95847- >>>>>>> 57dd868 (test: find the parents commits)
9584895844 return {
9584995845 commitHash: latestCommitHash,
9585095846 usedFallbackCommit: false
9585195847 };
95852- <<<<<<< HEAD
95853- =======
95854- return latestCommitHash;
95855- >>>>>>> 5e14053 (optimize: find the parent commits when no latest commit's baseline (#19))
95856- =======
95857- >>>>>>> 57dd868 (test: find the parents commits)
9585895848 }
9585995849 console.log(`⚠️ Commit ${latestCommitHash} does not have baseline artifacts`);
9586095850 console.log(`🔍 Looking for previous commits with baseline artifacts...`);
@@ -95881,41 +95871,21 @@ var __webpack_exports__ = {};
9588195871 console.log(`\n⚠️ Note: The latest commit (${latestCommitHash}) does not have baseline artifacts.`);
9588295872 console.log(` Using commit ${parentCommit} for baseline comparison instead.`);
9588395873 console.log(" If this seems incorrect, please wait a few minutes and try rerunning the workflow.");
95884- <<<<<<< HEAD
95885- <<<<<<< HEAD
95886- =======
95887- >>>>>>> 57dd868 (test: find the parents commits)
9588895874 return {
9588995875 commitHash: parentCommit,
9589095876 usedFallbackCommit: true,
9589195877 latestCommitHash: latestCommitHash
9589295878 };
95893- <<<<<<< HEAD
95894- =======
95895- return parentCommit;
95896- >>>>>>> 5e14053 (optimize: find the parent commits when no latest commit's baseline (#19))
95897- =======
95898- >>>>>>> 57dd868 (test: find the parents commits)
9589995879 }
9590095880 currentCommit = parentCommit;
9590195881 }
9590295882 console.log(`\n⚠️ No commits with baseline artifacts found in the last ${maxDepth} commits.`);
9590395883 console.log(` Using latest commit ${latestCommitHash} anyway.`);
9590495884 console.log(" Note: If baseline comparison fails, please wait a few minutes and try rerunning the workflow.");
95905- <<<<<<< HEAD
95906- <<<<<<< HEAD
95907- =======
95908- >>>>>>> 57dd868 (test: find the parents commits)
9590995885 return {
9591095886 commitHash: latestCommitHash,
9591195887 usedFallbackCommit: false
9591295888 };
95913- <<<<<<< HEAD
95914- =======
95915- return latestCommitHash;
95916- >>>>>>> 5e14053 (optimize: find the parent commits when no latest commit's baseline (#19))
95917- =======
95918- >>>>>>> 57dd868 (test: find the parents commits)
9591995889 } catch (error) {
9592095890 console.error(`❌ Failed to get target branch commit: ${error}`);
9592195891 console.error(`Repository: ${this.repository.owner}/${this.repository.repo}`);
@@ -96326,18 +96296,22 @@ var __webpack_exports__ = {};
9632696296 }
9632796297 function calculateDiff(current, baseline) {
9632896298 if (!baseline || 0 === baseline || isNaN(baseline)) return {
96329- value: 'N/A ',
96299+ value: '0 ',
9633096300 emoji: '❓'
9633196301 };
9633296302 if (isNaN(current)) return {
96333- value: 'N/A ',
96303+ value: '0 ',
9633496304 emoji: '❓'
9633596305 };
9633696306 const diff = current - baseline;
96307+ if (0 === diff) return {
96308+ value: '0',
96309+ emoji: ''
96310+ };
9633796311 const percent = diff / baseline * 100;
9633896312 if (Math.abs(percent) < 1) return {
9633996313 value: `${formatBytes(diff)} (${percent.toFixed(1)}%)`,
96340- emoji: '➡️ '
96314+ emoji: ''
9634196315 };
9634296316 if (diff > 0) return {
9634396317 value: `+${formatBytes(diff)} (+${percent.toFixed(1)}%)`,
@@ -96418,7 +96392,7 @@ var __webpack_exports__ = {};
9641896392 header: false
9641996393 },
9642096394 {
96421- data: baseline ? calculateDiff(current.totalSize, baseline.totalSize).value : 'N/A ',
96395+ data: baseline ? calculateDiff(current.totalSize, baseline.totalSize).value : '0 ',
9642296396 header: false
9642396397 }
9642496398 ],
@@ -96436,7 +96410,7 @@ var __webpack_exports__ = {};
9643696410 header: false
9643796411 },
9643896412 {
96439- data: baseline ? calculateDiff(current.jsSize, baseline.jsSize).value : 'N/A ',
96413+ data: baseline ? calculateDiff(current.jsSize, baseline.jsSize).value : '0 ',
9644096414 header: false
9644196415 }
9644296416 ],
@@ -96454,7 +96428,7 @@ var __webpack_exports__ = {};
9645496428 header: false
9645596429 },
9645696430 {
96457- data: baseline ? calculateDiff(current.cssSize, baseline.cssSize).value : 'N/A ',
96431+ data: baseline ? calculateDiff(current.cssSize, baseline.cssSize).value : '0 ',
9645896432 header: false
9645996433 }
9646096434 ],
@@ -96472,7 +96446,7 @@ var __webpack_exports__ = {};
9647296446 header: false
9647396447 },
9647496448 {
96475- data: baseline ? calculateDiff(current.htmlSize, baseline.htmlSize).value : 'N/A ',
96449+ data: baseline ? calculateDiff(current.htmlSize, baseline.htmlSize).value : '0 ',
9647696450 header: false
9647796451 }
9647896452 ],
@@ -96490,7 +96464,7 @@ var __webpack_exports__ = {};
9649096464 header: false
9649196465 },
9649296466 {
96493- data: baseline ? calculateDiff(current.otherSize, baseline.otherSize).value : 'N/A ',
96467+ data: baseline ? calculateDiff(current.otherSize, baseline.otherSize).value : '0 ',
9649496468 header: false
9649596469 }
9649696470 ]
@@ -96526,7 +96500,7 @@ var __webpack_exports__ = {};
9652696500 header: false
9652796501 },
9652896502 {
96529- data: baseline ? formatBytes(baseline.totalSize) : 'N/A ',
96503+ data: baseline ? formatBytes(baseline.totalSize) : '0 ',
9653096504 header: false
9653196505 }
9653296506 ]
@@ -96853,7 +96827,25 @@ var __webpack_exports__ = {};
9685396827 const reportsWithCurrent = projectReports.filter((r)=>r.current);
9685496828 if (reportsWithCurrent.length > 1) commentBody += `Found ${reportsWithCurrent.length} project(s) in monorepo.\n\n`;
9685596829 if (reportsWithCurrent.length > 0) {
96856- commentBody += '<details>\n<summary><b>📊 Quick Summary</b> (Click to expand)</summary>\n\n';
96830+ let hasChanges = false;
96831+ for (const report of reportsWithCurrent){
96832+ if (!report.current) continue;
96833+ if (!report.baseline) {
96834+ hasChanges = true;
96835+ break;
96836+ }
96837+ const currentSize = report.current.totalSize;
96838+ const baselineSize = report.baseline.totalSize;
96839+ if (0 === baselineSize || isNaN(baselineSize)) continue;
96840+ const diff = currentSize - baselineSize;
96841+ const percent = Math.abs(diff / baselineSize * 100);
96842+ if (percent >= 1) {
96843+ hasChanges = true;
96844+ break;
96845+ }
96846+ }
96847+ const detailsTag = hasChanges ? '<details open>\n' : '<details>\n';
96848+ commentBody += `${detailsTag}<summary><b>📊 Quick Summary</b></summary>\n\n`;
9685796849 commentBody += '| Project | Total Size | Change |\n';
9685896850 commentBody += '|---------|------------|--------|\n';
9685996851 for (const report of reportsWithCurrent){
@@ -96869,15 +96861,31 @@ var __webpack_exports__ = {};
9686996861 }
9687096862 commentBody += '\n</details>\n\n';
9687196863 }
96872- if (reportsWithCurrent.length > 1) commentBody += '<details>\n<summary><b>📋 Detailed Reports</b> (Click to expand)</summary>\n\n';
96873- for (const report of projectReports)if (report.current) {
96874- commentBody += generateProjectMarkdown(report.projectName, report.filePath, report.current, report.baseline || void 0, report.baselineCommitHash, report.baselinePRs);
96875- if (report.diffHtmlArtifactId) {
96876- const artifactDownloadLink = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}/artifacts/${report.diffHtmlArtifactId}`;
96877- commentBody += `\n📦 **Download Diff Report**: [${report.projectName} Bundle Diff](${artifactDownloadLink})\n\n`;
96864+ const hasSignificantChanges = (report)=>{
96865+ if (!report.current) return false;
96866+ if (!report.baseline) return true;
96867+ const currentSize = report.current.totalSize;
96868+ const baselineSize = report.baseline.totalSize;
96869+ if (0 === baselineSize || isNaN(baselineSize)) return false;
96870+ const diff = currentSize - baselineSize;
96871+ const percent = Math.abs(diff / baselineSize * 100);
96872+ return percent >= 1;
96873+ };
96874+ const reportsWithChanges = projectReports.filter((report)=>{
96875+ if (!report.current) return false;
96876+ return hasSignificantChanges(report);
96877+ });
96878+ if (reportsWithChanges.length > 0) {
96879+ if (reportsWithChanges.length > 1) commentBody += '<details>\n<summary><b>📋 Detailed Reports</b> (Click to expand)</summary>\n\n';
96880+ for (const report of reportsWithChanges){
96881+ commentBody += generateProjectMarkdown(report.projectName, report.filePath, report.current, report.baseline || void 0, report.baselineCommitHash, report.baselinePRs);
96882+ if (report.diffHtmlArtifactId) {
96883+ const artifactDownloadLink = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}/artifacts/${report.diffHtmlArtifactId}`;
96884+ commentBody += `\n📦 **Download Diff Report**: [${report.projectName} Bundle Diff](${artifactDownloadLink})\n\n`;
96885+ }
9687896886 }
96887+ if (reportsWithChanges.length > 1) commentBody += '</details>\n\n';
9687996888 }
96880- if (reportsWithCurrent.length > 1) commentBody += '</details>\n\n';
9688196889 commentBody += '*Generated by [Rsdoctor GitHub Action](https://rsdoctor.rs/guide/start/action)*';
9688296890 try {
9688396891 await githubService.updateOrCreateComment(context.payload.pull_request.number, commentBody);
0 commit comments