Skip to content

Commit bc68738

Browse files
committed
feat: github diff action
1 parent c7770ad commit bc68738

File tree

3 files changed

+2
-11
lines changed

3 files changed

+2
-11
lines changed

packages/action/src/download.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { setFailed, summary } from '@actions/core';
21
import { DefaultArtifactClient } from '@actions/artifact';
3-
import path from 'path';
2+
import { summary } from '@actions/core';
43
import * as fs from 'fs';
4+
import path from 'path';
55
import { GitHubService } from './github';
66

77
export async function downloadArtifact(artifactId: number, fileName: string) {

packages/action/src/index.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
} from './report';
1010
import path from 'path';
1111

12-
// Helper function to determine if this is a merge event
1312
function isMergeEvent(): boolean {
1413
const { context } = require('@actions/github');
1514
return (
@@ -19,7 +18,6 @@ function isMergeEvent(): boolean {
1918
);
2019
}
2120

22-
// Helper function to determine if this is a PR event
2321
function isPullRequestEvent(): boolean {
2422
const { context } = require('@actions/github');
2523
return context.eventName === 'pull_request';
@@ -71,7 +69,6 @@ function isPullRequestEvent(): boolean {
7169
await generateSizeReport(currentSizeData);
7270
}
7371
} else if (isPullRequestEvent()) {
74-
// MR 提交时:只下载目标分支的工件(如果存在)并生成比较报告
7572
console.log(
7673
'📥 Detected pull request event - downloading target branch artifact if exists',
7774
);
@@ -90,7 +87,6 @@ function isPullRequestEvent(): boolean {
9087
await githubService.getTargetBranchLatestCommit();
9188
console.log(`Target branch commit hash: ${targetCommitHash}`);
9289

93-
// Create artifact name for target branch (same naming pattern)
9490
const targetArtifactName = `${pathParts.join('-')}-${fileNameWithoutExt}-${targetCommitHash}${fileExt}`;
9591
console.log(`Looking for target artifact: ${targetArtifactName}`);
9692

@@ -125,7 +121,6 @@ function isPullRequestEvent(): boolean {
125121
console.log('✅ Successfully loaded demo baseline data');
126122
}
127123

128-
// Generate report card
129124
await generateSizeReport(currentSizeData, baselineSizeData || undefined);
130125
} else {
131126
console.log('🔄 Default behavior - uploading and downloading artifacts');
@@ -140,7 +135,6 @@ function isPullRequestEvent(): boolean {
140135
`✅ Successfully uploaded artifact with ID: ${uploadResponse.id}`,
141136
);
142137

143-
// Try to download target branch artifact
144138
try {
145139
const targetCommitHash =
146140
await githubService.getTargetBranchLatestCommit();
@@ -173,7 +167,6 @@ function isPullRequestEvent(): boolean {
173167
console.warn(`⚠️ Failed to download target branch artifact: ${error}`);
174168
console.log('📝 Using demo baseline data for comparison');
175169

176-
// Generate report card with demo baseline
177170
const currentSizeData = loadSizeData(fullPath);
178171
if (currentSizeData) {
179172
const demoBaseline = getDemoBaselineData();

packages/action/src/upload.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import { setFailed, summary } from '@actions/core';
21
import { DefaultArtifactClient } from '@actions/artifact';
32
import path from 'path';
4-
import * as fs from 'fs';
53
import { execSync } from 'child_process';
64

75
export async function uploadArtifact(commitHash?: string, filePath?: string) {

0 commit comments

Comments
 (0)