Skip to content

Commit

Permalink
Fix @shopify/stylelint-plugin failures due to missing npm test (#30)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
romainmenke and ybiquitous authored Aug 5, 2024
1 parent 2064a20 commit f9152ce
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ jobs:
with:
package: '@shopify/stylelint-plugin'
stylelint-version: stylelint@latest
test-command: NODE_OPTIONS="--experimental-vm-modules --no-warnings" npx jest
--runInBand
install-command: yarn
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ jobs:
with:
package: '@shopify/stylelint-plugin'
stylelint-version: stylelint/stylelint
test-command: NODE_OPTIONS="--experimental-vm-modules --no-warnings" npx jest
--runInBand
install-command: yarn
14 changes: 12 additions & 2 deletions .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ on:
type: string
description: The Stylelint version to test
required: true
test-command:
type: string
description: The test command to run
default: 'npm test'
install-command:
type: string
description: The install command to run
default: 'npm install --no-audit'

jobs:
test:
Expand Down Expand Up @@ -64,8 +72,9 @@ jobs:
working-directory: ${{ steps.repo-info.outputs.directory }}
env:
PACKAGE_URL: ${{ steps.repo-info.outputs.url }}
INSTALL_COMMAND: ${{ inputs.install-command }}
run: |
if ! npm install --no-audit; then
if ! eval "$INSTALL_COMMAND"; then
echo "::error ::The dependency installation failed. Visit ${PACKAGE_URL}"
exit 1
fi
Expand Down Expand Up @@ -98,8 +107,9 @@ jobs:
working-directory: ${{ steps.repo-info.outputs.directory }}
env:
PACKAGE_URL: ${{ steps.repo-info.outputs.url }}
TEST_COMMAND: ${{ inputs.test-command }}
run: |
if ! npm test; then
if ! eval "$TEST_COMMAND"; then
echo "::error ::The test failed. Visit ${PACKAGE_URL}"
exit 1
fi
8 changes: 7 additions & 1 deletion data/ecosystem.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
packages:
# In alphabetical order
- '@primer/stylelint-config'
- '@shopify/stylelint-plugin'
- [
'@shopify/stylelint-plugin',
{
install-command: 'yarn',
test-command: 'NODE_OPTIONS="--experimental-vm-modules --no-warnings" npx jest --runInBand',
},
]
- '@stylistic/stylelint-config'
- '@stylistic/stylelint-plugin'
- '@wordpress/stylelint-config'
Expand Down
17 changes: 15 additions & 2 deletions scripts/update-workflows.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import workflowFilename from './utils/workflow-filename.js';
function generateWorkflow({
concurrencyGroup,
pkg,
config,
stylelintVersion,
template,
workflowFilePath,
Expand All @@ -34,6 +35,14 @@ function generateWorkflow({
workflow.jobs.test.with.package = pkg;
workflow.jobs.test.with['stylelint-version'] = stylelintVersion;

if (config['test-command']) {
workflow.jobs.test.with['test-command'] = config['test-command'];
}

if (config['install-command']) {
workflow.jobs.test.with['install-command'] = config['install-command'];
}

return workflow;
}

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

// Generate workflows for each package
ecosystemData.packages.forEach((pkg) => {
const slug = generateSlug(pkg);
ecosystemData.packages.forEach((packageConfig, index) => {
const [pkg, config = {}] = [packageConfig].flat();

const slug = generateSlug(pkg, index);

const latestStylelintWorkflowFilePath = `.github/workflows/${workflowFilename(slug, 'latest')}`;
const latestStylelintWorkflow = generateWorkflow({
concurrencyGroup: `\${{ github.workflow }}-\${{ github.ref }}-${slug}-latest`,
pkg,
config,
stylelintVersion: 'stylelint@latest',
template: workflowTemplateContent,
workflowFilePath: latestStylelintWorkflowFilePath,
Expand All @@ -81,6 +93,7 @@ ecosystemData.packages.forEach((pkg) => {
const nextStylelintWorkflow = generateWorkflow({
concurrencyGroup: `\${{ github.workflow }}-\${{ github.ref }}-${slug}-next`,
pkg,
config,
stylelintVersion: 'stylelint/stylelint',
template: workflowTemplateContent,
workflowFilePath: nextStylelintWorkflowFilePath,
Expand Down

0 comments on commit f9152ce

Please sign in to comment.