From 3c2b864f2021ca83b24174f03906647dbd9a66dd Mon Sep 17 00:00:00 2001 From: Romain Menke <11521496+romainmenke@users.noreply.github.com> Date: Sun, 8 Sep 2024 18:32:46 +0200 Subject: [PATCH] Fix `stylelint-config-recommended-less` failures due to pnpm workspace (#37) * Fix `stylelint-config-recommended-less` failures due to pnpm workspace * use overrides * fix * add feedback * add feedback * wip * wip * wip * wip * wip * restore other tests * readme * fix * Update data/ecosystem.yml Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com> * update-workflows --------- Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com> --- ...ge-shopify-stylelint-plugin-a90.latest.yml | 3 +- ...kage-shopify-stylelint-plugin-a90.next.yml | 3 +- ...int-config-recommended-less-00b.latest.yml | 26 ---------- ...elint-config-recommended-less-00b.next.yml | 26 ---------- ...test-package-stylelint-less-d99.latest.yml | 6 +++ .../test-package-stylelint-less-d99.next.yml | 6 +++ .github/workflows/test-package.yml | 52 ++++++++++++++++--- README.md | 3 +- data/ecosystem.yml | 13 ++++- scripts/update-workflows.js | 21 +++++++- 10 files changed, 91 insertions(+), 68 deletions(-) delete mode 100644 .github/workflows/test-package-stylelint-config-recommended-less-00b.latest.yml delete mode 100644 .github/workflows/test-package-stylelint-config-recommended-less-00b.next.yml diff --git a/.github/workflows/test-package-shopify-stylelint-plugin-a90.latest.yml b/.github/workflows/test-package-shopify-stylelint-plugin-a90.latest.yml index b1bd4ed..53ca427 100644 --- a/.github/workflows/test-package-shopify-stylelint-plugin-a90.latest.yml +++ b/.github/workflows/test-package-shopify-stylelint-plugin-a90.latest.yml @@ -23,6 +23,7 @@ jobs: with: package: '@shopify/stylelint-plugin' stylelint-version: stylelint@latest + install-command: yarn + list-installed-versions-command: yarn list --pattern stylelint test-command: NODE_OPTIONS="--experimental-vm-modules --no-warnings" npx jest --runInBand - install-command: yarn diff --git a/.github/workflows/test-package-shopify-stylelint-plugin-a90.next.yml b/.github/workflows/test-package-shopify-stylelint-plugin-a90.next.yml index 54ff869..f24049c 100644 --- a/.github/workflows/test-package-shopify-stylelint-plugin-a90.next.yml +++ b/.github/workflows/test-package-shopify-stylelint-plugin-a90.next.yml @@ -23,6 +23,7 @@ jobs: with: package: '@shopify/stylelint-plugin' stylelint-version: stylelint/stylelint + install-command: yarn + list-installed-versions-command: yarn list --pattern stylelint test-command: NODE_OPTIONS="--experimental-vm-modules --no-warnings" npx jest --runInBand - install-command: yarn diff --git a/.github/workflows/test-package-stylelint-config-recommended-less-00b.latest.yml b/.github/workflows/test-package-stylelint-config-recommended-less-00b.latest.yml deleted file mode 100644 index ae06e61..0000000 --- a/.github/workflows/test-package-stylelint-config-recommended-less-00b.latest.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: stylelint-config-recommended-less -on: - push: - branches: - - main - paths: - - .github/workflows/test-package.yml - - .github/workflows/test-package-stylelint-config-recommended-less-00b.latest.yml - pull_request: - paths: - - .github/workflows/test-package.yml - - .github/workflows/test-package-stylelint-config-recommended-less-00b.latest.yml - workflow_dispatch: null - schedule: - - cron: 0 0 * * * -concurrency: - group: ${{ github.workflow }}-${{ github.ref - }}-stylelint-config-recommended-less-00b-latest - cancel-in-progress: true -jobs: - test: - uses: ./.github/workflows/test-package.yml - name: latest - with: - package: stylelint-config-recommended-less - stylelint-version: stylelint@latest diff --git a/.github/workflows/test-package-stylelint-config-recommended-less-00b.next.yml b/.github/workflows/test-package-stylelint-config-recommended-less-00b.next.yml deleted file mode 100644 index 5feb046..0000000 --- a/.github/workflows/test-package-stylelint-config-recommended-less-00b.next.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: stylelint-config-recommended-less -on: - push: - branches: - - main - paths: - - .github/workflows/test-package.yml - - .github/workflows/test-package-stylelint-config-recommended-less-00b.next.yml - pull_request: - paths: - - .github/workflows/test-package.yml - - .github/workflows/test-package-stylelint-config-recommended-less-00b.next.yml - workflow_dispatch: null - schedule: - - cron: 0 0 * * * -concurrency: - group: ${{ github.workflow }}-${{ github.ref - }}-stylelint-config-recommended-less-00b-next - cancel-in-progress: true -jobs: - test: - uses: ./.github/workflows/test-package.yml - name: next - with: - package: stylelint-config-recommended-less - stylelint-version: stylelint/stylelint diff --git a/.github/workflows/test-package-stylelint-less-d99.latest.yml b/.github/workflows/test-package-stylelint-less-d99.latest.yml index 97ddc36..89c23fc 100644 --- a/.github/workflows/test-package-stylelint-less-d99.latest.yml +++ b/.github/workflows/test-package-stylelint-less-d99.latest.yml @@ -23,3 +23,9 @@ jobs: with: package: stylelint-less stylelint-version: stylelint@latest + set-overrides-command: npm pkg set pnpm.overrides.stylelint + stylelint-version-override: latest + install-command: pnpm install --no-frozen-lockfile + list-installed-versions-command: pnpm list --long --json stylelint + build-command: pnpm -r build + test-command: pnpm -r test diff --git a/.github/workflows/test-package-stylelint-less-d99.next.yml b/.github/workflows/test-package-stylelint-less-d99.next.yml index 0a54f3e..da8a101 100644 --- a/.github/workflows/test-package-stylelint-less-d99.next.yml +++ b/.github/workflows/test-package-stylelint-less-d99.next.yml @@ -23,3 +23,9 @@ jobs: with: package: stylelint-less stylelint-version: stylelint/stylelint + set-overrides-command: npm pkg set pnpm.overrides.stylelint + stylelint-version-override: github:stylelint/stylelint + install-command: pnpm install --no-frozen-lockfile + list-installed-versions-command: pnpm list --long --json stylelint + build-command: pnpm -r build + test-command: pnpm -r test diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index ab986b7..d8761a4 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -11,14 +11,28 @@ on: type: string description: The Stylelint version to test required: true - test-command: + stylelint-version-override: type: string - description: The test command to run - default: 'npm test' + description: The Stylelint version override + set-overrides-command: + type: string + description: The command to set dependency overrides install-command: type: string description: The install command to run default: 'npm install --no-audit' + list-installed-versions-command: + type: string + description: The list dependencies command to run + default: 'npm list stylelint' + build-command: + type: string + description: The build command to run + default: 'npm run build --if-present' + test-command: + type: string + description: The test command to run + default: 'npm test' jobs: test: @@ -67,8 +81,20 @@ jobs: npm install --global yarn echo "yarn: $(yarn --version)" + - name: Set dependency overrides + env: + SET_OVERRIDES_COMMAND: ${{ inputs.set-overrides-command }} + STYLELINT_VERSION_OVERRIDE: ${{ inputs.stylelint-version-override }} + if: ${{ inputs.set-overrides-command }} + run: | + if ! eval "$SET_OVERRIDES_COMMAND=$STYLELINT_VERSION_OVERRIDE"; then + echo "::error ::Setting dependency overrides failed." + exit 1 + fi + + npm pkg get; + - name: Install dependencies - id: install-dependencies working-directory: ${{ steps.repo-info.outputs.directory }} env: PACKAGE_URL: ${{ steps.repo-info.outputs.url }} @@ -80,8 +106,8 @@ jobs: fi - name: Install Stylelint ${{ inputs.stylelint-version }} - id: install-stylelint working-directory: ${{ steps.repo-info.outputs.directory }} + if: ${{ ! inputs.set-overrides-command }} env: STYLELINT_VERSION: ${{ inputs.stylelint-version }} PACKAGE_URL: ${{ steps.repo-info.outputs.url }} @@ -91,19 +117,29 @@ jobs: exit 1 fi + - name: List installed Stylelint versions + working-directory: ${{ steps.repo-info.outputs.directory }} + env: + PACKAGE_URL: ${{ steps.repo-info.outputs.url }} + LIST_INSTALLED_VERSIONS_COMMAND: ${{ inputs.list-installed-versions-command }} + run: | + if ! eval "$LIST_INSTALLED_VERSIONS_COMMAND"; then + echo "::error ::Listing dependencies failed." + # `npm list` has a non-zero exit code when overriding dependencies + fi + - name: Run build - id: build working-directory: ${{ steps.repo-info.outputs.directory }} env: PACKAGE_URL: ${{ steps.repo-info.outputs.url }} + BUILD_COMMAND: ${{ inputs.build-command }} run: | - if ! npm run build --if-present; then + if ! eval "$BUILD_COMMAND"; then echo "::error ::The build failed. Visit ${PACKAGE_URL}" exit 1 fi - name: Run test - id: test working-directory: ${{ steps.repo-info.outputs.directory }} env: PACKAGE_URL: ${{ steps.repo-info.outputs.url }} diff --git a/README.md b/README.md index c83d8a4..885ebac 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,6 @@ To see test results, click the status badge for the relevant package in the list | [![stylelint-config-rational-order](https://img.shields.io/npm/v/stylelint-config-rational-order.svg)](https://www.npmjs.com/package/stylelint-config-rational-order) | [![latest](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-config-rational-order-966.latest.yml/badge.svg)](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-config-rational-order-966.latest.yml) | [![next](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-config-rational-order-966.next.yml/badge.svg)](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-config-rational-order-966.next.yml) | | [![stylelint-config-recess-order](https://img.shields.io/npm/v/stylelint-config-recess-order.svg)](https://www.npmjs.com/package/stylelint-config-recess-order) | [![latest](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-config-recess-order-9f7.latest.yml/badge.svg)](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-config-recess-order-9f7.latest.yml) | [![next](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-config-recess-order-9f7.next.yml/badge.svg)](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-config-recess-order-9f7.next.yml) | | [![stylelint-config-recommended](https://img.shields.io/npm/v/stylelint-config-recommended.svg)](https://www.npmjs.com/package/stylelint-config-recommended) | [![latest](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-config-recommended-64e.latest.yml/badge.svg)](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-config-recommended-64e.latest.yml) | [![next](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-config-recommended-64e.next.yml/badge.svg)](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-config-recommended-64e.next.yml) | -| [![stylelint-config-recommended-less](https://img.shields.io/npm/v/stylelint-config-recommended-less.svg)](https://www.npmjs.com/package/stylelint-config-recommended-less) | [![latest](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-config-recommended-less-00b.latest.yml/badge.svg)](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-config-recommended-less-00b.latest.yml) | [![next](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-config-recommended-less-00b.next.yml/badge.svg)](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-config-recommended-less-00b.next.yml) | | [![stylelint-config-recommended-scss](https://img.shields.io/npm/v/stylelint-config-recommended-scss.svg)](https://www.npmjs.com/package/stylelint-config-recommended-scss) | [![latest](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-config-recommended-scss-362.latest.yml/badge.svg)](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-config-recommended-scss-362.latest.yml) | [![next](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-config-recommended-scss-362.next.yml/badge.svg)](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-config-recommended-scss-362.next.yml) | | [![stylelint-config-recommended-vue](https://img.shields.io/npm/v/stylelint-config-recommended-vue.svg)](https://www.npmjs.com/package/stylelint-config-recommended-vue) | [![latest](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-config-recommended-vue-162.latest.yml/badge.svg)](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-config-recommended-vue-162.latest.yml) | [![next](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-config-recommended-vue-162.next.yml/badge.svg)](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-config-recommended-vue-162.next.yml) | | [![stylelint-config-sass-guidelines](https://img.shields.io/npm/v/stylelint-config-sass-guidelines.svg)](https://www.npmjs.com/package/stylelint-config-sass-guidelines) | [![latest](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-config-sass-guidelines-324.latest.yml/badge.svg)](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-config-sass-guidelines-324.latest.yml) | [![next](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-config-sass-guidelines-324.next.yml/badge.svg)](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-config-sass-guidelines-324.next.yml) | @@ -65,7 +64,7 @@ To see test results, click the status badge for the relevant package in the list | [![stylelint-use-nesting](https://img.shields.io/npm/v/stylelint-use-nesting.svg)](https://www.npmjs.com/package/stylelint-use-nesting) | [![latest](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-use-nesting-54f.latest.yml/badge.svg)](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-use-nesting-54f.latest.yml) | [![next](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-use-nesting-54f.next.yml/badge.svg)](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-use-nesting-54f.next.yml) | | [![stylelint-value-no-unknown-custom-properties](https://img.shields.io/npm/v/stylelint-value-no-unknown-custom-properties.svg)](https://www.npmjs.com/package/stylelint-value-no-unknown-custom-properties) | [![latest](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-value-no-unknown-custom-properties-2f3.latest.yml/badge.svg)](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-value-no-unknown-custom-properties-2f3.latest.yml) | [![next](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-value-no-unknown-custom-properties-2f3.next.yml/badge.svg)](https://github.com/stylelint/stylelint-ecosystem-tester/actions/workflows/test-package-stylelint-value-no-unknown-custom-properties-2f3.next.yml) | -Total 50 packages +Total 49 packages diff --git a/data/ecosystem.yml b/data/ecosystem.yml index bf12259..75d3624 100644 --- a/data/ecosystem.yml +++ b/data/ecosystem.yml @@ -5,6 +5,7 @@ packages: '@shopify/stylelint-plugin', { install-command: 'yarn', + list-installed-versions-command: 'yarn list --pattern stylelint', test-command: 'NODE_OPTIONS="--experimental-vm-modules --no-warnings" npx jest --runInBand', }, ] @@ -22,7 +23,6 @@ packages: - 'stylelint-config-rational-order' - 'stylelint-config-recess-order' - 'stylelint-config-recommended' - - 'stylelint-config-recommended-less' - 'stylelint-config-recommended-scss' - 'stylelint-config-recommended-vue' - 'stylelint-config-sass-guidelines' @@ -39,7 +39,16 @@ packages: - 'stylelint-declaration-strict-value' - 'stylelint-formatter-pretty' - 'stylelint-high-performance-animation' - - 'stylelint-less' + - [ + 'stylelint-less', + { + set-overrides-command: 'npm pkg set pnpm.overrides.stylelint', + install-command: 'pnpm install --no-frozen-lockfile', + list-installed-versions-command: 'pnpm list --long --json stylelint', + build-command: 'pnpm -r build', + test-command: 'pnpm -r test', + }, + ] - 'stylelint-media-use-custom-media' - 'stylelint-no-unsupported-browser-features' - 'stylelint-order' diff --git a/scripts/update-workflows.js b/scripts/update-workflows.js index 3d4b97a..42e625d 100644 --- a/scripts/update-workflows.js +++ b/scripts/update-workflows.js @@ -12,6 +12,7 @@ function generateWorkflow({ pkg, config, stylelintVersion, + stylelintVersionOverride, template, workflowFilePath, workflowName, @@ -35,14 +36,28 @@ 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['set-overrides-command']) { + workflow.jobs.test.with['set-overrides-command'] = config['set-overrides-command']; + workflow.jobs.test.with['stylelint-version-override'] = stylelintVersionOverride; } if (config['install-command']) { workflow.jobs.test.with['install-command'] = config['install-command']; } + if (config['list-installed-versions-command']) { + workflow.jobs.test.with['list-installed-versions-command'] = + config['list-installed-versions-command']; + } + + if (config['build-command']) { + workflow.jobs.test.with['build-command'] = config['build-command']; + } + + if (config['test-command']) { + workflow.jobs.test.with['test-command'] = config['test-command']; + } + return workflow; } @@ -78,6 +93,7 @@ ecosystemData.packages.forEach((packageConfig, index) => { pkg, config, stylelintVersion: 'stylelint@latest', + stylelintVersionOverride: 'latest', template: workflowTemplateContent, workflowFilePath: latestStylelintWorkflowFilePath, workflowName: pkg, @@ -95,6 +111,7 @@ ecosystemData.packages.forEach((packageConfig, index) => { pkg, config, stylelintVersion: 'stylelint/stylelint', + stylelintVersionOverride: 'github:stylelint/stylelint', template: workflowTemplateContent, workflowFilePath: nextStylelintWorkflowFilePath, workflowName: pkg,