forked from mirrors/misskey
75 lines
3 KiB
YAML
75 lines
3 KiB
YAML
name: Report backend memory
|
|
|
|
on:
|
|
workflow_run:
|
|
types: [completed]
|
|
workflows:
|
|
- Get backend memory usage # get-backend-memory.yml
|
|
|
|
jobs:
|
|
compare-memory:
|
|
runs-on: ubuntu-latest
|
|
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
|
permissions:
|
|
actions: read
|
|
contents: read
|
|
pull-requests: write
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6.0.2
|
|
|
|
- name: Download artifact
|
|
uses: actions/github-script@v9
|
|
with:
|
|
script: |
|
|
const fs = require('fs');
|
|
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
run_id: context.payload.workflow_run.id,
|
|
});
|
|
let matchArtifacts = allArtifacts.data.artifacts.filter((artifact) => {
|
|
return artifact.name.startsWith("memory-artifact-") || artifact.name == "memory-artifact"
|
|
});
|
|
await Promise.all(matchArtifacts.map(async (artifact) => {
|
|
let download = await github.rest.actions.downloadArtifact({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
artifact_id: artifact.id,
|
|
archive_format: 'zip',
|
|
});
|
|
await fs.promises.writeFile(`${process.env.GITHUB_WORKSPACE}/${artifact.name}.zip`, Buffer.from(download.data));
|
|
}));
|
|
- name: Extract all artifacts
|
|
run: |
|
|
find . -mindepth 1 -maxdepth 1 -type f -name '*.zip' -exec unzip {} -d artifacts ';'
|
|
ls -la artifacts/
|
|
- name: Load PR Number
|
|
id: load-pr-num
|
|
run: echo "pr-number=$(cat artifacts/pr_number)" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Output base
|
|
run: cat ./artifacts/memory-base.json
|
|
- name: Output head
|
|
run: cat ./artifacts/memory-head.json
|
|
- name: Output base JS footprint
|
|
run: cat ./artifacts/js-footprint-base.json
|
|
- name: Output head JS footprint
|
|
run: cat ./artifacts/js-footprint-head.json
|
|
- id: build-comment
|
|
name: Build memory comment
|
|
run: node .github/scripts/backend-memory-report.mts ./artifacts/memory-base.json ./artifacts/memory-head.json ./output.md ./artifacts/js-footprint-base.json ./artifacts/js-footprint-head.json
|
|
- uses: thollander/actions-comment-pull-request@v3
|
|
with:
|
|
pr-number: ${{ steps.load-pr-num.outputs.pr-number }}
|
|
comment-tag: show_memory_diff
|
|
file-path: ./output.md
|
|
- name: Tell error to PR
|
|
uses: thollander/actions-comment-pull-request@v3
|
|
if: failure() && steps.load-pr-num.outputs.pr-number
|
|
with:
|
|
pr-number: ${{ steps.load-pr-num.outputs.pr-number }}
|
|
comment-tag: show_memory_diff_error
|
|
message: |
|
|
An error occurred while comparing backend memory usage. See [workflow logs](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details.
|