Skip to content

Commit f9152ce

Browse files
Fix @shopify/stylelint-plugin failures due to missing npm test (#30)
* Fix `@shopify/stylelint-plugin` failures due to missing `npm test` * add flag * fix * try yarn? * Update .github/workflows/test-package.yml Co-authored-by: Masafumi Koba <[email protected]> * apply suggestions from code review --------- Co-authored-by: Masafumi Koba <[email protected]>
1 parent 2064a20 commit f9152ce

File tree

5 files changed

+40
-5
lines changed

5 files changed

+40
-5
lines changed

.github/workflows/test-package-shopify-stylelint-plugin-a90.latest.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ jobs:
2323
with:
2424
package: '@shopify/stylelint-plugin'
2525
stylelint-version: stylelint@latest
26+
test-command: NODE_OPTIONS="--experimental-vm-modules --no-warnings" npx jest
27+
--runInBand
28+
install-command: yarn

.github/workflows/test-package-shopify-stylelint-plugin-a90.next.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ jobs:
2323
with:
2424
package: '@shopify/stylelint-plugin'
2525
stylelint-version: stylelint/stylelint
26+
test-command: NODE_OPTIONS="--experimental-vm-modules --no-warnings" npx jest
27+
--runInBand
28+
install-command: yarn

.github/workflows/test-package.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ on:
1111
type: string
1212
description: The Stylelint version to test
1313
required: true
14+
test-command:
15+
type: string
16+
description: The test command to run
17+
default: 'npm test'
18+
install-command:
19+
type: string
20+
description: The install command to run
21+
default: 'npm install --no-audit'
1422

1523
jobs:
1624
test:
@@ -64,8 +72,9 @@ jobs:
6472
working-directory: ${{ steps.repo-info.outputs.directory }}
6573
env:
6674
PACKAGE_URL: ${{ steps.repo-info.outputs.url }}
75+
INSTALL_COMMAND: ${{ inputs.install-command }}
6776
run: |
68-
if ! npm install --no-audit; then
77+
if ! eval "$INSTALL_COMMAND"; then
6978
echo "::error ::The dependency installation failed. Visit ${PACKAGE_URL}"
7079
exit 1
7180
fi
@@ -98,8 +107,9 @@ jobs:
98107
working-directory: ${{ steps.repo-info.outputs.directory }}
99108
env:
100109
PACKAGE_URL: ${{ steps.repo-info.outputs.url }}
110+
TEST_COMMAND: ${{ inputs.test-command }}
101111
run: |
102-
if ! npm test; then
112+
if ! eval "$TEST_COMMAND"; then
103113
echo "::error ::The test failed. Visit ${PACKAGE_URL}"
104114
exit 1
105115
fi

data/ecosystem.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
packages:
22
# In alphabetical order
33
- '@primer/stylelint-config'
4-
- '@shopify/stylelint-plugin'
4+
- [
5+
'@shopify/stylelint-plugin',
6+
{
7+
install-command: 'yarn',
8+
test-command: 'NODE_OPTIONS="--experimental-vm-modules --no-warnings" npx jest --runInBand',
9+
},
10+
]
511
- '@stylistic/stylelint-config'
612
- '@stylistic/stylelint-plugin'
713
- '@wordpress/stylelint-config'

scripts/update-workflows.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import workflowFilename from './utils/workflow-filename.js';
1010
function generateWorkflow({
1111
concurrencyGroup,
1212
pkg,
13+
config,
1314
stylelintVersion,
1415
template,
1516
workflowFilePath,
@@ -34,6 +35,14 @@ function generateWorkflow({
3435
workflow.jobs.test.with.package = pkg;
3536
workflow.jobs.test.with['stylelint-version'] = stylelintVersion;
3637

38+
if (config['test-command']) {
39+
workflow.jobs.test.with['test-command'] = config['test-command'];
40+
}
41+
42+
if (config['install-command']) {
43+
workflow.jobs.test.with['install-command'] = config['install-command'];
44+
}
45+
3746
return workflow;
3847
}
3948

@@ -58,13 +67,16 @@ const workflowTemplateFile = new URL('../templates/test-package.yml', import.met
5867
const workflowTemplateContent = readFileSync(workflowTemplateFile, 'utf8');
5968

6069
// Generate workflows for each package
61-
ecosystemData.packages.forEach((pkg) => {
62-
const slug = generateSlug(pkg);
70+
ecosystemData.packages.forEach((packageConfig, index) => {
71+
const [pkg, config = {}] = [packageConfig].flat();
72+
73+
const slug = generateSlug(pkg, index);
6374

6475
const latestStylelintWorkflowFilePath = `.github/workflows/${workflowFilename(slug, 'latest')}`;
6576
const latestStylelintWorkflow = generateWorkflow({
6677
concurrencyGroup: `\${{ github.workflow }}-\${{ github.ref }}-${slug}-latest`,
6778
pkg,
79+
config,
6880
stylelintVersion: 'stylelint@latest',
6981
template: workflowTemplateContent,
7082
workflowFilePath: latestStylelintWorkflowFilePath,
@@ -81,6 +93,7 @@ ecosystemData.packages.forEach((pkg) => {
8193
const nextStylelintWorkflow = generateWorkflow({
8294
concurrencyGroup: `\${{ github.workflow }}-\${{ github.ref }}-${slug}-next`,
8395
pkg,
96+
config,
8497
stylelintVersion: 'stylelint/stylelint',
8598
template: workflowTemplateContent,
8699
workflowFilePath: nextStylelintWorkflowFilePath,

0 commit comments

Comments
 (0)