1
0
mirror of https://github.com/simple-icons/simple-icons.git synced 2024-12-16 01:10:30 +02:00

Optimize markdownlint on CI (#12250)

This commit is contained in:
Álvaro Mondéjar Rubio 2024-12-02 15:12:50 +01:00 committed by GitHub
parent c46f935617
commit fd1797e18c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 14 deletions

View File

@ -35,6 +35,10 @@ jobs:
node-version: 22 node-version: 22
cache: npm cache: npm
cache-dependency-path: '**/package.json' cache-dependency-path: '**/package.json'
- name: Is normal pull request
# check if is not a release pull request
id: pr
run: echo "is_normal=$(echo ${{ github.base_ref != 'master' && github.event_name == 'pull_request' }})" >> $GITHUB_OUTPUT
- name: Detect changed files - name: Detect changed files
uses: dorny/paths-filter@v3 uses: dorny/paths-filter@v3
id: changes id: changes
@ -52,20 +56,14 @@ jobs:
- 'sdk.d.ts' - 'sdk.d.ts'
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
- name: Don't edit slugs.md in pull requests - name: Don't edit slugs.md in pull requests
if: | if: steps.pr.outputs.is_normal == 'true' && steps.changes.outputs.slugs == 'true'
github.base_ref != 'master' &&
github.event_name == 'pull_request' &&
steps.changes.outputs.slugs == 'true'
run: | run: |
echo -ne "Detected slugs.md file edition in PR.\n" 1>&2 echo -ne "Detected slugs.md file edition in PR.\n" 1>&2
echo -ne "Please revert it, we build the slugs.md" 1>&2 echo -ne "Please revert it, we build the slugs.md" 1>&2
echo -ne " file automatically at releases.\n" 1>&2 echo -ne " file automatically at releases.\n" 1>&2
exit 1 exit 1
- name: Don't edit sdk.d.ts in pull requests - name: Don't edit sdk.d.ts in pull requests
if: | if: steps.pr.outputs.is_normal == 'true' && steps.changes.outputs.sdkts == 'true'
github.base_ref != 'master' &&
github.event_name == 'pull_request' &&
steps.changes.outputs.sdkts == 'true'
run: | run: |
echo -ne "Detected sdk.d.ts file edition in PR.\n" 1>&2 echo -ne "Detected sdk.d.ts file edition in PR.\n" 1>&2
echo -ne "Please revert it, we build the sdk.d.ts" 1>&2 echo -ne "Please revert it, we build the sdk.d.ts" 1>&2
@ -73,10 +71,22 @@ jobs:
exit 1 exit 1
- name: Install dependencies - name: Install dependencies
run: npm i --ignore-scripts --no-audit --no-fund run: npm i --ignore-scripts --no-audit --no-fund
- name: Prepare icons
if: steps.pr.outputs.is_normal == 'true' && steps.changes.outputs.icons == 'true'
run: sed -i 's/icons\/\*\.svg/$npm_config_icons/' package.json
- name: Prepare docs (docs changed)
# only lint changed docs
if: steps.pr.outputs.is_normal == 'true' && steps.changes.outputs.docs == 'true'
run: sed -i "s/'\*\*\/\*\.md'/"'$npm_config_docs'"/" package.json
- name: Prepare docs (no docs changed)
# only lint README.md if no changes in docs
if: steps.pr.outputs.is_normal == 'true' && steps.changes.outputs.docs != 'true'
run: sed -i "s/'\*\*\/\*\.md'/README.md/" package.json
- name: Run linter - name: Run linter
run: | run: |
sed -i 's/icons\/\*\.svg/$npm_config_icons/' package.json npm run lint \
npm run lint --icons='${{ steps.changes.outputs.icons_files }}' --icons='${{ steps.changes.outputs.icons_files }}' \
--docs='${{ steps.changes.outputs.docs_files }}'
env: env:
# Authorise GitHub API requests for editorconfig-checker # Authorise GitHub API requests for editorconfig-checker
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

3
.npmrc
View File

@ -1,6 +1,3 @@
package-lock=false package-lock=false
save-exact=true save-exact=true
save-dev=true save-dev=true
# Icons to lint with SVGLint on CI (see `lint` step on verify.yml workflow)
icons=icons/*.svg

View File

@ -123,7 +123,7 @@
"jsonlint": "node scripts/lint/jsonlint.js", "jsonlint": "node scripts/lint/jsonlint.js",
"svglint": "svglint --ci --config svglint.config.mjs icons/*.svg", "svglint": "svglint --ci --config svglint.config.mjs icons/*.svg",
"wslint": "editorconfig-checker", "wslint": "editorconfig-checker",
"markdownlint": "markdownlint-cli2 \"**/*.md\" \"#node_modules\"", "markdownlint": "markdownlint-cli2 '**/*.md' '#node_modules'",
"prepare": "husky", "prepare": "husky",
"prepublishOnly": "npm run build", "prepublishOnly": "npm run build",
"postpublish": "npm run clean", "postpublish": "npm run clean",