forked from mirrors/misskey
163 lines
6.1 KiB
YAML
163 lines
6.1 KiB
YAML
name: frontend-bundle-report
|
|
|
|
on:
|
|
pull_request:
|
|
types:
|
|
- opened
|
|
- synchronize
|
|
- reopened
|
|
- ready_for_review
|
|
paths:
|
|
- packages/frontend/**
|
|
- packages/frontend-shared/**
|
|
- packages/frontend-builder/**
|
|
- packages/i18n/**
|
|
- packages/icons-subsetter/**
|
|
- packages/misskey-js/**
|
|
- packages/misskey-reversi/**
|
|
- packages/misskey-bubble-game/**
|
|
- package.json
|
|
- pnpm-lock.yaml
|
|
- pnpm-workspace.yaml
|
|
- .node-version
|
|
- .github/scripts/frontend-js-size.mjs
|
|
- .github/scripts/frontend-bundle-visualizer-report.mjs
|
|
- .github/workflows/frontend-bundle-report.yml
|
|
- .github/workflows/frontend-bundle-report-comment.yml
|
|
|
|
permissions:
|
|
contents: read
|
|
pull-requests: read
|
|
|
|
concurrency:
|
|
group: frontend-bundle-report-${{ github.event.pull_request.number }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
report:
|
|
name: Build frontend bundle report
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
FRONTEND_JS_SIZE_LOCALE: ja-JP
|
|
steps:
|
|
- name: Checkout base
|
|
uses: actions/checkout@v6.0.2
|
|
with:
|
|
repository: ${{ github.event.pull_request.base.repo.full_name }}
|
|
ref: ${{ github.event.pull_request.base.sha }}
|
|
path: before
|
|
submodules: true
|
|
|
|
- name: Checkout pull request
|
|
uses: actions/checkout@v6.0.2
|
|
with:
|
|
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
path: after
|
|
submodules: true
|
|
|
|
- name: Check base visualizer support
|
|
id: check-base-visualizer
|
|
shell: bash
|
|
run: |
|
|
if grep -q 'FRONTEND_BUNDLE_VISUALIZER' before/packages/frontend/vite.config.ts; then
|
|
echo 'supported=true' >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo 'supported=false' >> "$GITHUB_OUTPUT"
|
|
echo 'Base commit does not support frontend bundle visualizer. Skipping frontend bundle report.' >> "$GITHUB_STEP_SUMMARY"
|
|
fi
|
|
|
|
- name: Setup pnpm
|
|
if: steps.check-base-visualizer.outputs.supported == 'true'
|
|
uses: pnpm/action-setup@v6.0.3
|
|
with:
|
|
package_json_file: after/package.json
|
|
|
|
- name: Setup Node.js
|
|
if: steps.check-base-visualizer.outputs.supported == 'true'
|
|
uses: actions/setup-node@v6.4.0
|
|
with:
|
|
node-version-file: after/.node-version
|
|
cache: pnpm
|
|
cache-dependency-path: |
|
|
before/pnpm-lock.yaml
|
|
after/pnpm-lock.yaml
|
|
|
|
- name: Install dependencies for base
|
|
if: steps.check-base-visualizer.outputs.supported == 'true'
|
|
working-directory: before
|
|
run: pnpm i --frozen-lockfile
|
|
|
|
- name: Build frontend dependencies for base
|
|
if: steps.check-base-visualizer.outputs.supported == 'true'
|
|
working-directory: before
|
|
run: pnpm --filter "frontend^..." run build
|
|
|
|
- name: Prepare report output
|
|
if: steps.check-base-visualizer.outputs.supported == 'true'
|
|
run: mkdir -p "$RUNNER_TEMP/frontend-bundle-report"
|
|
|
|
- name: Build frontend report for base
|
|
if: steps.check-base-visualizer.outputs.supported == 'true'
|
|
working-directory: before
|
|
env:
|
|
FRONTEND_BUNDLE_VISUALIZER: 'true'
|
|
FRONTEND_BUNDLE_VISUALIZER_TEMPLATE: raw-data
|
|
FRONTEND_BUNDLE_VISUALIZER_FILE: ${{ runner.temp }}/frontend-bundle-report/before-stats.json
|
|
run: pnpm --filter frontend run build
|
|
|
|
- name: Install dependencies for pull request
|
|
if: steps.check-base-visualizer.outputs.supported == 'true'
|
|
working-directory: after
|
|
run: pnpm i --frozen-lockfile
|
|
|
|
- name: Build frontend dependencies for pull request
|
|
if: steps.check-base-visualizer.outputs.supported == 'true'
|
|
working-directory: after
|
|
run: pnpm --filter "frontend^..." run build
|
|
|
|
- name: Build frontend report for pull request
|
|
if: steps.check-base-visualizer.outputs.supported == 'true'
|
|
working-directory: after
|
|
env:
|
|
FRONTEND_BUNDLE_VISUALIZER: 'true'
|
|
FRONTEND_BUNDLE_VISUALIZER_TEMPLATE: raw-data
|
|
FRONTEND_BUNDLE_VISUALIZER_FILE: ${{ runner.temp }}/frontend-bundle-report/after-stats.json
|
|
run: pnpm --filter frontend run build
|
|
|
|
- name: Generate report markdown
|
|
if: steps.check-base-visualizer.outputs.supported == 'true'
|
|
shell: bash
|
|
env:
|
|
BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
|
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
run: |
|
|
REPORT_DIR="$RUNNER_TEMP/frontend-bundle-report"
|
|
node after/.github/scripts/frontend-js-size.mjs before after "$REPORT_DIR/frontend-js-size-report.md"
|
|
node after/.github/scripts/frontend-bundle-visualizer-report.mjs "$REPORT_DIR/before-stats.json" "$REPORT_DIR/after-stats.json" "$REPORT_DIR/frontend-bundle-visualizer-report.md"
|
|
printf '%s\n' "$PR_NUMBER" > "$REPORT_DIR/pr-number.txt"
|
|
printf '%s\n' "$BASE_SHA" > "$REPORT_DIR/base-sha.txt"
|
|
printf '%s\n' "$HEAD_SHA" > "$REPORT_DIR/head-sha.txt"
|
|
printf '%s\n' "${{ github.event.pull_request.html_url }}" > "$REPORT_DIR/pr-url.txt"
|
|
|
|
- name: Check report
|
|
if: steps.check-base-visualizer.outputs.supported == 'true'
|
|
run: |
|
|
REPORT_DIR="$RUNNER_TEMP/frontend-bundle-report"
|
|
test -s "$REPORT_DIR/before-stats.json"
|
|
test -s "$REPORT_DIR/after-stats.json"
|
|
test -s "$REPORT_DIR/frontend-js-size-report.md"
|
|
test -s "$REPORT_DIR/frontend-bundle-visualizer-report.md"
|
|
cat "$REPORT_DIR/frontend-js-size-report.md" >> "$GITHUB_STEP_SUMMARY"
|
|
printf '\n\n' >> "$GITHUB_STEP_SUMMARY"
|
|
cat "$REPORT_DIR/frontend-bundle-visualizer-report.md" >> "$GITHUB_STEP_SUMMARY"
|
|
|
|
- name: Upload bundle report
|
|
if: steps.check-base-visualizer.outputs.supported == 'true'
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: frontend-bundle-report
|
|
path: ${{ runner.temp }}/frontend-bundle-report/
|
|
if-no-files-found: error
|
|
retention-days: 7
|