From f703413a39142d07e7ebe13395f7ad16f18646f0 Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Tue, 23 Jun 2026 16:14:54 +0900 Subject: [PATCH 1/6] chore(dev): tweak frontend-js-size.mjs --- .github/scripts/frontend-js-size.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/frontend-js-size.mjs b/.github/scripts/frontend-js-size.mjs index db83bd888a..561fcd80c7 100644 --- a/.github/scripts/frontend-js-size.mjs +++ b/.github/scripts/frontend-js-size.mjs @@ -411,7 +411,7 @@ function chunkMarkdownTable(rows, total) { '| --- | ---: | ---: | ---: | ---: |', ]; if (total != null) { - lines.push(`| (total) | ${formatBytes(total.beforeSize)} | ${formatBytes(total.afterSize)} | ${formatBytesDiff(total.beforeSize, total.afterSize)} | ${formatDiffPercent(total.beforeSize, total.afterSize)} |`); + lines.push(`| (total) | ${formatBytes(total.beforeSize)} | ${formatBytes(total.afterSize)} | ${formatBytesDiff(total.beforeSize, total.afterSize)} | ${formatDiffPercent(total.beforeSize, total.afterSize).replaceAll('\\%', '\\\\%')} |`); lines.push('| | | | | |'); } for (const row of rows) { From f6cfe15860ca75fe6cf340d1ae848ace36152a55 Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Tue, 23 Jun 2026 16:31:17 +0900 Subject: [PATCH 2/6] chore(dev): tweak frontend-js-size.mjs --- .github/scripts/frontend-js-size.mjs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/scripts/frontend-js-size.mjs b/.github/scripts/frontend-js-size.mjs index 561fcd80c7..ca37ea518f 100644 --- a/.github/scripts/frontend-js-size.mjs +++ b/.github/scripts/frontend-js-size.mjs @@ -464,14 +464,14 @@ function renderFrontendChunkReport(before, after) { return [ '
', - `${formatChunkChangeSummary('Diffs', diffSummary)}`, + `${formatChunkChangeSummary('Chunk size diff', diffSummary)}`, '', chunkMarkdownTable(diffRows, diffTotal), '', '
', '', '
', - `${formatChunkChangeSummary('Startup', startupSummary)}`, + `${formatChunkChangeSummary('Startup chunk size', startupSummary)}`, '', chunkMarkdownTable(startupRows, startupTotal), '', @@ -493,11 +493,12 @@ function renderFrontendBundleReport(before, after) { const lines = [ ...renderVisualizerSummaryTable(before, after), '', - '
', - 'Top 10', - '', + //'
', + //'Top 10', + //'', ]; + /* for (const row of after.hotModules.slice(0, 10)) { lines.push(`- ${code(row.id)}: ${sharePercent(row.renderedLength, after.metrics.renderedLength)} (${formatBytes(row.renderedLength)})`); } @@ -524,6 +525,7 @@ function renderFrontendBundleReport(before, after) { '', '
', ); + */ return lines.join('\n'); } @@ -538,11 +540,11 @@ const afterStats = JSON.parse(await fs.readFile(afterStatsFile, 'utf8')); const body = [ marker, '', - `## Frontend Chunk Report`, + `## Frontend Bundle Report`, '', renderFrontendChunkReport(before, after), '', - '## Frontend Bundle Report', + '## Bundle Stats', '', renderFrontendBundleReport(collectVisualizerReport(beforeStats), collectVisualizerReport(afterStats)), ].join('\n'); From e77184ffdb1b4032dc56563050186ba93607b8a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8A=E3=81=95=E3=82=80=E3=81=AE=E3=81=B2=E3=81=A8?= <46447427+samunohito@users.noreply.github.com> Date: Wed, 24 Jun 2026 11:36:23 +0900 Subject: [PATCH 3/6] chore(ci): simplify FFmpeg installation in workflows (#17612) * chore(ci): simplify FFmpeg installation in workflows * fix --- .github/workflows/test-backend.yml | 35 +-------------------------- .github/workflows/test-federation.yml | 35 +-------------------------- 2 files changed, 2 insertions(+), 68 deletions(-) diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml index b8eb0e2493..198451c0e9 100644 --- a/.github/workflows/test-backend.yml +++ b/.github/workflows/test-backend.yml @@ -19,12 +19,6 @@ on: - .github/workflows/test-backend.yml - .github/misskey/test.yml workflow_dispatch: - inputs: - force_ffmpeg_cache_update: - description: 'Force update ffmpeg cache' - required: false - default: false - type: boolean jobs: unit: @@ -62,36 +56,9 @@ jobs: submodules: true - name: Setup pnpm uses: pnpm/action-setup@v6.0.3 - - name: Get current date - id: current-date - run: echo "today=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT - - name: Setup and Restore ffmpeg/ffprobe Cache - id: cache-ffmpeg - uses: actions/cache@v5 - with: - path: | - /usr/local/bin/ffmpeg - /usr/local/bin/ffprobe - # daily cache - key: ${{ runner.os }}-ffmpeg-${{ steps.current-date.outputs.today }} - restore-keys: | - ${{ runner.os }}-ffmpeg-${{ steps.current-date.outputs.today }} - name: Install FFmpeg - if: steps.cache-ffmpeg.outputs.cache-hit != 'true' || github.event.inputs.force_ffmpeg_cache_update == true run: | - for i in {1..3}; do - echo "Attempt $i: Installing FFmpeg..." - curl -s -L https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz -o ffmpeg.tar.xz && \ - tar -xf ffmpeg.tar.xz && \ - mv ffmpeg-*-static/ffmpeg /usr/local/bin/ && \ - mv ffmpeg-*-static/ffprobe /usr/local/bin/ && \ - rm -rf ffmpeg.tar.xz ffmpeg-*-static/ && \ - break || sleep 10 - if [ $i -eq 3 ]; then - echo "Failed to install FFmpeg after 3 attempts" - exit 1 - fi - done + sudo apt install -y ffmpeg - name: Use Node.js uses: actions/setup-node@v6.4.0 with: diff --git a/.github/workflows/test-federation.yml b/.github/workflows/test-federation.yml index a8b7831f44..0433931531 100644 --- a/.github/workflows/test-federation.yml +++ b/.github/workflows/test-federation.yml @@ -15,12 +15,6 @@ on: - packages/misskey-js/** - .github/workflows/test-federation.yml workflow_dispatch: - inputs: - force_ffmpeg_cache_update: - description: 'Force update ffmpeg cache' - required: false - default: false - type: boolean jobs: test: @@ -37,36 +31,9 @@ jobs: submodules: true - name: Setup pnpm uses: pnpm/action-setup@v6.0.3 - - name: Get current date - id: current-date - run: echo "today=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT - - name: Setup and Restore ffmpeg/ffprobe Cache - id: cache-ffmpeg - uses: actions/cache@v5 - with: - path: | - /usr/local/bin/ffmpeg - /usr/local/bin/ffprobe - # daily cache - key: ${{ runner.os }}-ffmpeg-${{ steps.current-date.outputs.today }} - restore-keys: | - ${{ runner.os }}-ffmpeg-${{ steps.current-date.outputs.today }} - name: Install FFmpeg - if: steps.cache-ffmpeg.outputs.cache-hit != 'true' || github.event.inputs.force_ffmpeg_cache_update == true run: | - for i in {1..3}; do - echo "Attempt $i: Installing FFmpeg..." - curl -s -L https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz -o ffmpeg.tar.xz && \ - tar -xf ffmpeg.tar.xz && \ - mv ffmpeg-*-static/ffmpeg /usr/local/bin/ && \ - mv ffmpeg-*-static/ffprobe /usr/local/bin/ && \ - rm -rf ffmpeg.tar.xz ffmpeg-*-static/ && \ - break || sleep 10 - if [ $i -eq 3 ]; then - echo "Failed to install FFmpeg after 3 attempts" - exit 1 - fi - done + sudo apt install -y ffmpeg - name: Use Node.js uses: actions/setup-node@v6.4.0 with: From 3e1a0906579aa1a456e97210ba7276e6e72f6b67 Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Wed, 24 Jun 2026 13:30:13 +0900 Subject: [PATCH 4/6] fix(dev): tweak frontend-js-size.mjs --- .github/scripts/frontend-js-size.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/frontend-js-size.mjs b/.github/scripts/frontend-js-size.mjs index ca37ea518f..cae5b769ed 100644 --- a/.github/scripts/frontend-js-size.mjs +++ b/.github/scripts/frontend-js-size.mjs @@ -91,7 +91,7 @@ function formatDiffPercent(before, after) { if (before == null || before === 0 || after == null || after === 0) return '-'; const diff = after - before; if (diff === 0) return `0%`; - const percent = Math.round(diff / before * 100); + const percent = Math.abs(Math.round(diff / before * 100)); return formatColoredDiff(`${percent}%`, diff); } From e12f97b1d82b122b29e2fa63f7851b7e0d39b9ea Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Wed, 24 Jun 2026 15:01:37 +0900 Subject: [PATCH 5/6] enhance(dev): improve Frontend Bundle Report --- .github/scripts/frontend-js-size.mjs | 9 +++++ .github/workflows/frontend-bundle-report.yml | 17 +++++++-- packages/frontend/vite.config.ts | 38 ++++++++++---------- 3 files changed, 44 insertions(+), 20 deletions(-) diff --git a/.github/scripts/frontend-js-size.mjs b/.github/scripts/frontend-js-size.mjs index cae5b769ed..e9c985b652 100644 --- a/.github/scripts/frontend-js-size.mjs +++ b/.github/scripts/frontend-js-size.mjs @@ -530,6 +530,13 @@ function renderFrontendBundleReport(before, after) { return lines.join('\n'); } +function renderVisualizerArtifactLink() { + const artifactUrl = process.env.FRONTEND_BUNDLE_REPORT_ARTIFACT_URL; + const artifactName = process.env.FRONTEND_BUNDLE_REPORT_ARTIFACT_NAME || 'frontend-bundle-report'; + const htmlFile = process.env.FRONTEND_BUNDLE_REPORT_HTML_FILE || 'frontend-bundle-visualizer.html'; + return `> [Bundle visualizer HTML](${artifactUrl}) is included in the ${code(artifactName)} artifact as ${code(htmlFile)}.`; +} + const args = process.argv.slice(2); const [beforeDir, afterDir, beforeStatsFile, afterStatsFile, outFile] = args; const before = await collectReport(beforeDir); @@ -547,6 +554,8 @@ const body = [ '## Bundle Stats', '', renderFrontendBundleReport(collectVisualizerReport(beforeStats), collectVisualizerReport(afterStats)), + '', + renderVisualizerArtifactLink(), ].join('\n'); await fs.writeFile(outFile, body); diff --git a/.github/workflows/frontend-bundle-report.yml b/.github/workflows/frontend-bundle-report.yml index e040bc390f..eb6c64e5f7 100644 --- a/.github/workflows/frontend-bundle-report.yml +++ b/.github/workflows/frontend-bundle-report.yml @@ -101,7 +101,6 @@ jobs: 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 @@ -120,10 +119,20 @@ jobs: 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 + FRONTEND_BUNDLE_VISUALIZER_HTML_FILE: ${{ runner.temp }}/frontend-bundle-report/frontend-bundle-visualizer.html run: pnpm --filter frontend run build + - name: Upload bundle visualizer + if: steps.check-base-visualizer.outputs.supported == 'true' + id: upload-bundle-visualizer + uses: actions/upload-artifact@v7 + with: + name: frontend-bundle-visualizer + path: ${{ runner.temp }}/frontend-bundle-report/frontend-bundle-visualizer.html + if-no-files-found: error + retention-days: 7 + - name: Generate report markdown if: steps.check-base-visualizer.outputs.supported == 'true' shell: bash @@ -131,6 +140,9 @@ jobs: BASE_SHA: ${{ github.event.pull_request.base.sha }} HEAD_SHA: ${{ github.event.pull_request.head.sha }} PR_NUMBER: ${{ github.event.pull_request.number }} + FRONTEND_BUNDLE_REPORT_ARTIFACT_URL: ${{ steps.upload-bundle-visualizer.outputs.artifact-url }} + FRONTEND_BUNDLE_REPORT_ARTIFACT_NAME: frontend-bundle-visualizer + FRONTEND_BUNDLE_REPORT_HTML_FILE: frontend-bundle-visualizer.html run: | REPORT_DIR="$RUNNER_TEMP/frontend-bundle-report" node after/.github/scripts/frontend-js-size.mjs before after "$REPORT_DIR/before-stats.json" "$REPORT_DIR/after-stats.json" "$REPORT_DIR/frontend-js-size-report.md" @@ -145,6 +157,7 @@ jobs: 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-bundle-visualizer.html" test -s "$REPORT_DIR/frontend-js-size-report.md" cat "$REPORT_DIR/frontend-js-size-report.md" >> "$GITHUB_STEP_SUMMARY" diff --git a/packages/frontend/vite.config.ts b/packages/frontend/vite.config.ts index b1413be0a4..8cf725b1a1 100644 --- a/packages/frontend/vite.config.ts +++ b/packages/frontend/vite.config.ts @@ -27,27 +27,29 @@ const extensions = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.json', '.json5', '.s function getBundleVisualizerPlugin(): PluginOption[] { if (process.env.FRONTEND_BUNDLE_VISUALIZER !== 'true') return []; - const template = process.env.FRONTEND_BUNDLE_VISUALIZER_TEMPLATE === 'markdown' - ? 'markdown' - : process.env.FRONTEND_BUNDLE_VISUALIZER_TEMPLATE === 'raw-data' - ? 'raw-data' - : 'treemap'; - const defaultFilename = template === 'markdown' - ? path.resolve(__dirname, '../../built/_frontend_bundle_visualizer_/report.md') - : template === 'raw-data' - ? path.resolve(__dirname, '../../built/_frontend_bundle_visualizer_/stats.json') - : path.resolve(__dirname, '../../built/_frontend_bundle_visualizer_/stats.html'); - - return [ + const visualizerOptions = { + title: 'Misskey frontend bundle visualizer', + gzipSize: true, + brotliSize: true, + projectRoot: path.resolve(__dirname, '../..'), + }; + const plugins = [ visualizer({ - filename: process.env.FRONTEND_BUNDLE_VISUALIZER_FILE ?? defaultFilename, - title: 'Misskey frontend bundle visualizer', - template, - gzipSize: true, - brotliSize: true, - projectRoot: path.resolve(__dirname, '../..'), + ...visualizerOptions, + filename: process.env.FRONTEND_BUNDLE_VISUALIZER_FILE, + template: 'raw-data', }) as PluginOption, ]; + + if (process.env.FRONTEND_BUNDLE_VISUALIZER_HTML_FILE != null) { + plugins.push(visualizer({ + ...visualizerOptions, + filename: process.env.FRONTEND_BUNDLE_VISUALIZER_HTML_FILE, + template: 'treemap', + }) as PluginOption); + } + + return plugins; } /** From 117355078459b078ac2afd117e54680759bcd10f Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Wed, 24 Jun 2026 15:08:43 +0900 Subject: [PATCH 6/6] chore(dev): refactor frontend bundle report --- .github/scripts/frontend-js-size.mjs | 10 ++-------- .github/workflows/frontend-bundle-report.yml | 3 --- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/.github/scripts/frontend-js-size.mjs b/.github/scripts/frontend-js-size.mjs index e9c985b652..ce5fd10deb 100644 --- a/.github/scripts/frontend-js-size.mjs +++ b/.github/scripts/frontend-js-size.mjs @@ -530,19 +530,13 @@ function renderFrontendBundleReport(before, after) { return lines.join('\n'); } -function renderVisualizerArtifactLink() { - const artifactUrl = process.env.FRONTEND_BUNDLE_REPORT_ARTIFACT_URL; - const artifactName = process.env.FRONTEND_BUNDLE_REPORT_ARTIFACT_NAME || 'frontend-bundle-report'; - const htmlFile = process.env.FRONTEND_BUNDLE_REPORT_HTML_FILE || 'frontend-bundle-visualizer.html'; - return `> [Bundle visualizer HTML](${artifactUrl}) is included in the ${code(artifactName)} artifact as ${code(htmlFile)}.`; -} - const args = process.argv.slice(2); const [beforeDir, afterDir, beforeStatsFile, afterStatsFile, outFile] = args; const before = await collectReport(beforeDir); const after = await collectReport(afterDir); const beforeStats = JSON.parse(await fs.readFile(beforeStatsFile, 'utf8')); const afterStats = JSON.parse(await fs.readFile(afterStatsFile, 'utf8')); +const visualizerArtifactLink = `> [Bundle visualizer HTML](${process.env.FRONTEND_BUNDLE_REPORT_ARTIFACT_URL}) is included in the ${code('frontend-bundle-visualizer')} artifact as ${code('frontend-bundle-visualizer.html')}.`; const body = [ marker, @@ -555,7 +549,7 @@ const body = [ '', renderFrontendBundleReport(collectVisualizerReport(beforeStats), collectVisualizerReport(afterStats)), '', - renderVisualizerArtifactLink(), + visualizerArtifactLink, ].join('\n'); await fs.writeFile(outFile, body); diff --git a/.github/workflows/frontend-bundle-report.yml b/.github/workflows/frontend-bundle-report.yml index eb6c64e5f7..b249fa8a79 100644 --- a/.github/workflows/frontend-bundle-report.yml +++ b/.github/workflows/frontend-bundle-report.yml @@ -141,8 +141,6 @@ jobs: HEAD_SHA: ${{ github.event.pull_request.head.sha }} PR_NUMBER: ${{ github.event.pull_request.number }} FRONTEND_BUNDLE_REPORT_ARTIFACT_URL: ${{ steps.upload-bundle-visualizer.outputs.artifact-url }} - FRONTEND_BUNDLE_REPORT_ARTIFACT_NAME: frontend-bundle-visualizer - FRONTEND_BUNDLE_REPORT_HTML_FILE: frontend-bundle-visualizer.html run: | REPORT_DIR="$RUNNER_TEMP/frontend-bundle-report" node after/.github/scripts/frontend-js-size.mjs before after "$REPORT_DIR/before-stats.json" "$REPORT_DIR/after-stats.json" "$REPORT_DIR/frontend-js-size-report.md" @@ -157,7 +155,6 @@ jobs: 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-bundle-visualizer.html" test -s "$REPORT_DIR/frontend-js-size-report.md" cat "$REPORT_DIR/frontend-js-size-report.md" >> "$GITHUB_STEP_SUMMARY"