mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-11-15 02:04:08 +01:00
18
.github/workflows/e2e.yml
vendored
18
.github/workflows/e2e.yml
vendored
@@ -69,15 +69,11 @@ jobs:
|
|||||||
start: pnpm run dev
|
start: pnpm run dev
|
||||||
wait-on: 'http://localhost:9000'
|
wait-on: 'http://localhost:9000'
|
||||||
browser: chrome
|
browser: chrome
|
||||||
spec: |
|
|
||||||
cypress/integration/rendering/classDiagram.spec.js
|
|
||||||
cypress/integration/rendering/flowchart-v2.spec.js
|
|
||||||
|
|
||||||
- name: Move runtime data
|
- name: Move runtime data
|
||||||
if: ${{ steps.cache-snapshot.outputs.cache-hit != 'true' }}
|
if: ${{ steps.cache-snapshot.outputs.cache-hit != 'true' }}
|
||||||
run: |
|
run: |
|
||||||
mkdir -p cypress/snapshots/runtimes
|
mv cypress/snapshots/runtimes/current cypress/snapshots/runtimes/base
|
||||||
mv cypress/runtimes cypress/snapshots/runtimes/base
|
|
||||||
|
|
||||||
e2e:
|
e2e:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -149,9 +145,6 @@ jobs:
|
|||||||
# e.g. if this action was run from a fork
|
# e.g. if this action was run from a fork
|
||||||
record: ${{ secrets.CYPRESS_RECORD_KEY != '' }}
|
record: ${{ secrets.CYPRESS_RECORD_KEY != '' }}
|
||||||
parallel: ${{ secrets.CYPRESS_RECORD_KEY != '' }}
|
parallel: ${{ secrets.CYPRESS_RECORD_KEY != '' }}
|
||||||
spec: |
|
|
||||||
cypress/integration/rendering/classDiagram.spec.js
|
|
||||||
cypress/integration/rendering/flowchart-v2.spec.js
|
|
||||||
env:
|
env:
|
||||||
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
||||||
VITEST_COVERAGE: true
|
VITEST_COVERAGE: true
|
||||||
@@ -205,17 +198,12 @@ jobs:
|
|||||||
id: runtime
|
id: runtime
|
||||||
if: ${{ needs.e2e.result != 'failure' && github.event_name == 'pull_request' }}
|
if: ${{ needs.e2e.result != 'failure' && github.event_name == 'pull_request' }}
|
||||||
run: |
|
run: |
|
||||||
ls -l cypress/snapshots/runtimes
|
mv ./snapshots/runtimes/current ./snapshots/runtimes/head
|
||||||
mv cypress/snapshots/runtimes cypress/snapshots/runtimes/head
|
|
||||||
ls -l cypress/snapshots/runtimes
|
|
||||||
ls -l cypress/snapshots/runtimes/base
|
|
||||||
ls -l cypress/snapshots/runtimes/head
|
|
||||||
tree cypress/snapshots/runtimes
|
|
||||||
npm config set ignore-scripts true
|
npm config set ignore-scripts true
|
||||||
pnpm install --frozen-lockfile
|
pnpm install --frozen-lockfile
|
||||||
{
|
{
|
||||||
echo 'runtime_diff<<EOF'
|
echo 'runtime_diff<<EOF'
|
||||||
npx tsx scripts/runTime.ts
|
npx tsx scripts/runTime.ts ./snapshots
|
||||||
echo EOF
|
echo EOF
|
||||||
} >> "$GITHUB_OUTPUT"
|
} >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export default eyesPlugin(
|
|||||||
});
|
});
|
||||||
on('task', {
|
on('task', {
|
||||||
recordRenderTime({ fileName, testName, timeTaken }) {
|
recordRenderTime({ fileName, testName, timeTaken }) {
|
||||||
const resultsPath = path.join('cypress', 'runtimes');
|
const resultsPath = path.join('cypress', 'snapshots', 'runtimes', 'current');
|
||||||
if (!fs.existsSync(resultsPath)) {
|
if (!fs.existsSync(resultsPath)) {
|
||||||
fs.mkdirSync(resultsPath, { recursive: true });
|
fs.mkdirSync(resultsPath, { recursive: true });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
import { readFile } from 'fs/promises';
|
import { readFile } from 'fs/promises';
|
||||||
import { globby } from 'globby';
|
import { globby } from 'globby';
|
||||||
import { markdownTable } from 'markdown-table';
|
|
||||||
|
|
||||||
interface RunTimes {
|
interface RunTimes {
|
||||||
[key: string]: number;
|
[key: string]: number;
|
||||||
@@ -51,10 +50,14 @@ const percentageDifference = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
const main = async () => {
|
const main = async () => {
|
||||||
const oldStats = await readStats('./cypress/snapshots/runtimes/base/**/*.csv');
|
const base = process.argv[2] || './cypress/snapshots';
|
||||||
const newStats = await readStats('./cypress/snapshots/runtimes/head/**/*.csv');
|
const oldStats = await readStats(`${base}/runtimes/base/**/*.csv`);
|
||||||
|
const newStats = await readStats(`${base}/runtimes/head/**/*.csv`);
|
||||||
const fullData: string[][] = [];
|
const fullData: string[][] = [];
|
||||||
const changed: string[][] = [];
|
const changed: string[][] = [];
|
||||||
|
let oldRuntimeSum = 0;
|
||||||
|
let newRuntimeSum = 0;
|
||||||
|
let testCount = 0;
|
||||||
for (const [fileName, runtimes] of Object.entries(newStats)) {
|
for (const [fileName, runtimes] of Object.entries(newStats)) {
|
||||||
const oldStat = oldStats[fileName];
|
const oldStat = oldStats[fileName];
|
||||||
if (!oldStat) {
|
if (!oldStat) {
|
||||||
@@ -65,31 +68,68 @@ const main = async () => {
|
|||||||
if (!oldTimeTaken) {
|
if (!oldTimeTaken) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
oldRuntimeSum += oldTimeTaken;
|
||||||
|
newRuntimeSum += timeTaken;
|
||||||
|
testCount++;
|
||||||
const delta = timeTaken - oldTimeTaken;
|
const delta = timeTaken - oldTimeTaken;
|
||||||
|
|
||||||
const { change, crossedThreshold } = percentageDifference(oldTimeTaken, timeTaken);
|
const { change, crossedThreshold } = percentageDifference(oldTimeTaken, timeTaken);
|
||||||
const out = [
|
const out = [
|
||||||
fileName,
|
fileName,
|
||||||
testName,
|
testName.replace('#', ''),
|
||||||
oldTimeTaken.toString(),
|
`${oldTimeTaken}/${timeTaken}`,
|
||||||
timeTaken.toString(),
|
`${delta.toString()}ms ${change}`,
|
||||||
change,
|
|
||||||
`${delta.toString()}ms`,
|
|
||||||
];
|
];
|
||||||
if (crossedThreshold) {
|
if (crossedThreshold && Math.abs(delta) > 25) {
|
||||||
changed.push(out);
|
changed.push(out);
|
||||||
console.warn(`${testName} (${fileName}): ${timeTaken}ms (${delta}ms, ${change})`);
|
|
||||||
}
|
}
|
||||||
fullData.push(out);
|
fullData.push(out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const headers = ['File', 'Test', 'Old Time', 'New Time', '% Change', 'Difference'];
|
const oldAverage = oldRuntimeSum / testCount;
|
||||||
console.log(markdownTable([headers, ...changed]));
|
const newAverage = newRuntimeSum / testCount;
|
||||||
|
const { change, crossedThreshold } = percentageDifference(oldAverage, newAverage);
|
||||||
|
|
||||||
|
const headers = ['File', 'Test', 'Time Old/New', 'Change (%)'];
|
||||||
|
console.log(`## Runtime Changes
|
||||||
|
Old runtime average: ${oldAverage.toFixed(2)}ms
|
||||||
|
New runtime average: ${newAverage.toFixed(2)}ms
|
||||||
|
Change: ${change} ${crossedThreshold ? '⚠️' : ''}
|
||||||
|
`);
|
||||||
|
console.log(`
|
||||||
|
<details>
|
||||||
|
<summary>Changed tests</summary>
|
||||||
|
${htmlTable([headers, ...changed])}
|
||||||
|
</details>
|
||||||
|
`);
|
||||||
console.log(`
|
console.log(`
|
||||||
<details>
|
<details>
|
||||||
<summary>Full Data</summary>
|
<summary>Full Data</summary>
|
||||||
${markdownTable([headers, ...fullData])}
|
${htmlTable([headers, ...fullData])}
|
||||||
</details>
|
</details>
|
||||||
`);
|
`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const htmlTable = (data: string[][]): string => {
|
||||||
|
let table = `<table border='1' style="border-collapse: collapse">`;
|
||||||
|
|
||||||
|
// Generate table header
|
||||||
|
table += `<tr>
|
||||||
|
${data
|
||||||
|
.shift()!
|
||||||
|
.map((header) => `<th>${header}</th>`)
|
||||||
|
.join('')}
|
||||||
|
</tr>`;
|
||||||
|
|
||||||
|
// Generate table rows
|
||||||
|
for (const row of data) {
|
||||||
|
table += `<tr>
|
||||||
|
${row.map((cell) => `<td>${cell}</td>`).join('')}
|
||||||
|
</tr>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
table += '</table>';
|
||||||
|
return table;
|
||||||
|
};
|
||||||
|
|
||||||
void main().catch((e) => console.error(e));
|
void main().catch((e) => console.error(e));
|
||||||
|
|||||||
Reference in New Issue
Block a user