Skip to content

Commit

Permalink
test: collaborative mode
Browse files Browse the repository at this point in the history
  • Loading branch information
akhdrv committed Jan 19, 2024
1 parent 12640c3 commit 1cf514a
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 1 deletion.
48 changes: 48 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,51 @@ jobs:
run: |
cd spec/main-suite
pnpm run integration:unchanged
collaborative_mode:
name: Сollaborative mode
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_REGISTRY_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
path: current
- uses: actions/checkout@v4
with:
path: baseline

- uses: actions/setup-node@v4
with:
node-version-file: 'current/.nvmrc'
cache: 'pnpm'
- uses: pnpm/action-setup@v2

- name: Prepare baseline
run: |
cd baseline
pnpm install
cd spec/main-suite
pnpm run integration:prepare
- name: Prepare current
run: |
cd current
pnpm install
cd spec/main-suite
pnpm run integration:prepare
- name: Run perftool
run: |
cd current/spec/main-suite
npm run integration:collaborative:unchanged
npm run integration:collaborative:degradation
npm run integration:check
- name: Expose artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: Perftool Reports
path: current/spec/main-suite/test-result/*
3 changes: 3 additions & 0 deletions spec/main-suite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
"integration:npm": "perftool -o test-result/old.json --logLevel=verbose && SLOW=1 perftool -o test-result/new.json --logLevel=verbose && npm run integration:compare",
"integration:degradation": "perftool -o test-result/old.json --logLevel=verbose && SLOW=1 perftool -o test-result/new.json --logLevel=verbose && pnpm run integration:compare -o test-result/degradation.json",
"integration:unchanged": "perftool -o test-result/old.json --logLevel=verbose && perftool -o test-result/new.json --logLevel=verbose && pnpm run integration:compare -o test-result/unchanged.json",
"integration:collaborative": "perftool -v --baselineRefDir ../../../baseline/spec/main-suite -o test-result/new.json --baselineOutputPath test-result/old.json",
"integration:collaborative:unchanged": "./touch.mjs && pnpm run integration:collaborative --compareOutputPath test-result/unchanged.json",
"integration:collaborative:degradation": "./slowdown.mjs && pnpm run integration:collaborative --compareOutputPath test-result/degradation.json",
"integration:compare": "perftool-compare test-result/new.json test-result/old.json --logLevel=verbose"
},
"private": true
Expand Down
14 changes: 14 additions & 0 deletions spec/main-suite/slowdown.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env node

import fsPromises from 'fs/promises';

async function start() {
const testPath = './src/components/Components.perftest.tsx';
let contents = await fsPromises.readFile(testPath, { encoding: 'utf-8' });

contents = contents.replace(/\/\/\sSLOW/g, 'slow = true;');

await fsPromises.writeFile(testPath, contents, { encoding: 'utf-8' });
}

start();
7 changes: 6 additions & 1 deletion spec/main-suite/src/components/Components.perftest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ import { setViewport } from '@salutejs/perftool';

import { TestComponent as OriginalTestComponent } from './TestComponent';

// eslint-disable-next-line prefer-const
let slow = false;
// SLOW

export function TestComponent() {
const isSlow = Boolean(process.env.SLOW);
// COMPONENT
const isSlow = Boolean(process.env.SLOW || slow);

return <OriginalTestComponent slow={isSlow} />;
}
Expand Down
14 changes: 14 additions & 0 deletions spec/main-suite/touch.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env node

import fsPromises from 'fs/promises';

async function start() {
const testPath = './src/components/Components.perftest.tsx';
let contents = await fsPromises.readFile(testPath, { encoding: 'utf-8' });

contents = contents.replace(/\/\/\sCOMPONENT/g, 'window.top;');

await fsPromises.writeFile(testPath, contents, { encoding: 'utf-8' });
}

start();

0 comments on commit 1cf514a

Please sign in to comment.