Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tools: Product-specific visual comparison #19990

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ test/cypress
test/test-*.*
test/*.ts
test/typescript-karma
tools/affected-product
tools/eslint-plugin-highcharts/node_modules/**
tools/gulptasks/dashboards/api-docs/**/*.js
tools/jsdoc/storage/**/*.js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ jobs:
- name: Build Highcharts
run: npx gulp scripts

- name: Build Dashboards
run: npx gulp dashboards/scripts

- name: Write file sizes at master
run: npx gulp write-file-sizes --filename master.json

Expand Down Expand Up @@ -107,10 +104,10 @@ jobs:
- name: Build Highcharts
run: npx gulp scripts

- run: npx karma start test/karma-conf.js --tests highcharts/*/* --reference --browsercount 2 --no-fail-on-empty-test-suite
- run: npx karma start test/karma-conf.js --tests maps/*/* --reference --browsercount 2 --no-fail-on-empty-test-suite
- run: npx karma start test/karma-conf.js --tests stock/*/* --reference --browsercount 2 --no-fail-on-empty-test-suite
- run: npx karma start test/karma-conf.js --tests gantt/*/* --reference --browsercount 2 --no-fail-on-empty-test-suite
- run: ./tools/affected-product Core Data Series Shared && npx karma start test/karma-conf.js --tests highcharts/*/* --reference --browsercount 2 --no-fail-on-empty-test-suite
- run: ./tools/affected-product Stock Data Series Shared && npx karma start test/karma-conf.js --tests stock/*/* --reference --browsercount 2 --no-fail-on-empty-test-suite
- run: ./tools/affected-product Maps Data Series Shared && npx karma start test/karma-conf.js --tests maps/*/* --reference --browsercount 2 --no-fail-on-empty-test-suite
- run: ./tools/affected-product Gantt Data Series Shared && npx karma start test/karma-conf.js --tests gantt/*/* --reference --browsercount 2 --no-fail-on-empty-test-suite

- name: Checkout current branch
uses: actions/checkout@v4
Expand Down Expand Up @@ -138,10 +135,10 @@ jobs:
- name: Build Highcharts
run: npx gulp scripts

- run: npx karma start test/karma-conf.js --tests highcharts/*/* --single-run --browsercount 2 --visualcompare || true
- run: npx karma start test/karma-conf.js --tests stock/*/* --single-run --browsercount 2 --visualcompare || true
- run: npx karma start test/karma-conf.js --tests maps/*/* --single-run --browsercount 2 --visualcompare || true
- run: npx karma start test/karma-conf.js --tests gantt/*/* --single-run --browsercount 2 --visualcompare || true
- run: ./tools/affected-product Core Data Series Shared && npx karma start test/karma-conf.js --tests highcharts/*/* --single-run --browsercount 2 --visualcompare || true
- run: ./tools/affected-product Stock Data Series Shared && npx karma start test/karma-conf.js --tests stock/*/* --single-run --browsercount 2 --visualcompare || true
- run: ./tools/affected-product Maps Data Series Shared && npx karma start test/karma-conf.js --tests maps/*/* --single-run --browsercount 2 --visualcompare || true
- run: ./tools/affected-product Gantt Data Series Shared && npx karma start test/karma-conf.js --tests gantt/*/* --single-run --browsercount 2 --visualcompare || true

- name: Save test results where both an reference.svg and candidate.svg exists
run: |
Expand Down
31 changes: 31 additions & 0 deletions tools/affected-product
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env node
const { execSync } = require('node:child_process');

if (process.argv.includes('-h') || process.argv.includes('--help')) {
console.log([
'affected-product [PRODUCT_FOLDERS]',
'Tests whether a product folder is affected by new commits.',
'',
' [PRODUCT_FOLDERS] - Folder in ./ts',
'',
'Exit with code 0, if product folders are affected.',
'Exit with code 1, if product folders are not affected.'
].join('\n'));
process.exit(1);
}

const affectedFolders = execSync('git diff HEAD^ HEAD --name-only --diff-filter=ACM')
.toString()
.split(/\s/gu)
.filter(path => !!path)
.map(path => path.split(/\//gu)[1]),
testFolders = process.argv.filter(folder => folder[0] !== '/');

for (const folder of testFolders) {
if (affectedFolders.includes(folder)) {
console.log(`${folder} affected`);
process.exit(0);
}
}

process.exit(1);
22 changes: 8 additions & 14 deletions tools/gulptasks/lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* Array of detected products.
*/
function getProducts(logPaths) {
const ChildProcess = require('child_process');
const ChildProcess = require('node:child_process');

const paths = ChildProcess
.execSync('git diff --cached --name-only --diff-filter=ACM')
Expand All @@ -38,43 +38,37 @@ function getProducts(logPaths) {
'Maps',
'Stock'
],
affectedProducts = [];
affectedProducts = new Set();

// Logging for testing and debugging
if (logPaths) {
const log = require('./log');
log.message('paths: ', paths);
}

function mark(product) {
if (affectedProducts.indexOf(product) !== -1) {
affectedProducts.push(product);
}
}

paths.forEach(path => {
// Any path part check
products.forEach(productName => {
const productNameRegex = new RegExp(productName, 'iu');
if (productNameRegex.test(path)) {
mark(productName);
affectedProducts.add(productName);
}
});

// By directory detection
const pathParts = path.split('/');

if (pathParts.length > 2 && pathParts[0] === 'ts') {
if (['Shared', 'Data'].indexOf(pathParts[1]) !== -1) {
mark('Core');
mark('Dashboards');
if (['Accessibility', 'Shared', 'Data'].indexOf(pathParts[1]) !== -1) {
affectedProducts.add('Core');
affectedProducts.add('Dashboards');
} else if (pathParts[1] === 'DataGrid') {
mark('Dashboards');
affectedProducts.add('Dashboards');
}
}
});

return affectedProducts;
return Array.from(affectedProducts);
}

/**
Expand Down
Loading