Skip to content

build(deps-dev): bump pkg-pr-new from 0.0.41 to 0.0.62 #420

build(deps-dev): bump pkg-pr-new from 0.0.41 to 0.0.62

build(deps-dev): bump pkg-pr-new from 0.0.41 to 0.0.62 #420

Workflow file for this run

name: Tree-shake test
on:
pull_request:
workflow_dispatch:
inputs:
target_branch:
description: 'Target branch to compare against'
required: true
default: 'main'
jobs:
treeshake-test:
permissions:
contents: read
issues: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10.27.0
run_install: false
- name: Checkout PR branch
uses: actions/checkout@v4
with:
path: pr-branch
- name: Checkout target branch
uses: actions/checkout@v4
with:
path: target-branch
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.target_branch || github.base_ref }}
- name: Install dependencies (PR branch)
working-directory: pr-branch
run: pnpm install
- name: Install dependencies (target branch)
working-directory: target-branch
run: pnpm install
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22.x
cache: 'pnpm'
cache-dependency-path: |
pr-branch/pnpm-lock.yaml
target-branch/pnpm-lock.yaml
- name: Generate import tests on PR branch
working-directory: pr-branch
run: pnpm --filter treeshake-test generate-tests
- name: Generate import tests on target branch
working-directory: target-branch
run: pnpm --filter treeshake-test generate-tests
- name: Run tree-shake test on PR branch
working-directory: pr-branch
run: pnpm --filter treeshake-test test --tsdown ${{ github.event_name == 'workflow_dispatch' && '--webpack' || '' }}
- name: Run tree-shake test on target branch
working-directory: target-branch
run: pnpm --filter treeshake-test test --tsdown ${{ github.event_name == 'workflow_dispatch' && '--webpack' || '' }}
- name: Compare results
run: |
node pr-branch/apps/treeshake-test/compareResults.ts \
pr-branch/apps/treeshake-test/results.json \
target-branch/apps/treeshake-test/results.json \
> comparison.md
- name: Comment PR with results
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const comparison = fs.readFileSync('comparison.md', 'utf8');
const botCommentIdentifier = '<!-- treeshake-test-bot-comment -->';
async function findBotComment(issueNumber) {
if (!issueNumber) return null;
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
});
return comments.data.find((comment) =>
comment.body.includes(botCommentIdentifier)
);
}
async function createOrUpdateComment(issueNumber) {
if (!issueNumber) {
console.log('No issue number provided. Cannot post or update comment.');
return;
}
const existingComment = await findBotComment(issueNumber);
if (existingComment) {
await github.rest.issues.updateComment({
...context.repo,
comment_id: existingComment.id,
body: botCommentIdentifier + '\n' + comparison,
});
} else {
await github.rest.issues.createComment({
...context.repo,
issue_number: issueNumber,
body: botCommentIdentifier + '\n' + comparison,
});
}
}
const issueNumber = context.issue.number;
if (!issueNumber) {
console.log('No issue number found in context. Skipping comment.');
} else {
await createOrUpdateComment(issueNumber);
}
await core.summary
.addRaw(comparison)
.write();