Skip to content

Commit 8f09349

Browse files
authored
feat: 添加 markdown 语法及格式检查,添加 autoreview 工作流 (#265)
1 parent 244719b commit 8f09349

83 files changed

Lines changed: 934 additions & 628 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.autocorrectignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# 目录
2+
docs/political/index.md
3+
docs/math_phys/index.md
4+
docs/major/mandatory/index.md
5+
docs/major/elective/index.md
6+
docs/short_term/index.md
7+
docs/others/index.md
8+
9+
# 历年卷
10+
*.tex
11+
docs/major/introduction_to_data_visualization/数据可视化导论小测.md
12+
13+
# 其他
14+
*.py

.autocorrectrc

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# yaml-language-server: $schema=https://huacnlee.github.io/autocorrect/schema.json
2+
rules:
3+
# Default rules: https://github.com/huacnlee/autocorrect/raw/main/autocorrect/.autocorrectrc.default
4+
spellcheck: 2
5+
# Enable or disable in special context
6+
context:
7+
# Enable or disable to format codeblock in Markdown or AsciiDoc etc.
8+
codeblock: 1
9+
textRules:
10+
# Config some special rule for some texts
11+
# For example, if we wants to let "Hello你好" just warning, and "Hi你好" to ignore
12+
# "Hello你好": 2
13+
# "Hi你好": 0
14+
"形策I": 2
15+
"普物实验I": 2
16+
"线代II": 2
17+
"普物II": 2
18+
"数分II": 2
19+
"数分I": 2
20+
"普物I": 2
21+
"线代I": 2
22+
fileTypes:
23+
# Config the files associations, you config is higher priority than default.
24+
# "rb": ruby
25+
# "Rakefile": ruby
26+
# "*.js": javascript
27+
# ".mdx": markdown
28+
spellcheck:
29+
words:
30+
# Please do not add a general English word (eg. apple, python) here.
31+
# Users can add their special words to their .autocorrectrc file by their need.
32+
- ActiveMQ
33+
- AirPods
34+
- Aliyun
35+
- API
36+
- App Store
37+
- AppKit
38+
- AppStore = App Store
39+
- AWS
40+
- CacheStorage
41+
- CDN
42+
- CentOS
43+
- CloudFront
44+
- CORS
45+
- CPU
46+
- DNS
47+
- Elasticsearch
48+
- ESLint
49+
- Facebook
50+
- GeForce
51+
- GitHub
52+
- Google
53+
- GPU
54+
- H5
55+
- Hadoop
56+
- HBase
57+
- HDFS
58+
- HKEX
59+
- HTML
60+
- HTTP
61+
- HTTPS
62+
- I10n
63+
- I18n
64+
- iMovie
65+
- IndexedDB
66+
- Intel
67+
- iOS
68+
- iPad
69+
- iPadOS
70+
- iPhone
71+
- iTunes
72+
- JavaScript
73+
- jQuery
74+
- JSON
75+
- JWT
76+
- Linux
77+
- LocalStorage
78+
- macOS
79+
- Microsoft
80+
- MongoDB
81+
- Mozilla
82+
- MVC
83+
- MySQL
84+
- Nasdaq
85+
- Netflix
86+
- NodeJS = Node.js
87+
- NoSQL
88+
- NVDIA
89+
- NYSE
90+
- OAuth
91+
- Objective-C
92+
- OLAP
93+
- OSS
94+
- P2P
95+
- PaaS
96+
- PDF
97+
- PPT
98+
- RabbitMQ
99+
- Redis
100+
- RESTful
101+
- RSS
102+
- RubyGem
103+
- RubyGems
104+
- SaaS
105+
- Sass
106+
- SDK
107+
- Shopify
108+
- SQL
109+
- SQLite
110+
- SQLServer
111+
- SSL
112+
- Tesla
113+
- TikTok
114+
- tvOS
115+
- TypeScript
116+
- Ubuntu
117+
- UML
118+
- URI
119+
- URL
120+
- VIM
121+
- watchOS
122+
- WebAssembly
123+
- WebKit
124+
- Webpack
125+
- Wi-Fi
126+
- Windows
127+
- WWDC
128+
- Xcode
129+
- XML
130+
- YAML
131+
- YML
132+
- YouTube

.github/workflows/autoreview.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Format Auto Review
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, reopened, synchronize]
6+
paths:
7+
- '**/*.md'
8+
9+
permissions:
10+
checks: write
11+
contents: read
12+
pull-requests: write
13+
14+
concurrency: ci-${{ github.workflow }}-${{ github.ref }}
15+
16+
jobs:
17+
auto-review:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
repository: ${{ github.event.pull_request.head.repo.full_name }}
25+
ref: ${{ github.event.pull_request.head.ref }}
26+
- name: Setup Python
27+
uses: actions/setup-python@v4
28+
with:
29+
python-version: '3.x'
30+
- name: Setup reviewdog
31+
uses: reviewdog/action-setup@v1.3.2
32+
with:
33+
reviewdog_version: latest
34+
- name: Get changed files
35+
id: changed-files
36+
uses: tj-actions/changed-files@v46
37+
with:
38+
files: '**/*.md'
39+
40+
- name: Running autocorrect
41+
if: steps.changed-files.outputs.any_changed == 'true'
42+
env:
43+
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
run: |
45+
curl -sSL https://git.io/JcGER | sh
46+
autocorrect --lint --format rdjson ${{ steps.changed-files.outputs.all_changed_files }} | \
47+
reviewdog -f=rdjson -level=warning -reporter=github-pr-review -fail-level=error
48+
- name: Running markdownlint
49+
uses: reviewdog/action-markdownlint@v0.26.2
50+
if: ${{ !cancelled() && steps.changed-files.outputs.any_changed == 'true' }}
51+
with:
52+
github_token: ${{ secrets.GITHUB_TOKEN }}
53+
reporter: github-pr-review
54+
markdownlint_flags: ${{ steps.changed-files.outputs.all_changed_files }}
55+
fail_level: error
56+
- name: Running custom punctuation checker
57+
if: ${{ !cancelled() && steps.changed-files.outputs.any_changed == 'true' }}
58+
env:
59+
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
run: |
61+
python tools/punctuation_checker.py \
62+
"${{ steps.changed-files.outputs.all_changed_files }}" | \
63+
reviewdog -efm="%f:%l:%t %m" -name="punctuation-check" -reporter=github-pr-review -fail-level=error -level=warning
64+
65+
- name: Post comment if failure
66+
uses: thollander/actions-comment-pull-request@v3
67+
if: failure()
68+
with:
69+
comment-tag: autoreview-comment
70+
message: |
71+
源码格式/语法检查未通过,请根据 GitHub Action 给出的 Code Review 审查建议进行修改(未给出修改建议的需根据提示手动修改),修改完成后请点击 "Resolve conversation"。
72+
73+
对于有争议的修改建议,可暂时不进行修改并在 PR 中进行讨论。
74+
75+
> 注:可通过 "Files changed" 页面中的 "Add suggestion to batch" 功能来批量采纳修改建议。
76+
- name: Post comment if success
77+
uses: thollander/actions-comment-pull-request@v3
78+
if: success()
79+
with:
80+
comment-tag: autoreview-comment
81+
message: |
82+
源码格式/语法检查已通过。

.github/workflows/checker.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

.github/workflows/deploy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ concurrency:
1717

1818
jobs:
1919
build:
20+
if: github.repository == 'ZJU-Turing/TuringCourses'
2021
runs-on: ubuntu-latest
2122
steps:
2223
- name: Checkout

.markdownlint.jsonc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"MD004": { // Unordered list style
3+
"style": "dash"
4+
},
5+
"MD007": { // Unordered list indentation
6+
"indent": 4
7+
},
8+
"MD013": false, // Line length
9+
"MD014": false, // Dollar signs used before commands without showing output
10+
"MD024": { // Multiple headings with the same content
11+
"siblings_only": true
12+
},
13+
"MD033": false, // Inline HTML
14+
"MD036": false, // Emphasis used instead of a heading
15+
"MD045": false // Images should have alternate text (alt text)
16+
}

.markdownlintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docs/major/introduction_to_data_visualization/数据可视化导论小测.md

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
浙江大学图灵班各门课程的学习指南以及学习资源。
2424

25-
- 主站:https://ZJU-Turing.github.io/TuringCourses/
26-
- 存档站(CS/AI/IS 三专业版):https://zju-turing.github.io/TuringCoursesGrave/
25+
- 主站:<https://ZJU-Turing.github.io/TuringCourses/>
26+
- 存档站(CS/AI/IS 三专业版):<https://zju-turing.github.io/TuringCoursesGrave/>
2727

28-
关于贡献,详见 https://ZJU-Turing.github.io/TuringCourses/contributing/
28+
关于贡献,详见 <https://ZJU-Turing.github.io/TuringCourses/contributing/>

docs/changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ nocounter: true
2828

2929
{{ changelog }}
3030

31-
</div>
31+
</div>

0 commit comments

Comments
 (0)