Skip to content

Commit 094a40a

Browse files
authored
chore: exit GH action if no ported Lumo packages were changed (#9282)
1 parent 14d9b5c commit 094a40a

File tree

1 file changed

+24
-28
lines changed

1 file changed

+24
-28
lines changed

wtr-utils.js

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,16 @@ const getAllVisualPackages = () => {
9999
.filter((dir) => fs.statSync(`packages/${dir}`).isDirectory() && fs.existsSync(`packages/${dir}/test/visual`));
100100
};
101101

102+
const getAllPortedLumoPackages = () => {
103+
return fs
104+
.readdirSync('packages')
105+
.filter(
106+
(dir) =>
107+
fs.statSync(`packages/${dir}`).isDirectory() &&
108+
fs.existsSync(`packages/vaadin-lumo-styles/src/components/${dir}.css`),
109+
);
110+
};
111+
102112
/**
103113
* Get all available packages with visual tests for base styles.
104114
*/
@@ -171,38 +181,16 @@ const getUnitTestGroups = (packages) => {
171181
* Get visual test groups based on packages.
172182
*/
173183
const getVisualTestGroups = (packages, theme) => {
174-
packages = packages.map((pkg) => {
184+
if (theme === 'base') {
185+
packages = packages.filter(({ name }) => !name.includes('lumo'));
186+
}
187+
188+
return packages.map((pkg) => {
175189
return {
176190
name: pkg,
177191
files: [`packages/${pkg}/test/visual/*.test.{js,ts}`, `packages/${pkg}/test/visual/${theme}/*.test.{js,ts}`],
178192
};
179193
});
180-
181-
if (theme === 'base') {
182-
packages = packages.filter(({ name }) => !name.includes('lumo'));
183-
}
184-
185-
if (theme === 'lumo' && hasPortedParam) {
186-
packages = packages.map(({ name, files }) => {
187-
return {
188-
name,
189-
files: files.flatMap((glob) => {
190-
if (name.includes('lumo')) {
191-
// In the theme package, run all visual tests
192-
return glob;
193-
}
194-
195-
return globSync(glob).filter((file) => {
196-
// Otherwise, only run visual tests that import CSS files
197-
const content = fs.readFileSync(file, 'utf-8').toString();
198-
return /vaadin-lumo-styles\/[^.]+\.css/u.test(content);
199-
});
200-
}),
201-
};
202-
});
203-
}
204-
205-
return packages.filter((group) => group.files.length > 0);
206194
};
207195

208196
const getTestRunnerHtml = () => (testFramework) =>
@@ -289,7 +277,15 @@ const createUnitTestsConfig = (config) => {
289277
};
290278

291279
const createVisualTestsConfig = (theme, browserVersion) => {
292-
const visualPackages = theme === 'base' ? getAllBasePackages() : getAllVisualPackages();
280+
let visualPackages = [];
281+
if (theme === 'base') {
282+
visualPackages = getAllBasePackages();
283+
} else if (theme === 'lumo' && hasPortedParam) {
284+
visualPackages = getAllPortedLumoPackages();
285+
} else {
286+
visualPackages = getAllVisualPackages();
287+
}
288+
293289
const packages = getTestPackages(visualPackages);
294290
const groups = getVisualTestGroups(packages, theme);
295291

0 commit comments

Comments
 (0)