1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-07-25 16:45:00 +02:00

frontend bundle diagnostics と frontend browser diagnostics を統合 (#17757)

* refactor(gh): unify frontend diagnostics

* refactor(gh): unify frontend diagnostics markdown rendering

* docs(gh): restore frontend diagnostics comments

* wip

* fix

* refactor: 呼称をbase/headに統一

* tweak

* Update types.ts

* fix
This commit is contained in:
syuilo
2026-07-21 11:26:53 +09:00
committed by GitHub
parent 159b1a4484
commit b51d5ba0a0
47 changed files with 693 additions and 810 deletions

View File

@@ -1,44 +0,0 @@
name: Frontend browser diagnostics (comment)
on:
workflow_run:
workflows:
- Frontend browser diagnostics (inspect)
types:
- completed
permissions:
actions: read
contents: read
issues: write
pull-requests: write
jobs:
comment:
name: Comment frontend browser diagnostics report
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
concurrency:
group: frontend-browser-diagnostics-report-${{ github.event.workflow_run.id }}
cancel-in-progress: true
steps:
- name: Download browser metrics report
uses: actions/download-artifact@v8
with:
name: frontend-browser-diagnostics
path: ${{ runner.temp }}/frontend-browser-diagnostics
github-token: ${{ github.token }}
repository: ${{ github.repository }}
run-id: ${{ github.event.workflow_run.id }}
- name: Load PR number
id: load-pr-number
shell: bash
run: echo "pr-number=$(cat "$RUNNER_TEMP/frontend-browser-diagnostics/pr-number.txt")" >> "$GITHUB_OUTPUT"
- name: Comment on pull request
uses: thollander/actions-comment-pull-request@v3
with:
pr-number: ${{ steps.load-pr-number.outputs.pr-number }}
comment-tag: frontend-browser-diagnostics
file-path: ${{ runner.temp }}/frontend-browser-diagnostics/frontend-browser-diagnostics.md

View File

@@ -1,44 +0,0 @@
name: Frontend bundle diagnostics (comment)
on:
workflow_run:
workflows:
- Frontend bundle diagnostics (inspect)
types:
- completed
permissions:
actions: read
contents: read
issues: write
pull-requests: write
jobs:
comment:
name: Comment frontend bundle report
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
concurrency:
group: frontend-bundle-diagnostics-report-${{ github.event.workflow_run.id }}
cancel-in-progress: true
steps:
- name: Download bundle report
uses: actions/download-artifact@v8
with:
name: frontend-bundle-report
path: ${{ runner.temp }}/frontend-bundle-report
github-token: ${{ github.token }}
repository: ${{ github.repository }}
run-id: ${{ github.event.workflow_run.id }}
- name: Load PR number
id: load-pr-number
shell: bash
run: echo "pr-number=$(cat "$RUNNER_TEMP/frontend-bundle-report/pr-number.txt")" >> "$GITHUB_OUTPUT"
- name: Comment on pull request
uses: thollander/actions-comment-pull-request@v3
with:
pr-number: ${{ steps.load-pr-number.outputs.pr-number }}
comment-tag: frontend-bundle-diagnostics
file-path: ${{ runner.temp }}/frontend-bundle-report/frontend-bundle-diagnostics-report.md

View File

@@ -1,148 +0,0 @@
name: Frontend bundle diagnostics (inspect)
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
- packages-private/diagnostics-shared/**
- packages-private/diagnostics-frontend-bundle/**
- .github/workflows/frontend-bundle-diagnostics.inspect.yml
- .github/workflows/frontend-bundle-diagnostics.comment.yml
permissions:
contents: read
pull-requests: read
concurrency:
group: frontend-bundle-diagnostics-inspect-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
report:
name: Build frontend bundle report
runs-on: ubuntu-latest
steps:
- name: Checkout base
uses: actions/checkout@v6.0.3
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.3
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
path: after
submodules: true
- name: Setup pnpm
uses: pnpm/action-setup@v6.0.9
with:
package_json_file: after/package.json
- name: Setup Node.js
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
working-directory: before
run: pnpm i --frozen-lockfile
- name: Build frontend dependencies for base
working-directory: before
run: pnpm --filter "frontend^..." run build
- name: Prepare report output
run: mkdir -p "$RUNNER_TEMP/frontend-bundle-report"
- name: Build frontend report for base
working-directory: before
env:
FRONTEND_BUNDLE_VISUALIZER: 'true'
FRONTEND_BUNDLE_VISUALIZER_FILE: ${{ runner.temp }}/frontend-bundle-report/before-stats.json
run: pnpm --filter frontend run build
- name: Install dependencies for pull request
working-directory: after
run: pnpm i --frozen-lockfile
- name: Build frontend dependencies for pull request
working-directory: after
run: pnpm --filter "frontend^..." run build
- name: Build frontend report for pull request
working-directory: after
env:
FRONTEND_BUNDLE_VISUALIZER: 'true'
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
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
archive: false
retention-days: 7
- name: Generate report markdown
shell: bash
working-directory: after
env:
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 }}
run: |
REPORT_DIR="$RUNNER_TEMP/frontend-bundle-report"
pnpm --filter diagnostics-frontend-bundle run render-md \
"$GITHUB_WORKSPACE/before" "$GITHUB_WORKSPACE/after" \
"$REPORT_DIR/before-stats.json" "$REPORT_DIR/after-stats.json" \
"$REPORT_DIR/frontend-bundle-diagnostics-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
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-bundle-diagnostics-report.md"
cat "$REPORT_DIR/frontend-bundle-diagnostics-report.md" >> "$GITHUB_STEP_SUMMARY"
- name: Upload bundle report
uses: actions/upload-artifact@v7
with:
name: frontend-bundle-report
path: ${{ runner.temp }}/frontend-bundle-report/
if-no-files-found: error
retention-days: 7

View File

@@ -0,0 +1,75 @@
name: Frontend diagnostics (comment)
on:
workflow_run:
workflows:
- Frontend diagnostics (inspect)
types:
- completed
permissions:
actions: read
contents: read
issues: write
pull-requests: write
jobs:
comment:
name: Comment frontend diagnostics report
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
concurrency:
group: frontend-diagnostics-report-${{ github.event.workflow_run.id }}
cancel-in-progress: true
steps:
- name: Download frontend diagnostics report
uses: actions/download-artifact@v8
with:
name: frontend-diagnostics
path: ${{ runner.temp }}/frontend-diagnostics
github-token: ${{ github.token }}
repository: ${{ github.repository }}
run-id: ${{ github.event.workflow_run.id }}
- name: Resolve current pull request
id: resolve-pr
uses: actions/github-script@v9
env:
PR_NUMBER_FILE: ${{ runner.temp }}/frontend-diagnostics/pr-number.txt
with:
script: |
const fs = require('fs/promises');
const { owner, repo } = context.repo;
const workflowRun = context.payload.workflow_run;
const pullRequestNumberText = (await fs.readFile(process.env.PR_NUMBER_FILE, 'utf8')).trim();
if (!/^[1-9]\d*$/.test(pullRequestNumberText)) {
throw new Error('Invalid pull request number in frontend diagnostics artifact.');
}
const pullRequestNumber = Number(pullRequestNumberText);
if (!Number.isSafeInteger(pullRequestNumber)) {
throw new Error('Pull request number in frontend diagnostics artifact is not a safe integer.');
}
const { data: currentPullRequest } = await github.rest.pulls.get({
owner,
repo,
pull_number: pullRequestNumber,
});
if (currentPullRequest.state !== 'open' || currentPullRequest.head.sha !== workflowRun.head_sha) {
core.notice(`Skipping stale frontend diagnostics report for pull request #${pullRequestNumber}.`);
core.setOutput('is-current', 'false');
return;
}
core.setOutput('is-current', 'true');
core.setOutput('pr-number', String(pullRequestNumber));
- name: Comment on pull request
if: steps.resolve-pr.outputs.is-current == 'true'
uses: thollander/actions-comment-pull-request@v3
with:
pr-number: ${{ steps.resolve-pr.outputs.pr-number }}
comment-tag: frontend-diagnostics
file-path: ${{ runner.temp }}/frontend-diagnostics/frontend-diagnostics.md

View File

@@ -1,4 +1,4 @@
name: Frontend browser diagnostics (inspect)
name: Frontend diagnostics (inspect)
on:
pull_request:
@@ -23,21 +23,21 @@ on:
- .node-version
- .github/misskey/test.yml
- packages-private/diagnostics-shared/**
- packages-private/diagnostics-frontend-browser/**
- .github/workflows/frontend-browser-diagnostics.inspect.yml
- .github/workflows/frontend-browser-diagnostics.comment.yml
- packages-private/diagnostics-frontend/**
- .github/workflows/frontend-diagnostics.inspect.yml
- .github/workflows/frontend-diagnostics.comment.yml
permissions:
contents: read
pull-requests: read
concurrency:
group: frontend-browser-diagnostics-inspect-${{ github.event.pull_request.number }}
group: frontend-diagnostics-inspect-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
report:
name: Measure frontend browser metrics
name: Measure frontend diagnostics
runs-on: ubuntu-latest
timeout-minutes: 90
@@ -61,79 +61,100 @@ jobs:
persist-credentials: false
repository: ${{ github.event.pull_request.base.repo.full_name }}
ref: ${{ github.event.pull_request.base.sha }}
path: before
path: base
submodules: true
- name: Checkout pull request
- name: Checkout head
uses: actions/checkout@v6.0.3
with:
persist-credentials: false
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
path: after
path: head
submodules: true
- name: Setup pnpm
uses: pnpm/action-setup@v6.0.9
with:
package_json_file: after/package.json
package_json_file: head/package.json
- name: Setup Node.js
uses: actions/setup-node@v6.4.0
with:
node-version-file: after/.node-version
node-version-file: head/.node-version
cache: pnpm
cache-dependency-path: |
before/pnpm-lock.yaml
after/pnpm-lock.yaml
base/pnpm-lock.yaml
head/pnpm-lock.yaml
- name: Prepare report output
shell: bash
run: mkdir -p "$RUNNER_TEMP/frontend-diagnostics"
- name: Install dependencies for base
working-directory: before
working-directory: base
run: pnpm i --frozen-lockfile
- name: Configure base
working-directory: before
working-directory: base
run: cp .github/misskey/test.yml .config
- name: Build base
working-directory: before
working-directory: base
env:
FRONTEND_BUNDLE_VISUALIZER: 'true'
FRONTEND_BUNDLE_VISUALIZER_FILE: ${{ runner.temp }}/frontend-diagnostics/base-bundle-stats.json
run: pnpm build
- name: Install dependencies for pull request
working-directory: after
- name: Install dependencies for head
working-directory: head
run: pnpm i --frozen-lockfile
- name: Configure pull request
working-directory: after
- name: Configure head
working-directory: head
run: cp .github/misskey/test.yml .config
- name: Build pull request
working-directory: after
- name: Build head
working-directory: head
env:
FRONTEND_BUNDLE_VISUALIZER: 'true'
FRONTEND_BUNDLE_VISUALIZER_FILE: ${{ runner.temp }}/frontend-diagnostics/head-bundle-stats.json
FRONTEND_BUNDLE_VISUALIZER_HTML_FILE: ${{ runner.temp }}/frontend-diagnostics/frontend-bundle-visualizer.html
run: pnpm build
- name: Upload bundle visualizer
id: upload-bundle-visualizer
uses: actions/upload-artifact@v7
with:
name: frontend-bundle-visualizer
path: ${{ runner.temp }}/frontend-diagnostics/frontend-bundle-visualizer.html
if-no-files-found: error
archive: false
retention-days: 7
- name: Install Playwright browsers
working-directory: after/packages-private/diagnostics-frontend-browser
working-directory: head/packages-private/diagnostics-frontend
run: pnpm exec playwright install --with-deps --no-shell chromium
- name: Measure frontend browser metrics
shell: bash
working-directory: after
working-directory: head
env:
FRONTEND_BROWSER_METRICS_SAMPLE_COUNT: 5
MK_ENABLE_CROSS_ORIGIN_ISOLATION: "true"
# 計測ハーネスはafter側のものを両方に使うが、成果物はrunnerのworkspace直下に出す
# 計測ハーネスはhead側のものを両方に使うが、成果物はrunnerのworkspace直下に出す
FRONTEND_BROWSER_HEAP_SNAPSHOT_OUTPUT_DIR: ${{ github.workspace }}
run: |
REPORT_DIR="$RUNNER_TEMP/frontend-browser-diagnostics"
mkdir -p "$REPORT_DIR"
pnpm --filter diagnostics-frontend-browser run inspect \
"$GITHUB_WORKSPACE/before" "$GITHUB_WORKSPACE/after" \
"$REPORT_DIR/before-browser.json" "$REPORT_DIR/after-browser.json"
REPORT_DIR="$RUNNER_TEMP/frontend-diagnostics"
pnpm --filter diagnostics-frontend run inspect-browser \
"$GITHUB_WORKSPACE/base" "$GITHUB_WORKSPACE/head" \
"$REPORT_DIR/base-browser.json" "$REPORT_DIR/head-browser.json"
- name: Upload browser base heap snapshot
id: upload-browser-base-heap-snapshot
uses: actions/upload-artifact@v7
with:
name: frontend-browser-base-heap-snapshot
path: base-heap-snapshot.heapsnapshot
archive: false
if-no-files-found: error
@@ -143,6 +164,7 @@ jobs:
id: upload-browser-head-heap-snapshot
uses: actions/upload-artifact@v7
with:
name: frontend-browser-head-heap-snapshot
path: head-heap-snapshot.heapsnapshot
archive: false
if-no-files-found: error
@@ -150,13 +172,13 @@ jobs:
- name: Generate browser detailed html
shell: bash
working-directory: after
working-directory: head
run: |
REPORT_DIR="$RUNNER_TEMP/frontend-browser-diagnostics"
test -s "$REPORT_DIR/before-browser.json"
test -s "$REPORT_DIR/after-browser.json"
pnpm --filter diagnostics-frontend-browser run render-html \
"$REPORT_DIR/before-browser.json" "$REPORT_DIR/after-browser.json" \
REPORT_DIR="$RUNNER_TEMP/frontend-diagnostics"
test -s "$REPORT_DIR/base-browser.json"
test -s "$REPORT_DIR/head-browser.json"
pnpm --filter diagnostics-frontend run render-browser-html \
"$REPORT_DIR/base-browser.json" "$REPORT_DIR/head-browser.json" \
"$REPORT_DIR/frontend-browser-detailed-html.html"
- name: Upload browser detailed html
@@ -164,54 +186,61 @@ jobs:
uses: actions/upload-artifact@v7
with:
name: frontend-browser-metrics-detailed-html
path: ${{ runner.temp }}/frontend-browser-diagnostics/frontend-browser-detailed-html.html
path: ${{ runner.temp }}/frontend-diagnostics/frontend-browser-detailed-html.html
if-no-files-found: error
archive: false
retention-days: 7
- name: Generate browser metrics report
- name: Generate frontend diagnostics report
shell: bash
working-directory: after
working-directory: head
env:
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_BROWSER_BASE_HEAP_SNAPSHOT_ARTIFACT_URL: ${{ steps.upload-browser-base-heap-snapshot.outputs.artifact-url }}
FRONTEND_BROWSER_HEAD_HEAP_SNAPSHOT_ARTIFACT_URL: ${{ steps.upload-browser-head-heap-snapshot.outputs.artifact-url }}
FRONTEND_BROWSER_DETAILED_HTML_ARTIFACT_URL: ${{ steps.upload-browser-detailed-html.outputs.artifact-url }}
run: |
REPORT_DIR="$RUNNER_TEMP/frontend-browser-diagnostics"
test -s "$REPORT_DIR/before-browser.json"
test -s "$REPORT_DIR/after-browser.json"
pnpm --filter diagnostics-frontend-browser run render-md \
"$REPORT_DIR/before-browser.json" "$REPORT_DIR/after-browser.json" \
"$REPORT_DIR/frontend-browser-diagnostics.md"
REPORT_DIR="$RUNNER_TEMP/frontend-diagnostics"
test -s "$REPORT_DIR/base-bundle-stats.json"
test -s "$REPORT_DIR/head-bundle-stats.json"
test -s "$REPORT_DIR/base-browser.json"
test -s "$REPORT_DIR/head-browser.json"
pnpm --filter diagnostics-frontend run render-md \
"$GITHUB_WORKSPACE/base" "$GITHUB_WORKSPACE/head" \
"$REPORT_DIR/base-bundle-stats.json" "$REPORT_DIR/head-bundle-stats.json" \
"$REPORT_DIR/base-browser.json" "$REPORT_DIR/head-browser.json" \
"$REPORT_DIR/frontend-diagnostics.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 browser metrics report
- name: Check frontend diagnostics report
shell: bash
run: |
REPORT_DIR="$RUNNER_TEMP/frontend-browser-diagnostics"
test -s "$REPORT_DIR/frontend-browser-diagnostics.md"
REPORT_DIR="$RUNNER_TEMP/frontend-diagnostics"
test -s "$REPORT_DIR/frontend-diagnostics.md"
test -s "$REPORT_DIR/frontend-browser-detailed-html.html"
test -s "$REPORT_DIR/pr-number.txt"
test -s "$REPORT_DIR/head-sha.txt"
cat "$REPORT_DIR/frontend-browser-diagnostics.md" >> "$GITHUB_STEP_SUMMARY"
cat "$REPORT_DIR/frontend-diagnostics.md" >> "$GITHUB_STEP_SUMMARY"
- name: Upload browser metrics report
- name: Upload frontend diagnostics report
uses: actions/upload-artifact@v7
with:
name: frontend-browser-diagnostics
name: frontend-diagnostics
path: |
${{ runner.temp }}/frontend-browser-diagnostics/before-browser.json
${{ runner.temp }}/frontend-browser-diagnostics/after-browser.json
${{ runner.temp }}/frontend-browser-diagnostics/frontend-browser-diagnostics.md
${{ runner.temp }}/frontend-browser-diagnostics/pr-number.txt
${{ runner.temp }}/frontend-browser-diagnostics/base-sha.txt
${{ runner.temp }}/frontend-browser-diagnostics/head-sha.txt
${{ runner.temp }}/frontend-browser-diagnostics/pr-url.txt
${{ runner.temp }}/frontend-diagnostics/base-bundle-stats.json
${{ runner.temp }}/frontend-diagnostics/head-bundle-stats.json
${{ runner.temp }}/frontend-diagnostics/base-browser.json
${{ runner.temp }}/frontend-diagnostics/head-browser.json
${{ runner.temp }}/frontend-diagnostics/frontend-diagnostics.md
${{ runner.temp }}/frontend-diagnostics/pr-number.txt
${{ runner.temp }}/frontend-diagnostics/base-sha.txt
${{ runner.temp }}/frontend-diagnostics/head-sha.txt
${{ runner.temp }}/frontend-diagnostics/pr-url.txt
if-no-files-found: error
retention-days: 7

View File

@@ -33,8 +33,7 @@ jobs:
workspace:
- diagnostics-shared
- diagnostics-backend
- diagnostics-frontend-browser
- diagnostics-frontend-bundle
- diagnostics-frontend
- changelog-checker
steps:
- uses: actions/checkout@v6.0.3