Skip to content

Commit

Permalink
chore: update size file & ci (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgz5689 committed Jun 7, 2024
1 parent bb5da15 commit ccce50d
Show file tree
Hide file tree
Showing 4 changed files with 288 additions and 17 deletions.
28 changes: 19 additions & 9 deletions .github/workflows/size-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,33 @@ jobs:
working-directory: main-code
run: pnpm run build

- name: Calculate previous size
id: size-previous
- name: Set DIST_PATH environment variable
id: set-dist-path
working-directory: main-code
run: |
echo "PREVIOUS_SIZE=$(node scripts/size-report.mjs)" >> $GITHUB_ENV
echo "DIST_PATH=$(pwd)/dist" >> $GITHUB_ENV
- name: Checkout PR code
uses: actions/checkout@v4
with:
path: pr-code

- name: Install dependencies
working-directory: pr-code
run: pnpm install

- name: Build PR code
working-directory: pr-code
run: pnpm run build

- name: Calculate current size
id: size-current
- name: Calculate size
id: calculate-size
working-directory: pr-code
run: |
echo "CURRENT_SIZE=$(node scripts/size-report.mjs)" >> $GITHUB_ENV
PREVIOUS_SIZE=$(pnpm tsx scripts/size-report.ts $DIST_PATH)
echo "PREVIOUS_SIZE=$PREVIOUS_SIZE" >> $GITHUB_ENV
CURRENT_SIZE=$(pnpm tsx scripts/size-report.ts)
echo "CURRENT_SIZE=$CURRENT_SIZE" >> $GITHUB_ENV
- name: Display size difference
run: |
Expand All @@ -72,9 +80,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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"eslint-plugin-react-refresh": "^0.4.5",
"husky": "^8.0.3",
"prettier": "^3.2.2",
"tsx": "^4.12.0",
"typescript": "^5.2.2",
"vite": "^5.0.8",
"vite-electron-plugin": "^0.8.3"
Expand Down
Loading

0 comments on commit ccce50d

Please sign in to comment.