Skip to content

Commit

Permalink
ci: 优化中文文本检查
Browse files Browse the repository at this point in the history
  • Loading branch information
jiazengp committed Jan 20, 2025
1 parent 19189a0 commit d280328
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 10 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/check-zh.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Check Chinese text

env:
NODE_OPTIONS: --max-old-space-size=6144

on:
push:
branches: [main]
paths:
- '**/zh/**/*.md'
pull_request:
branches: [main]
types: [opened]

workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node_version:
- 20

steps:
- name: Checkout
uses: actions/checkout@v3
with:
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
fetch-depth: 0
- name: Cache pnpm modules
uses: actions/cache@v2
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
run_install: true

- name: Set node version to ${{ matrix.node_version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node_version }}
cache: pnpm

- name: Linter zh markdown
run: pnpm run lint:zh
3 changes: 0 additions & 3 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,3 @@ jobs:
env:
NODE_OPTIONS: --max_old_space_size=4096
run: pnpm build-mpa

- name: Linter test
run: pnpm run lint
9 changes: 4 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@
"Aliyun",
"axline",
"bilibili",
"Gitee",
"GITEE",
"ISPROD",
"qrcode",
"qzone",
"unocss",
"vitepress",
"wechat",
"wechatpay",
"wxtl",
"Gitee",
"GITEE",
"bilibili",
"qzone",
"wechat"
"zhlint"
],
"vue.codeActions.enabled": false,
"files.trimTrailingWhitespace": true,
Expand Down
17 changes: 17 additions & 0 deletions .zhlintcaseignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
> {#
? {#
! {#
[^ ]:
]:
[!
# 1.
# 2.
# 3.
# 4.
# 5.
# 6.
# 7.
# 8.
# 9.
<span>
</span>
13 changes: 13 additions & 0 deletions .zhlintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"preset": "default",
"rules": {
"adjustedFullwidthPunctuation": "‘’",
"spaceOutsideHalfQuote": false
},
"caseIgnores": {
"IgnoredCase": {
"textStart": "[^",
"textEnd": ":"
}
}
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
"commit": "git-cz",
"dev": "vitepress",
"lint": "prettier --check . && pnpm lint:zh",
"lint:fix": "prettier --write .",
"lint:fix": "prettier --write . & pnpm lint:zh-fix",
"lint:md": "markdownlint **/*.md",
"lint:prettier": "prettier --check .",
"lint:zh": "zhlint 'src/zh/**/*.md'",
"lint:zh": "zhlint **/zh/**/*.md",
"lint:zh-fix": "zhlint **/zh/**/*.md --fix",
"lunaria:build": "lunaria build",
"lunaria:preview": "lunaria preview",
"prepare": "husky",
Expand Down

0 comments on commit d280328

Please sign in to comment.