Skip to content

Commit 947549a

Browse files
authored
still trying to replicate running semver during CI (#27)
1 parent ac4f5d9 commit 947549a

File tree

2 files changed

+1
-71
lines changed

2 files changed

+1
-71
lines changed

.github/workflows/label-version-bump.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ jobs:
2929
node-version: lts/*
3030
cache: 'yarn'
3131

32-
- name: Install semver
33-
run: yarn global add semver
34-
3532
- name: Detect version bump type
3633
id: bump-type
3734
run: |
@@ -55,6 +52,7 @@ jobs:
5552
id: versions
5653
if: steps.bump-type.outputs.bump-type != 'null'
5754
run: |
55+
npm add --global semver
5856
OLD_VERSION=$(jq ".version" package.json -r)
5957
NEW_VERSION=$(semver $OLD_VERSION -i ${{ steps.bump-type.outputs.bump-type }})
6058
echo "old-version=$OLD_VERSION" >> "$GITHUB_OUTPUT"

packages/rrweb-snapshot/test/css.test.ts

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -227,74 +227,6 @@ describe('css splitter', () => {
227227
}
228228
expect(splitCssText(cssText, style)).toEqual(sections);
229229
});
230-
231-
it(
232-
'the second time is faster',
233-
{
234-
// because we're timing every so often this might flap because computers
235-
retry: 3,
236-
},
237-
() => {
238-
const cssText = fs.readFileSync(
239-
path.resolve(__dirname, './css/benchmark.css'),
240-
'utf8',
241-
);
242-
243-
const parts = cssText.split('}');
244-
const sections = [];
245-
for (let i = 0; i < parts.length - 1; i++) {
246-
if (i % 100 === 0) {
247-
sections.push(parts[i] + '}');
248-
} else {
249-
sections[sections.length - 1] += parts[i] + '}';
250-
}
251-
}
252-
sections[sections.length - 1] += parts[parts.length - 1];
253-
254-
expect(cssText.length).toEqual(sections.join('').length);
255-
256-
const style = JSDOM.fragment(`<style></style>`).querySelector('style');
257-
if (style) {
258-
sections.forEach((section) => {
259-
style.appendChild(JSDOM.fragment(section));
260-
});
261-
}
262-
263-
// Measure the time for the first execution
264-
const startFirst = performance.now();
265-
const firstResult = splitCssText(cssText, style);
266-
const endFirst = performance.now();
267-
const firstExecutionTime = endFirst - startFirst;
268-
269-
expect(firstResult).toEqual(sections);
270-
271-
const cachedExecutionTimes = [];
272-
for (let i = 0; i < 100; i++) {
273-
// Measure the time for the second execution
274-
const startSecond = performance.now();
275-
const secondResult = splitCssText(cssText, style);
276-
const endSecond = performance.now();
277-
278-
expect(secondResult).toEqual(firstResult);
279-
const secondExecutionTime = endSecond - startSecond;
280-
cachedExecutionTimes.push(secondExecutionTime);
281-
}
282-
283-
// Assert that the second execution is faster
284-
expect(
285-
cachedExecutionTimes.every((time) => time < firstExecutionTime),
286-
).toBe(true);
287-
288-
// Optional: Log the execution times for debugging
289-
console.log(`First execution time: ${firstExecutionTime}ms`);
290-
console.log(
291-
`Average execution time for the second execution: ${
292-
cachedExecutionTimes.reduce((a, b) => a + b) /
293-
cachedExecutionTimes.length
294-
}ms`,
295-
);
296-
},
297-
);
298230
});
299231

300232
describe('applyCssSplits css rejoiner', function () {

0 commit comments

Comments
 (0)