From 71a5ae7313f36254a6829f1c98b5b717716ddd56 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Sat, 24 Sep 2022 22:08:54 +0800 Subject: [PATCH 01/12] Add AutoCorrect as CI lint for check updated files in PR. --- .autocorrectignore | 1 + .github/workflows/autocorrect-lint.yml | 47 ++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 .autocorrectignore create mode 100644 .github/workflows/autocorrect-lint.yml diff --git a/.autocorrectignore b/.autocorrectignore new file mode 100644 index 00000000000000..86fe41bfdba60c --- /dev/null +++ b/.autocorrectignore @@ -0,0 +1 @@ +files/zh-cn/conflicting \ No newline at end of file diff --git a/.github/workflows/autocorrect-lint.yml b/.github/workflows/autocorrect-lint.yml new file mode 100644 index 00000000000000..c8c4629b7048fe --- /dev/null +++ b/.github/workflows/autocorrect-lint.yml @@ -0,0 +1,47 @@ +name: AutoCorrect Lint + +on: + pull_request: + branches: + - main + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: "30" + + - name: Config git core.quotePath + run: | + # If you don't do this, the get-diff-action won't be able to + # notice files that contain non-ascii characters. + # I.e. + # + # ▶ git status + # Changes not staged for commit: + # ... + # modified: "files/en-us/glossary/b\303\251zier_curve/index.html" + # + # But after you set `core.quotePath` you get: + # + # ▶ git status + # Changes not staged for commit: + # ... + # modified: "files/en-us/glossary/bézier_curve/index.html" + # + # Now, this gets used by the `git diff ...` inside get-diff-action. + git config --global core.quotePath false + + - name: Get changed files + run: | + GIT_DIFF_FILTERED=$(git diff --diff-filter=AM --name-only ${{ github.event.pull_request.base.sha }} -- files/zh-cn/ | tr "\n" " ") + echo "GIT_DIFF_FILTERED=$GIT_DIFF_FILTERED" >> $GITHUB_ENV + + - name: AutoCorrect changed content + if: ${{ env.GIT_DIFF_FILTERED }} + uses: huacnlee/autocorrect-action@v1.10.7 + with: + args: ${{ env.GIT_DIFF_FILTERED }} --lint From 85807b6525877e85c4de065f2a9d077bed206d98 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Thu, 29 Sep 2022 11:10:57 +0800 Subject: [PATCH 02/12] AutoCorrect only enable for files/zh-cn and docs/zh-cn by use .autocorrectignore --- .autocorrectignore | 6 +++++- .github/workflows/autocorrect-lint.yml | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.autocorrectignore b/.autocorrectignore index 86fe41bfdba60c..36510c7de4a5a7 100644 --- a/.autocorrectignore +++ b/.autocorrectignore @@ -1 +1,5 @@ -files/zh-cn/conflicting \ No newline at end of file +files/ +docs/ +!docs/zh-cn/ +!files/zh-cn/ +files/zh-cn/web/javascript/reference/global_objects/bigint/tolocalestring/index.md diff --git a/.github/workflows/autocorrect-lint.yml b/.github/workflows/autocorrect-lint.yml index c8c4629b7048fe..ec7de90dd7c7a4 100644 --- a/.github/workflows/autocorrect-lint.yml +++ b/.github/workflows/autocorrect-lint.yml @@ -42,6 +42,6 @@ jobs: - name: AutoCorrect changed content if: ${{ env.GIT_DIFF_FILTERED }} - uses: huacnlee/autocorrect-action@v1.10.7 + uses: huacnlee/autocorrect-action@v1.11.0 with: args: ${{ env.GIT_DIFF_FILTERED }} --lint From 1211a12a8b25a82ac3621851040a7a1b3d8e2128 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Tue, 25 Oct 2022 18:12:41 +0800 Subject: [PATCH 03/12] Add textRules for let AutoCorrect ignore some special cases. --- .autocorrectignore | 2 +- .autocorrectrc | 4 ++++ .github/workflows/autocorrect-lint.yml | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 .autocorrectrc diff --git a/.autocorrectignore b/.autocorrectignore index 36510c7de4a5a7..dd3edbc419bfa4 100644 --- a/.autocorrectignore +++ b/.autocorrectignore @@ -2,4 +2,4 @@ files/ docs/ !docs/zh-cn/ !files/zh-cn/ -files/zh-cn/web/javascript/reference/global_objects/bigint/tolocalestring/index.md +docs/zh-cn/translation-guide.md \ No newline at end of file diff --git a/.autocorrectrc b/.autocorrectrc new file mode 100644 index 00000000000000..8b8f715da76117 --- /dev/null +++ b/.autocorrectrc @@ -0,0 +1,4 @@ +textRules: + 一二三,四五六.七八九: 0 + 一二三,四五六,七八九,一二三,四五六,七八九: 0 + 9.9亿: 0 diff --git a/.github/workflows/autocorrect-lint.yml b/.github/workflows/autocorrect-lint.yml index ec7de90dd7c7a4..368e07eb629911 100644 --- a/.github/workflows/autocorrect-lint.yml +++ b/.github/workflows/autocorrect-lint.yml @@ -42,6 +42,6 @@ jobs: - name: AutoCorrect changed content if: ${{ env.GIT_DIFF_FILTERED }} - uses: huacnlee/autocorrect-action@v1.11.0 + uses: huacnlee/autocorrect-action@v2.3.2 with: args: ${{ env.GIT_DIFF_FILTERED }} --lint From 857c3914d5d580dfd266ea590c02d9ad1487365c Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Sun, 11 Dec 2022 01:10:59 +0800 Subject: [PATCH 04/12] Update get changed files script for autocorrect-lint GitHub Action. --- .autocorrectignore | 4 +-- .github/workflows/autocorrect-lint.yml | 47 ++++++++++---------------- 2 files changed, 19 insertions(+), 32 deletions(-) diff --git a/.autocorrectignore b/.autocorrectignore index dd3edbc419bfa4..ffb28a9f2729a0 100644 --- a/.autocorrectignore +++ b/.autocorrectignore @@ -1,5 +1,3 @@ files/ docs/ -!docs/zh-cn/ -!files/zh-cn/ -docs/zh-cn/translation-guide.md \ No newline at end of file +!files/zh-cn/ \ No newline at end of file diff --git a/.github/workflows/autocorrect-lint.yml b/.github/workflows/autocorrect-lint.yml index 368e07eb629911..c603631cc32632 100644 --- a/.github/workflows/autocorrect-lint.yml +++ b/.github/workflows/autocorrect-lint.yml @@ -4,44 +4,33 @@ on: pull_request: branches: - main + paths: + - "files/zh-cn/**" jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - with: - fetch-depth: "30" - - - name: Config git core.quotePath - run: | - # If you don't do this, the get-diff-action won't be able to - # notice files that contain non-ascii characters. - # I.e. - # - # ▶ git status - # Changes not staged for commit: - # ... - # modified: "files/en-us/glossary/b\303\251zier_curve/index.html" - # - # But after you set `core.quotePath` you get: - # - # ▶ git status - # Changes not staged for commit: - # ... - # modified: "files/en-us/glossary/bézier_curve/index.html" - # - # Now, this gets used by the `git diff ...` inside get-diff-action. - git config --global core.quotePath false + - uses: actions/checkout@v3 - name: Get changed files + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BASE_SHA: ${{ github.event.pull_request.base.sha }} + HEAD_SHA: ${{ github.event.pull_request.head.sha }} run: | - GIT_DIFF_FILTERED=$(git diff --diff-filter=AM --name-only ${{ github.event.pull_request.base.sha }} -- files/zh-cn/ | tr "\n" " ") - echo "GIT_DIFF_FILTERED=$GIT_DIFF_FILTERED" >> $GITHUB_ENV + # Use the GitHub API to get the list of changed files + # documenation: https://docs.github.com/rest/commits/commits#compare-two-commits + DIFF_DOCUMENTS=$(gh api repos/{owner}/{repo}/compare/${{ env.BASE_SHA }}...${{ env.HEAD_SHA }} \ + --paginate \ + --jq '.files | .[] | select(.status|IN("added", "modified", "renamed", "copied", "changed")) | .filename') + # filter out files that are not markdown + DIFF_DOCUMENTS=$(echo "${DIFF_DOCUMENTS}" | egrep -i "^files/zh-cn/" | xargs) + echo "DIFF_DOCUMENTS=${DIFF_DOCUMENTS}" >> $GITHUB_ENV - name: AutoCorrect changed content - if: ${{ env.GIT_DIFF_FILTERED }} - uses: huacnlee/autocorrect-action@v2.3.2 + if: ${{ env.DIFF_DOCUMENTS }} + uses: huacnlee/autocorrect-action@v2.5.4 with: - args: ${{ env.GIT_DIFF_FILTERED }} --lint + args: ${{ env.DIFF_DOCUMENTS }} --lint From 014a2bc0148b8750b1ac479a6a7ded50bff11b6a Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Tue, 13 Dec 2022 14:47:34 +0800 Subject: [PATCH 05/12] Update .github/workflows/autocorrect-lint.yml Co-authored-by: A1lo --- .github/workflows/autocorrect-lint.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/autocorrect-lint.yml b/.github/workflows/autocorrect-lint.yml index c603631cc32632..7553ef7a7763ce 100644 --- a/.github/workflows/autocorrect-lint.yml +++ b/.github/workflows/autocorrect-lint.yml @@ -23,7 +23,6 @@ jobs: # Use the GitHub API to get the list of changed files # documenation: https://docs.github.com/rest/commits/commits#compare-two-commits DIFF_DOCUMENTS=$(gh api repos/{owner}/{repo}/compare/${{ env.BASE_SHA }}...${{ env.HEAD_SHA }} \ - --paginate \ --jq '.files | .[] | select(.status|IN("added", "modified", "renamed", "copied", "changed")) | .filename') # filter out files that are not markdown DIFF_DOCUMENTS=$(echo "${DIFF_DOCUMENTS}" | egrep -i "^files/zh-cn/" | xargs) From 898c4d3fd7c0f5871e12fba8d3dc40ca4568c825 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Tue, 13 Dec 2022 14:51:45 +0800 Subject: [PATCH 06/12] Update .github/workflows/autocorrect-lint.yml Co-authored-by: A1lo --- .github/workflows/autocorrect-lint.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/autocorrect-lint.yml b/.github/workflows/autocorrect-lint.yml index 7553ef7a7763ce..7415ba4e25fd17 100644 --- a/.github/workflows/autocorrect-lint.yml +++ b/.github/workflows/autocorrect-lint.yml @@ -6,6 +6,7 @@ on: - main paths: - "files/zh-cn/**" + - ".github/workflows/autocorrect-lint.yml" jobs: lint: From f7f76ffcd578a3529168c85c60f49fe327998990 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Tue, 17 Jan 2023 22:18:00 +0800 Subject: [PATCH 07/12] Update autocorrect-lint.yml --- .github/workflows/autocorrect-lint.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/autocorrect-lint.yml b/.github/workflows/autocorrect-lint.yml index 7415ba4e25fd17..c3ff65fafd3e81 100644 --- a/.github/workflows/autocorrect-lint.yml +++ b/.github/workflows/autocorrect-lint.yml @@ -31,6 +31,6 @@ jobs: - name: AutoCorrect changed content if: ${{ env.DIFF_DOCUMENTS }} - uses: huacnlee/autocorrect-action@v2.5.4 + uses: huacnlee/autocorrect-action@v2.6.0 with: - args: ${{ env.DIFF_DOCUMENTS }} --lint + args: ${{ env.DIFF_DOCUMENTS }} --lint --no-diff-bg-color From 5d88432839d280d1bc408477b840490241da8934 Mon Sep 17 00:00:00 2001 From: Brian Thomas Smith Date: Thu, 20 Jul 2023 09:50:30 +0200 Subject: [PATCH 08/12] Update .autocorrectignore Adding newline suggestion Co-authored-by: Claas Augner <495429+caugner@users.noreply.github.com> --- .autocorrectignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.autocorrectignore b/.autocorrectignore index ffb28a9f2729a0..81250d7fa59456 100644 --- a/.autocorrectignore +++ b/.autocorrectignore @@ -1,3 +1,3 @@ files/ docs/ -!files/zh-cn/ \ No newline at end of file +!files/zh-cn/ From cf049b22e29dd8fe55cd0b8ff3a041d1bf59f45e Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Fri, 21 Jul 2023 10:00:39 +0800 Subject: [PATCH 09/12] Update .autocorrectignore --- .autocorrectignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.autocorrectignore b/.autocorrectignore index 81250d7fa59456..cabe9364ee1033 100644 --- a/.autocorrectignore +++ b/.autocorrectignore @@ -1,3 +1,7 @@ +# AutoCorrect Link ignore rules. +# https://github.com/huacnlee/autocorrect +# +# Like `.gitignore`, this file to tell AutoCorrect which files need to check, some need to ignore. files/ docs/ !files/zh-cn/ From 245fa2cc231cb91b4b685755904bcf4bc02dfd50 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Fri, 21 Jul 2023 10:07:01 +0800 Subject: [PATCH 10/12] Update autocorrect-lint.yml --- .github/workflows/autocorrect-lint.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/autocorrect-lint.yml b/.github/workflows/autocorrect-lint.yml index c3ff65fafd3e81..47b48b5b05e668 100644 --- a/.github/workflows/autocorrect-lint.yml +++ b/.github/workflows/autocorrect-lint.yml @@ -1,5 +1,16 @@ +# This workflow to use AutoCorrect tool for checking the copywriting, correct spaces and punctuations for CJK contents. +# +# For example: +# +# - incorrect: "欢迎阅读MDN文档." +# - correct: "欢迎阅读 MDN 文档。" +# +# - incorrect: "Welcome,this is MDN Web Docs。" +# - correct: "Welcome, to read MDN Web Docs." +# +# More details: +# https://github.com/huacnlee/autocorrect name: AutoCorrect Lint - on: pull_request: branches: From 143a9df38cfcd64d2acd64627d5313c2b9f13f73 Mon Sep 17 00:00:00 2001 From: A1lo Date: Fri, 21 Jul 2023 10:15:14 +0800 Subject: [PATCH 11/12] remove tailing space --- .github/workflows/autocorrect-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/autocorrect-lint.yml b/.github/workflows/autocorrect-lint.yml index 47b48b5b05e668..e20981451debf3 100644 --- a/.github/workflows/autocorrect-lint.yml +++ b/.github/workflows/autocorrect-lint.yml @@ -2,7 +2,7 @@ # # For example: # -# - incorrect: "欢迎阅读MDN文档." +# - incorrect: "欢迎阅读MDN文档." # - correct: "欢迎阅读 MDN 文档。" # # - incorrect: "Welcome,this is MDN Web Docs。" From b6297aa23c9da4be0b9bd8c6856ea2f0c1f839dd Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Mon, 24 Jul 2023 09:38:48 +0800 Subject: [PATCH 12/12] Update autocorrect-lint.yml --- .github/workflows/autocorrect-lint.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/autocorrect-lint.yml b/.github/workflows/autocorrect-lint.yml index e20981451debf3..bcee715e650d2f 100644 --- a/.github/workflows/autocorrect-lint.yml +++ b/.github/workflows/autocorrect-lint.yml @@ -15,9 +15,6 @@ on: pull_request: branches: - main - paths: - - "files/zh-cn/**" - - ".github/workflows/autocorrect-lint.yml" jobs: lint: