Skip to content

Commit

Permalink
ci: new endpoint for perftool-send-report
Browse files Browse the repository at this point in the history
  • Loading branch information
akhdrv committed Sep 19, 2023
1 parent 9d6fdd1 commit a98177e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
1 change: 1 addition & 0 deletions .github/workflows/performance-test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,5 +227,6 @@ jobs:
run: >
./scripts/perftool-send-report.js
--reportPath /home/runner/work/plasma/plasma/perftest/comparison.json
--referrer https://github.com/${{ github.repository }}/pull/${{ github.event.number }}
env:
GITHUB_SHA: ${{ github.sha }}
30 changes: 16 additions & 14 deletions scripts/perftool-send-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ const getMetadata = (data) => {
return JSON.stringify(result);
};

const METRICS_URL = 'https://metrics.prom.third-party-app.sberdevices.ru/create-canvas-app-metrics';
const METRICS_URL = 'https://metrics.prom.third-party-app.sberdevices.ru/perftool';

program.option('--reportPath <string>').parse();
program.option('--reportPath <string>').option('--referrer <string>').parse();

async function perftoolSendReport() {
const { reportPath } = program.opts();
const { reportPath, referrer } = program.opts();
// eslint-disable-next-line global-require, import/no-dynamic-require
const { staticTaskChange, result, isVersionChanged } = require(reportPath);

Expand All @@ -40,30 +40,32 @@ async function perftoolSendReport() {
}

const body = [];
const sessionId = crypto.randomUUID();
const runId = crypto.randomUUID();
const commitHash = process.env.GITHUB_SHA;
// e.g. subjectId = src/components/Carousel/Carousel.perftest.tsx#CarouselLiteBasic
for (const [subjectId, subject] of Object.entries(data)) {
for (const [componentId, subject] of Object.entries(data)) {
// e.g. taskId = rerender | render
for (const [taskId, task] of Object.entries(subject)) {
const filteredMetrics = Object.entries(task).filter(([k]) => !k.startsWith('_'));
// e.g. metricId = median | mean
for (const [metricId, metric] of filteredMetrics) {
for (const typeId of ['old', 'new', 'change']) {
for (const kind of ['old', 'new', 'change']) {
// change, old are optional
if (!metric[typeId]) {
if (!metric[kind]) {
// eslint-disable-next-line no-continue
continue;
}

const item = {
ua: 'perftest/packages/plasma',
hostname: commitHash,
sessionId,
path: subjectId,
key: `${taskId}_${metricId}`,
valueStr: typeId,
metadata: getMetadata(metric[typeId]),
commitHash,
runId,
componentId,
taskId,
metricId,
kind,
referrer,
service: 'perftest/packages/plasma',
payload: getMetadata(metric[kind]),
};
body.push(item);
}
Expand Down

0 comments on commit a98177e

Please sign in to comment.