From 2bcda1dd33625f339df01429eae7865539521c08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Mond=C3=A9jar?= Date: Sat, 9 Mar 2024 17:36:18 +0100 Subject: [PATCH] Only lint changed SVG icons on CI (#10602) --- .github/workflows/verify.yml | 21 ++++++++++++--------- .npmrc | 3 +++ package.json | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index b413d92b0..90235ea0f 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -30,14 +30,7 @@ jobs: node-version: 20 cache: npm cache-dependency-path: '**/package.json' - - name: Install dependencies - run: npm i - - name: Run linter - run: npm run lint - env: - # Authorise GitHub API requests for editorconfig-checker - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Detect changed documentation files + - name: Detect changed files uses: dorny/paths-filter@v3 id: changes with: @@ -46,8 +39,18 @@ jobs: docs: - '*.md' - '.github/**.md' + icons: + - 'icons/*.svg' + token: ${{ secrets.GITHUB_TOKEN }} + - name: Install dependencies + run: npm i + - name: Run linter + run: npm run lint --icons='${{ steps.changes.outputs.icons_files }}' + env: + # Authorise GitHub API requests for editorconfig-checker + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Check documentation links - if: steps.changes.outputs.docs == 'true' + if: steps.changes.outputs.docs == true run: | npx markdown-link-check --retry \ --config .github/markdown-link-check.json \ diff --git a/.npmrc b/.npmrc index 0ca8d2a0b..4e8c3098a 100644 --- a/.npmrc +++ b/.npmrc @@ -1,2 +1,5 @@ package-lock=false save-exact=true + +# Icons to lint with SVGLint (see `npm run svglint`) +icons=icons/*.svg diff --git a/package.json b/package.json index 26b809283..617d46e6d 100644 --- a/package.json +++ b/package.json @@ -116,7 +116,7 @@ "our-lint": "node scripts/lint/ourlint.js", "jslint": "prettier --cache --check .", "jsonlint": "node scripts/lint/jsonlint.js", - "svglint": "svglint icons/*.svg --ci", + "svglint": "svglint --ci $npm_config_icons", "wslint": "editorconfig-checker", "prepare": "is-ci || husky", "prepublishOnly": "npm run build",