From b1f856465d5e48e5ea278ace52960d5ceaef3493 Mon Sep 17 00:00:00 2001
From: Mark Silverwood <3482679+SlicedSilver@users.noreply.github.com>
Date: Tue, 30 Jul 2024 14:43:04 +0100
Subject: [PATCH 1/5] split graphics tests on CI into multiple parts
---
.circleci/config.yml | 101 ++++++++++---------
tests/e2e/graphics/helpers/get-test-cases.ts | 16 ++-
2 files changed, 66 insertions(+), 51 deletions(-)
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 35bb865048..c3d5b3d77d 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -2,7 +2,6 @@
version: 2.1
-
aliases:
- &restore-node-modules-cache
name: Restore node_modules cache
@@ -64,6 +63,8 @@ commands:
productionBuild:
type: boolean
default: false
+ grep:
+ type: string
steps:
- checkout-with-deps
- run:
@@ -74,6 +75,7 @@ commands:
echo 'export TESTS_REPORT_FILE="test-results/graphics/results.xml"' >> $BASH_ENV
echo 'export DEVICE_PIXEL_RATIO=<< parameters.devicePixelRatio >>' >> $BASH_ENV
echo 'export PRODUCTION_BUILD=<< parameters.productionBuild >>' >> $BASH_ENV
+ echo 'export GREP=<< parameters.grep >>' >> $BASH_ENV
echo 'export COMPARE_BRANCH="v5-candidate"' >> $BASH_ENV
- run:
command: scripts/run-graphics-tests.sh
@@ -195,37 +197,21 @@ jobs:
path: ./dts-changes
when: on_fail
- graphics-tests-dpr1_0:
- executor: node-browsers-executor
- steps:
- - run-graphics-tests:
- devicePixelRatio: "1.0"
-
- graphics-tests-dpr1_25:
- executor: node-browsers-executor
- steps:
- - run-graphics-tests:
- devicePixelRatio: "1.25"
-
- graphics-tests-dpr1_5:
- executor: node-browsers-executor
- steps:
- - run-graphics-tests:
- devicePixelRatio: "1.5"
-
- graphics-tests-dpr2_0:
- executor: node-browsers-executor
- steps:
- - run-graphics-tests:
- devicePixelRatio: "2.0"
-
- graphics-tests-dpr2_0-prod:
+ graphics-tests:
+ parameters:
+ grep:
+ type: string
+ dpr:
+ type: string
+ productionBuild:
+ type: boolean
+ default: false
executor: node-browsers-executor
steps:
- run-graphics-tests:
- devicePixelRatio: "2.0"
- productionBuild: true
-
+ devicePixelRatio: << parameters.dpr >>
+ grep: << parameters.grep >>
+ productionBuild: << parameters.productionBuild >>
memleaks-tests:
executor: node-browsers-executor
@@ -307,6 +293,28 @@ jobs:
paths:
- website
+
+anchors:
+ - &graphics-test-matrix
+ parameters:
+ dpr: ["1.0", "1.25", "1.5", "2.0"]
+ productionBuild: [false, true]
+ exclude:
+ - dpr: "1.0"
+ productionBuild: true
+ - dpr: "1.25"
+ productionBuild: true
+ - dpr: "1.5"
+ productionBuild: true
+
+ - &graphics-test-config
+ requires:
+ - build
+ filters: *merge-based-filters
+ dpr: << matrix.dpr >>
+ productionBuild: << matrix.productionBuild >>
+
+
workflows:
version: 2
@@ -351,26 +359,21 @@ workflows:
filters: *merge-based-filters
requires:
- build
- - graphics-tests-dpr1_0:
- filters: *merge-based-filters
- requires:
- - build
- - graphics-tests-dpr1_25:
- filters: *merge-based-filters
- requires:
- - build
- - graphics-tests-dpr1_5:
- filters: *merge-based-filters
- requires:
- - build
- - graphics-tests-dpr2_0:
- filters: *merge-based-filters
- requires:
- - build
- - graphics-tests-dpr2_0-prod:
- filters: *merge-based-filters
- requires:
- - build
+ - graphics-tests:
+ name: graphics-tests-part1-dpr<< matrix.dpr >><< matrix.productionBuild >>
+ grep: "(api/|applying-options/|degenerative-horizontal-series-with-integer-min-tick/|)"
+ matrix: *graphics-test-matrix
+ <<: *graphics-test-config
+ - graphics-tests:
+ name: graphics-tests-part2-dpr<< matrix.dpr >><< matrix.productionBuild >>
+ grep: "(initial-options/|logical-range/|panes/|plugins/|two-scales/|test-cases/)"
+ matrix: *graphics-test-matrix
+ <<: *graphics-test-config
+ - graphics-tests:
+ name: graphics-tests-part3-dpr<< matrix.dpr >><< matrix.productionBuild >>
+ grep: "(price-scale/|series/|series-markers/|time-scale/)"
+ matrix: *graphics-test-matrix
+ <<: *graphics-test-config
- memleaks-tests:
filters: *default-filters
requires:
diff --git a/tests/e2e/graphics/helpers/get-test-cases.ts b/tests/e2e/graphics/helpers/get-test-cases.ts
index da2f8b3b36..a05842c436 100644
--- a/tests/e2e/graphics/helpers/get-test-cases.ts
+++ b/tests/e2e/graphics/helpers/get-test-cases.ts
@@ -1,7 +1,7 @@
///
import * as fs from 'fs';
-import { basename, dirname, join } from 'node:path';
+import { basename, dirname, join, normalize, sep } from 'node:path';
import { fileURLToPath } from 'node:url';
const currentFilePath = fileURLToPath(import.meta.url);
@@ -14,6 +14,18 @@ export interface TestCase {
const testCasesDir = join(currentDirectory, '..', 'test-cases');
+function splitPathToFolders(inputPath: string): string[] {
+ const normalizedPath = normalize(inputPath);
+ const folders = normalizedPath.split(sep).filter(Boolean);
+ return folders;
+}
+
+function extractTestCaseNameAndFolder(fileName: string): string | null {
+ const parentFolderAndFileName = splitPathToFolders(fileName).slice(-2).join('/');
+ const match = /^([^.].+)\.js$/.exec(parentFolderAndFileName);
+ return match && match[1];
+}
+
function extractTestCaseName(fileName: string): string | null {
const match = /^([^.].+)\.js$/.exec(basename(fileName));
return match && match[1];
@@ -61,7 +73,7 @@ export function getTestCases(): Record {
if (!testFilterRegex) {
return true;
}
- const name = extractTestCaseName(testCaseFile);
+ const name = extractTestCaseNameAndFolder(testCaseFile);
if (name) {
return testFilterRegex.test(name);
}
From 20e1e47592988ae8c9eb7b7f0e9754ff23a6829a Mon Sep 17 00:00:00 2001
From: Mark Silverwood <3482679+SlicedSilver@users.noreply.github.com>
Date: Tue, 30 Jul 2024 15:35:16 +0100
Subject: [PATCH 2/5] wrap grep env var in quotes
---
.circleci/config.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.circleci/config.yml b/.circleci/config.yml
index c3d5b3d77d..cff03e673d 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -75,7 +75,7 @@ commands:
echo 'export TESTS_REPORT_FILE="test-results/graphics/results.xml"' >> $BASH_ENV
echo 'export DEVICE_PIXEL_RATIO=<< parameters.devicePixelRatio >>' >> $BASH_ENV
echo 'export PRODUCTION_BUILD=<< parameters.productionBuild >>' >> $BASH_ENV
- echo 'export GREP=<< parameters.grep >>' >> $BASH_ENV
+ echo 'export GREP="<< parameters.grep >>"' >> $BASH_ENV
echo 'export COMPARE_BRANCH="v5-candidate"' >> $BASH_ENV
- run:
command: scripts/run-graphics-tests.sh
@@ -361,7 +361,7 @@ workflows:
- build
- graphics-tests:
name: graphics-tests-part1-dpr<< matrix.dpr >><< matrix.productionBuild >>
- grep: "(api/|applying-options/|degenerative-horizontal-series-with-integer-min-tick/|)"
+ grep: "(api/|applying-options/|degenerative-horizontal-series-with-integer-min-tick/)"
matrix: *graphics-test-matrix
<<: *graphics-test-config
- graphics-tests:
From 361a60d3d3489f5492209e1da40ee610a81eedae Mon Sep 17 00:00:00 2001
From: Mark Silverwood <3482679+SlicedSilver@users.noreply.github.com>
Date: Tue, 30 Jul 2024 15:46:28 +0100
Subject: [PATCH 3/5] re-balance the splitting of graphic tests
---
.circleci/config.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.circleci/config.yml b/.circleci/config.yml
index cff03e673d..d10d0695c9 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -361,7 +361,7 @@ workflows:
- build
- graphics-tests:
name: graphics-tests-part1-dpr<< matrix.dpr >><< matrix.productionBuild >>
- grep: "(api/|applying-options/|degenerative-horizontal-series-with-integer-min-tick/)"
+ grep: "(api/|applying-options/|series-markers/|price-scale/)"
matrix: *graphics-test-matrix
<<: *graphics-test-config
- graphics-tests:
@@ -371,7 +371,7 @@ workflows:
<<: *graphics-test-config
- graphics-tests:
name: graphics-tests-part3-dpr<< matrix.dpr >><< matrix.productionBuild >>
- grep: "(price-scale/|series/|series-markers/|time-scale/)"
+ grep: "(series/|series-markers/|time-scale/|degenerative-horizontal-series-with-integer-min-tick/)"
matrix: *graphics-test-matrix
<<: *graphics-test-config
- memleaks-tests:
From d6be0b01307f9147497feddf7f512dd32040ea07 Mon Sep 17 00:00:00 2001
From: Mark Silverwood <3482679+SlicedSilver@users.noreply.github.com>
Date: Tue, 30 Jul 2024 16:02:12 +0100
Subject: [PATCH 4/5] improve job titles
---
.circleci/config.yml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/.circleci/config.yml b/.circleci/config.yml
index d10d0695c9..9c9d7d3fd3 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -360,18 +360,18 @@ workflows:
requires:
- build
- graphics-tests:
- name: graphics-tests-part1-dpr<< matrix.dpr >><< matrix.productionBuild >>
+ name: graphics-tests-part1-dpr<< matrix.dpr >><<# matrix.productionBuild >>-PROD< matrix.productionBuild >>
grep: "(api/|applying-options/|series-markers/|price-scale/)"
matrix: *graphics-test-matrix
<<: *graphics-test-config
- graphics-tests:
- name: graphics-tests-part2-dpr<< matrix.dpr >><< matrix.productionBuild >>
+ name: graphics-tests-part2-dpr<< matrix.dpr >><<# matrix.productionBuild >>-PROD< matrix.productionBuild >>
grep: "(initial-options/|logical-range/|panes/|plugins/|two-scales/|test-cases/)"
matrix: *graphics-test-matrix
<<: *graphics-test-config
- graphics-tests:
- name: graphics-tests-part3-dpr<< matrix.dpr >><< matrix.productionBuild >>
- grep: "(series/|series-markers/|time-scale/|degenerative-horizontal-series-with-integer-min-tick/)"
+ name: graphics-tests-part3-dpr<< matrix.dpr >><<# matrix.productionBuild >>-PROD< matrix.productionBuild >>
+ grep: "(series/|time-scale/|degenerative-horizontal-series-with-integer-min-tick/)"
matrix: *graphics-test-matrix
<<: *graphics-test-config
- memleaks-tests:
From b46849fe318219ecf5fe1a999d1bd7e258a06303 Mon Sep 17 00:00:00 2001
From: Mark Silverwood <3482679+SlicedSilver@users.noreply.github.com>
Date: Tue, 30 Jul 2024 16:02:35 +0100
Subject: [PATCH 5/5] updated outdated commands in tests/README.md
---
tests/README.md | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/tests/README.md b/tests/README.md
index 7e4e7fdab3..b9cd34b4f2 100644
--- a/tests/README.md
+++ b/tests/README.md
@@ -47,7 +47,7 @@ You can run the coverage test with the following command:
Alternatively, you can run the test on a specific file like this:
```bash
-node ./tests/e2e/coverage/runner.js ./dist/lightweight-charts.standalone.development.js
+npx esno ./tests/e2e/coverage/runner.ts ./dist/lightweight-charts.standalone.development.js
```
#### Analysing the Coverage test
@@ -75,7 +75,7 @@ You can run the graphics tests with the following command:
Alternatively, you can run the test on specific files like this:
```bash
-node ./tests/e2e/graphics/runner.js ./path/to/golden/standalone/module.js ./path/to/test/standalone/module.js
+npx esno ./tests/e2e/graphics/runner.ts ./path/to/golden/standalone/module.js ./path/to/test/standalone/module.js
```
The following enviromental variables can be used to adjust the test:
@@ -85,7 +85,7 @@ The following enviromental variables can be used to adjust the test:
- `CMP_OUT_DIR`: Directory to output the test artifacts. (Defaults to `.gendata`)
```bash
-PRODUCTION_BUILD=false DEVICE_PIXEL_RATIO=1.5 node ./tests/e2e/graphics/runner.js ./golden/lightweight-charts.standalone.development.js ./dist/lightweight-charts.standalone.development.js
+PRODUCTION_BUILD=false DEVICE_PIXEL_RATIO=1.5 npx esno ./tests/e2e/graphics/runner.ts ./golden/lightweight-charts.standalone.development.js ./dist/lightweight-charts.standalone.development.js
```
### Memory Leaks
@@ -103,7 +103,7 @@ You can run the memory leak test with the following command:
Alternatively, you can run the test on a specific file like this:
```bash
-node ./tests/e2e/memleaks/runner.js ./dist/lightweight-charts.standalone.development.js
+npx esno ./tests/e2e/memleaks/runner.ts ./dist/lightweight-charts.standalone.development.js
```
### Interactions
@@ -121,5 +121,5 @@ You can run the interactions tests with the following command:
Alternatively, you can run the tests on a specific file like this:
```bash
-node ./tests/e2e/interactions/runner.js ./dist/lightweight-charts.standalone.development.js
+npx esno ./tests/e2e/interactions/runner.ts ./dist/lightweight-charts.standalone.development.js
```