Skip to content

Commit

Permalink
Optimize markdownlint on CI (#12250)
Browse files Browse the repository at this point in the history
  • Loading branch information
mondeja authored Dec 2, 2024
1 parent c46f935 commit fd1797e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
30 changes: 20 additions & 10 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 35,10 @@ jobs:
node-version: 22
cache: npm
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
uses: dorny/paths-filter@v3
id: changes
Expand All @@ -52,31 56,37 @@ jobs:
- 'sdk.d.ts'
token: ${{ secrets.GITHUB_TOKEN }}
- name: Don't edit slugs.md in pull requests
if: |
github.base_ref != 'master' &&
github.event_name == 'pull_request' &&
steps.changes.outputs.slugs == 'true'
if: steps.pr.outputs.is_normal == 'true' && steps.changes.outputs.slugs == 'true'
run: |
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 " file automatically at releases.\n" 1>&2
exit 1
- name: Don't edit sdk.d.ts in pull requests
if: |
github.base_ref != 'master' &&
github.event_name == 'pull_request' &&
steps.changes.outputs.sdkts == 'true'
if: steps.pr.outputs.is_normal == 'true' && steps.changes.outputs.sdkts == 'true'
run: |
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 " file automatically at releases.\n" 1>&2
exit 1
- name: Install dependencies
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
run: |
sed -i 's/icons\/\*\.svg/$npm_config_icons/' package.json
npm run lint --icons='${{ steps.changes.outputs.icons_files }}'
npm run lint \
--icons='${{ steps.changes.outputs.icons_files }}' \
--docs='${{ steps.changes.outputs.docs_files }}'
env:
# Authorise GitHub API requests for editorconfig-checker
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
3 changes: 0 additions & 3 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,6 1,3 @@
package-lock=false
save-exact=true
save-dev=true

# Icons to lint with SVGLint on CI (see `lint` step on verify.yml workflow)
icons=icons/*.svg
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 123,7 @@
"jsonlint": "node scripts/lint/jsonlint.js",
"svglint": "svglint --ci --config svglint.config.mjs icons/*.svg",
"wslint": "editorconfig-checker",
"markdownlint": "markdownlint-cli2 \"**/*.md\" \"#node_modules\"",
"markdownlint": "markdownlint-cli2 '**/*.md' '#node_modules'",
"prepare": "husky",
"prepublishOnly": "npm run build",
"postpublish": "npm run clean",
Expand Down

0 comments on commit fd1797e

Please sign in to comment.