mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-07-27 03:44:37 +02:00
Workflowの追従 (#17622)
* [skip ci] Update CHANGELOG.md (prepend template) * fix(dev): tweak frontend-bundle-report * Merge branch 'develop' of https://github.com/misskey-dev/misskey into develop * enhance(dev): tweak Frontend Chunk Report * fix(dev): tweak frontend-bundle-report-comment * enhance(dev): tweak Frontend Chunk Report * enhance(dev): tweak Frontend Chunk Report * enhance(dev): improve backend memory usage comparison workflow (#17591) * wip * Update get-backend-memory.yml * [ci skip] tweak table * enhance(dev): tweak report-backend-memory * refactor(dev): report-backend-memoryのmarkdown生成ロジックを分離 * enhance(dev): tweak report-backend-memory * enhance(dev): tweak report-backend-memory * enhance(dev): tweak report-backend-memory * chore(dev): refactor * refactor(dev): unify frontend-bundle-visualizer-report.mjs and frontend-js-size.mjs * chore(dev): fix typo * refactor(dev): refactor frontend-js-size.mjs * chore(dev): tweak frontend-js-size.mjs * chore(dev): tweak frontend-js-size.mjs * chore(dev): tweak frontend-js-size.mjs * chore(ci): simplify FFmpeg installation in workflows (#17612) * chore(ci): simplify FFmpeg installation in workflows * fix * fix(dev): tweak frontend-js-size.mjs * Merge branch 'develop' of https://github.com/misskey-dev/misskey into develop * enhance(dev): improve Frontend Bundle Report * chore(dev): refactor frontend bundle report * enhance(dev): improve backend memory usage report (#17608) * enhance(dev): tweak report-backend-memory * wip * Update backend-memory-report.mjs * Update backend-memory-report.mjs * chore(dev): tweak frontend-js-size.mjs * Merge branch 'develop' of https://github.com/misskey-dev/misskey into develop * chore(dev): tweak backend-memory-report * chore(dev): tweak backend-memory-report * (test) enhance(dev): improve backend-memory-report * chore(dev): tweak backend-memory-report * chore(dev): tweak backend-memory-report * chore(dev): tweak backend-memory-report * chore(dev): tweak backend-memory-report * chore(dev): tweak frontend-js-size * chore(dev): tweak frontend-js-size * chore(dev): tweak backend-memory-report * chore(dev): tweak backend-memory-report * chore(dev): tweak backend-memory-report * chore(dev): tweak frontend-js-size * Update frontend-bundle-report.yml * [ci skip] chore(dev): tweak frontend-js-size * refactor(dev): refactor of backend memory comparison workflow (#17619) * refactor(dev): refactor of backend memory comparison workflow * fix * fix(dev): follow up of1c4bcd9b32* fix(dev): follow up of1c4bcd9b32* fix(dev): follow up of1c4bcd9b32* fix(dev): follow up of1c4bcd9b32* chore(dev): refactor workflow js * refactor(dev): extract heap snapshot logic 将来的にフロントエンドでもheap snaphotを集計したくなった時などのため あとpairedDeltaSummaryを共通化 * chore(dev): tweak backend-memory-report * chore(dev): tweak some workflows * chore(dev): tweak some workflows * fix(dev): fix measure-memory * clean up --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: おさむのひと <46447427+samunohito@users.noreply.github.com>
This commit is contained in:
@@ -25,8 +25,8 @@ on:
|
||||
- pnpm-lock.yaml
|
||||
- pnpm-workspace.yaml
|
||||
- .node-version
|
||||
- .github/scripts/frontend-js-size.mjs
|
||||
- .github/scripts/frontend-bundle-visualizer-report.mjs
|
||||
- .github/scripts/utility.mts
|
||||
- .github/scripts/frontend-js-size.mts
|
||||
- .github/workflows/frontend-bundle-report.yml
|
||||
- .github/workflows/frontend-bundle-report-comment.yml
|
||||
|
||||
@@ -104,6 +104,9 @@ jobs:
|
||||
});
|
||||
const report = artifacts.find((artifact) => artifact.name === artifactName && !artifact.expired);
|
||||
if (report) return { done: true, run };
|
||||
|
||||
core.info(`Frontend bundle report run ${run.id} did not produce ${artifactName}.`);
|
||||
return { done: true, run: null };
|
||||
}
|
||||
|
||||
return { done: false, run: null };
|
||||
@@ -126,8 +129,30 @@ jobs:
|
||||
|
||||
core.warning(`Timed out waiting for ${artifactName} from ${workflow_id} for ${headSha}.`);
|
||||
|
||||
- name: Download bundle report from workflow_run
|
||||
- name: Find bundle report artifact
|
||||
if: github.event_name == 'workflow_run'
|
||||
id: find-report-artifact
|
||||
uses: actions/github-script@v9
|
||||
with:
|
||||
script: |
|
||||
const artifactName = 'frontend-bundle-report';
|
||||
const { owner, repo } = context.repo;
|
||||
const artifacts = await github.paginate(github.rest.actions.listWorkflowRunArtifacts, {
|
||||
owner,
|
||||
repo,
|
||||
run_id: context.payload.workflow_run.id,
|
||||
per_page: 100,
|
||||
});
|
||||
const report = artifacts.find((artifact) => artifact.name === artifactName && !artifact.expired);
|
||||
if (report) {
|
||||
core.setOutput('exists', 'true');
|
||||
} else {
|
||||
core.info(`Workflow run ${context.payload.workflow_run.id} did not produce ${artifactName}.`);
|
||||
core.setOutput('exists', 'false');
|
||||
}
|
||||
|
||||
- name: Download bundle report from workflow_run
|
||||
if: github.event_name == 'workflow_run' && steps.find-report-artifact.outputs.exists == 'true'
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: frontend-bundle-report
|
||||
@@ -147,7 +172,7 @@ jobs:
|
||||
run-id: ${{ steps.find-report-run.outputs.run-id }}
|
||||
|
||||
- name: Comment on pull request
|
||||
if: github.event_name == 'workflow_run' || steps.find-report-run.outputs.run-id != ''
|
||||
if: (github.event_name == 'workflow_run' && steps.find-report-artifact.outputs.exists == 'true') || steps.find-report-run.outputs.run-id != ''
|
||||
uses: actions/github-script@v9
|
||||
with:
|
||||
github-token: ${{ secrets.FRONTEND_BUNDLE_REPORT_COMMENT_TOKEN || secrets.FRONTEND_JS_SIZE_COMMENT_TOKEN || secrets.FRONTEND_BUNDLE_VISUALIZER_COMMENT_TOKEN || github.token }}
|
||||
@@ -160,30 +185,25 @@ jobs:
|
||||
const reportMarkers = [jsSizeMarker, visualizerMarker];
|
||||
const reportDir = path.join(process.env.RUNNER_TEMP, 'frontend-bundle-report');
|
||||
const jsSizeReportPath = path.join(reportDir, 'frontend-js-size-report.md');
|
||||
const visualizerReportPath = path.join(reportDir, 'frontend-bundle-visualizer-report.md');
|
||||
const prNumberPath = path.join(reportDir, 'pr-number.txt');
|
||||
const headShaPath = path.join(reportDir, 'head-sha.txt');
|
||||
const workflowRun = context.payload.workflow_run;
|
||||
const pullRequest = context.payload.pull_request;
|
||||
const headSha = workflowRun?.head_sha ?? pullRequest?.head?.sha ?? null;
|
||||
const eventHeadSha = workflowRun?.head_sha ?? pullRequest?.head?.sha ?? null;
|
||||
const { owner, repo } = context.repo;
|
||||
|
||||
if (!fs.existsSync(jsSizeReportPath)) {
|
||||
core.setFailed('The frontend bundle report artifact does not contain frontend-js-size-report.md.');
|
||||
return;
|
||||
}
|
||||
if (!fs.existsSync(visualizerReportPath)) {
|
||||
core.setFailed('The frontend bundle report artifact does not contain frontend-bundle-visualizer-report.md.');
|
||||
return;
|
||||
}
|
||||
|
||||
const artifactHeadSha = fs.existsSync(headShaPath)
|
||||
? fs.readFileSync(headShaPath, 'utf8').trim()
|
||||
: null;
|
||||
if (headSha != null && artifactHeadSha != null && artifactHeadSha !== headSha) {
|
||||
core.setFailed(`The artifact head SHA (${artifactHeadSha}) does not match the workflow head SHA (${headSha}).`);
|
||||
return;
|
||||
if (eventHeadSha != null && artifactHeadSha != null && artifactHeadSha !== eventHeadSha) {
|
||||
core.info(`The artifact head SHA (${artifactHeadSha}) differs from the event head SHA (${eventHeadSha}). Using artifact metadata for PR validation.`);
|
||||
}
|
||||
const reportHeadSha = artifactHeadSha ?? eventHeadSha;
|
||||
|
||||
const artifactPrNumber = fs.existsSync(prNumberPath)
|
||||
? Number(fs.readFileSync(prNumberPath, 'utf8').trim())
|
||||
@@ -203,25 +223,29 @@ jobs:
|
||||
}
|
||||
}
|
||||
|
||||
const pullRequestsForCommit = await github.paginate(github.rest.repos.listPullRequestsAssociatedWithCommit, {
|
||||
owner,
|
||||
repo,
|
||||
commit_sha: headSha,
|
||||
per_page: 100,
|
||||
});
|
||||
for (const pullRequest of pullRequestsForCommit) {
|
||||
associatedPullRequests.set(pullRequest.number, pullRequest);
|
||||
if (reportHeadSha != null) {
|
||||
const pullRequestsForCommit = await github.paginate(github.rest.repos.listPullRequestsAssociatedWithCommit, {
|
||||
owner,
|
||||
repo,
|
||||
commit_sha: reportHeadSha,
|
||||
per_page: 100,
|
||||
});
|
||||
for (const pullRequest of pullRequestsForCommit) {
|
||||
associatedPullRequests.set(pullRequest.number, pullRequest);
|
||||
}
|
||||
}
|
||||
|
||||
if (Number.isInteger(artifactPrNumber) && associatedPullRequests.has(artifactPrNumber)) {
|
||||
issue_number = artifactPrNumber;
|
||||
} else if (Number.isInteger(artifactPrNumber) && associatedPullRequests.size === 0) {
|
||||
issue_number = artifactPrNumber;
|
||||
} else if (!Number.isInteger(artifactPrNumber) && associatedPullRequests.size === 1) {
|
||||
issue_number = [...associatedPullRequests.keys()][0];
|
||||
} else if (Number.isInteger(artifactPrNumber)) {
|
||||
core.setFailed(`The artifact pull request number (${artifactPrNumber}) is not associated with ${headSha}.`);
|
||||
core.setFailed(`The artifact pull request number (${artifactPrNumber}) is not associated with ${reportHeadSha}.`);
|
||||
return;
|
||||
} else {
|
||||
core.setFailed(`Could not determine the pull request associated with ${headSha}.`);
|
||||
core.setFailed(`Could not determine the pull request associated with ${reportHeadSha}.`);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@@ -229,16 +253,23 @@ jobs:
|
||||
return;
|
||||
}
|
||||
|
||||
const currentPullRequest = await github.rest.pulls.get({
|
||||
owner,
|
||||
repo,
|
||||
pull_number: issue_number,
|
||||
});
|
||||
const currentHeadSha = currentPullRequest.data.head?.sha;
|
||||
if (reportHeadSha != null && currentHeadSha != null && reportHeadSha !== currentHeadSha) {
|
||||
core.info(`The report head SHA (${reportHeadSha}) is not the current pull request head SHA (${currentHeadSha}). Skipping stale frontend bundle report.`);
|
||||
return;
|
||||
}
|
||||
|
||||
const jsSizeReport = fs.readFileSync(jsSizeReportPath, 'utf8').trim();
|
||||
if (!jsSizeReport.includes(jsSizeMarker)) {
|
||||
core.setFailed('The frontend JS size report is missing the expected marker.');
|
||||
return;
|
||||
}
|
||||
const visualizerReport = fs.readFileSync(visualizerReportPath, 'utf8').trim();
|
||||
let body = [
|
||||
jsSizeReport,
|
||||
visualizerReport,
|
||||
].join('\n\n') + '\n';
|
||||
let body = `${jsSizeReport}\n`;
|
||||
|
||||
const maxCommentLength = 65_000;
|
||||
if (body.length > maxCommentLength) {
|
||||
|
||||
Reference in New Issue
Block a user