Skip to content

Commit 977509d

Browse files
committed
chore(core): perfomance testing
1 parent 1302973 commit 977509d

7 files changed

Lines changed: 1165 additions & 409 deletions

File tree

.github/workflows/build.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ jobs:
7373
runs-on: ubuntu-latest
7474
if: always()
7575
permissions:
76+
actions: read
7677
contents: write
7778
pull-requests: write
7879
checks: write
@@ -111,9 +112,61 @@ jobs:
111112
- name: Build project
112113
run: yarn build
113114
- name: Generate report
115+
env:
116+
ALLURE_PERF_METRICS: "1"
114117
run: yarn allure generate --config=./allurerc.mjs --dump="allure-results-*.zip" --output=./allure-report
118+
- name: Write perf metrics summary
119+
if: always()
120+
run: |
121+
node ./scripts/allure-perf-summary.mjs ./allure-report/allure-perf-metrics.json --output ./allure-report/allure-perf-metrics.md
122+
cat ./allure-report/allure-perf-metrics.md >> "$GITHUB_STEP_SUMMARY"
123+
- name: Upload perf metrics
124+
uses: actions/upload-artifact@v5
125+
if: always()
126+
with:
127+
name: allure-perf-metrics
128+
path: |
129+
./allure-report/allure-perf-metrics.json
130+
./allure-report/allure-perf-metrics.md
131+
if-no-files-found: ignore
115132
- name: Allure Report Official
116133
uses: allure-framework/allure-action@v0
117134
with:
118135
report-directory: "./allure-report"
119136
github-token: ${{ secrets.GITHUB_TOKEN }}
137+
138+
perf-metrics-comment:
139+
needs: report
140+
name: Comment perf metrics
141+
runs-on: ubuntu-latest
142+
if: always() && github.event_name == 'pull_request'
143+
permissions:
144+
actions: read
145+
pull-requests: write
146+
steps:
147+
- name: Download perf metrics
148+
uses: actions/download-artifact@v6
149+
continue-on-error: true
150+
with:
151+
name: allure-perf-metrics
152+
path: ./allure-perf-metrics
153+
- name: Comment perf metrics on pull request
154+
uses: actions/github-script@v9
155+
with:
156+
script: |
157+
const fs = require("node:fs");
158+
const marker = "<!-- allure-perf-metrics -->";
159+
const summaryPath = "./allure-perf-metrics/allure-perf-metrics.md";
160+
const { owner, repo } = context.repo;
161+
const artifactsUrl = `${context.serverUrl}/${owner}/${repo}/actions/runs/${context.runId}`;
162+
const summary = fs.existsSync(summaryPath) ? fs.readFileSync(summaryPath, "utf8") : "### Allure perf metrics\n\nMetrics file was not generated.\n";
163+
const body = `${marker}\n${summary}\nArtifacts: [allure-perf-metrics](${artifactsUrl})`;
164+
const issue_number = context.payload.pull_request.number;
165+
const comments = await github.rest.issues.listComments({ owner, repo, issue_number, per_page: 100 });
166+
const previous = comments.data.find((comment) => comment.user.type === "Bot" && comment.body?.includes(marker));
167+
168+
if (previous) {
169+
await github.rest.issues.updateComment({ owner, repo, comment_id: previous.id, body });
170+
} else {
171+
await github.rest.issues.createComment({ owner, repo, issue_number, body });
172+
}

0 commit comments

Comments
 (0)