Skip to content

Commit

Permalink
feat: 9
Browse files Browse the repository at this point in the history
  • Loading branch information
lgz5689 committed Jun 7, 2024
1 parent cd1d383 commit 498e4db
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
32 changes: 17 additions & 15 deletions .github/workflows/size-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,27 @@ jobs:
working-directory: main-code
run: pnpm run build

- name: Set DIST_PATH environment variable
id: set-dist-path
working-directory: main-code
run: |
echo "DIST_PATH=$(pwd)/dist" >> $GITHUB_ENV
- name: Checkout PR code
uses: actions/checkout@v4

- name: Install dependencies
run: pnpm install

# - name: Build PR code
# run: pnpm run build

- name: Calculate previous size
id: size-previous
working-directory: main-code
run: |
SCRIPT_PATH=../$($PWD)/scripts/size-report.ts
PREVIOUS_SIZE=$(pnpm tsx $SCRIPT_PATH)
echo "PREVIOUS_SIZE=$(PREVIOUS_SIZE)" >> $GITHUB_ENV
- name: Build PR code
run: pnpm run build

- name: Calculate current size
id: size-current
- name: Calculate size
id: calculate-size
run: |
PREVIOUS_SIZE=$(pnpm tsx scripts/size-report.ts $DIST_PATH)
CURRENT_SIZE=$(pnpm tsx scripts/size-report.ts)
echo "PREVIOUS_SIZE=$(PREVIOUS_SIZE)" >> $GITHUB_ENV
echo "CURRENT_SIZE=$(CURRENT_SIZE)" >> $GITHUB_ENV
- name: Display size difference
Expand All @@ -75,9 +75,11 @@ jobs:
const currentSize = process.env.CURRENT_SIZE;
const message = `
| Difference | Main branch | Current PR |
|------------|-------------|------------|
| Build Size | ${previousSize} | ${currentSize} |
# Size Report
| | Build Size |
|-------------|-----------------|
| Main branch | ${previousSize} |
| Current PR | ${currentSize} |
`;
github.rest.issues.createComment({
Expand Down
2 changes: 1 addition & 1 deletion scripts/size-report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async function calculateSize(directory: string) {
}

async function main() {
const distPath = path.resolve(__dirname, "..", "dist");
const distPath = process.argv[2] || path.resolve(__dirname, "..", "dist");
const distSize = await calculateSize(distPath);
process.stdout.write(prettyBytes(distSize));
}
Expand Down

0 comments on commit 498e4db

Please sign in to comment.