Skip to content

Commit

Permalink
Merge branch 'main' into frontmatter-linter
Browse files Browse the repository at this point in the history
  • Loading branch information
queengooborg authored Aug 10, 2023
2 parents 450a5f8 + 0afc60f commit f86015e
Show file tree
Hide file tree
Showing 5,003 changed files with 67,857 additions and 76,967 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
1 change: 1 addition & 0 deletions .autocorrectignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
files/
docs/
!files/zh-cn/
_wikihistory.json
6 changes: 4 additions & 2 deletions .autocorrectrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
textRules:
一二三,四五六.七八九: 0
一二三,四五六,七八九,一二三,四五六,七八九: 0
# sorted by `LC_ALL=C sort` command
9.9亿: 0
一二三,四五六,七八九,一二三,四五六,七八九: 0
一二三,四五六.七八九: 0
我,爱,巧克力,青蛙: 0
132 changes: 132 additions & 0 deletions .github/workflows/pr-check-lint_content.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: Lint and review content files

on:
pull_request_target:
branches:
- main
paths:
- "**/*.md"

permissions:
pull-requests: write

jobs:
lint-and-review-docs:
runs-on: ubuntu-latest

steps:
- name: Checkout BASE
uses: actions/checkout@v3

- name: Checkout HEAD
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
path: pr_head

- name: Get changed content from HEAD
run: |
git config --global user.email "[email protected]"
git config --global user.name "mdn-bot"
rm -r files docs *.md
mv pr_head/files pr_head/docs pr_head/*.md .
rm -r pr_head
# To avoid contents of PR getting into the diff that we are going to generate
# after running the linters, here we make a dummy commit.
# Note, this commit is not getting pushed.
git add .
git commit -m "Code from PR head"
- 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: |
# Use the GitHub API to get the list of changed files
# documentation: https://docs.github.com/rest/commits/commits#compare-two-commits
DIFF_DOCUMENTS=$(gh api repos/{owner}/{repo}/compare/${{ env.BASE_SHA }}...${{ env.HEAD_SHA }} \
--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 ".*\.md$" | xargs)
echo "DIFF_DOCUMENTS=${DIFF_DOCUMENTS}" >> $GITHUB_ENV
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: yarn

- name: Install all yarn packages
run: yarn --frozen-lockfile

- name: Lint and format markdown files
if: ${{ env.DIFF_DOCUMENTS }}
run: |
# Generate random delimiter
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
EOF="$(openssl rand -hex 8)"
files_to_lint="${{ env.DIFF_DOCUMENTS }}"
echo "Running markdownlint --fix"
MD_LINT_FAILED=false
MD_LINT_LOG=$(yarn markdownlint-cli2 --fix ${files_to_lint} 2>&1) || MD_LINT_FAILED=true
echo "MD_LINT_LOG<<${EOF}" >> $GITHUB_ENV
echo "${MD_LINT_LOG}" >> $GITHUB_ENV
echo "${EOF}" >> $GITHUB_ENV
echo "MD_LINT_FAILED=${MD_LINT_FAILED}" >> $GITHUB_ENV
echo "Running Prettier"
yarn prettier -w ${files_to_lint}
if [[ -n $(git diff) ]]; then
echo "FILES_MODIFIED=true" >> $GITHUB_ENV
fi
# info for troubleshooting
echo MD_LINT_FAILED=${MD_LINT_FAILED}
git diff
- name: Setup reviewdog
if: env.FILES_MODIFIED == 'true' || env.MD_LINT_FAILED == 'true'
uses: reviewdog/action-setup@v1
with:
reviewdog_version: latest

- name: Suggest changes using diff
if: env.FILES_MODIFIED == 'true'
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TMPFILE=$(mktemp)
git diff >"${TMPFILE}"
git stash -u && git stash drop
reviewdog \
-name="mdn-linter" \
-f=diff \
-f.diff.strip=1 \
-reporter=github-pr-review < "${TMPFILE}"
- name: Add reviews for markdownlint errors
if: env.MD_LINT_FAILED == 'true'
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "${{ env.MD_LINT_LOG }}" | \
reviewdog \
-efm="%f:%l:%c %m" \
-efm="%f:%l %m" \
-name="markdownlint" \
-diff="git diff" \
-reporter="github-pr-review"
- name: Fail if any issues pending
if: env.FILES_MODIFIED == 'true' || env.MD_LINT_FAILED == 'true'
run: |
echo -e "\nLogs from markdownlint:"
echo "${{ env.MD_LINT_LOG }}"
echo -e "\nPlease fix all the linting issues mentioned in above logs and in the review comments."
exit 1
54 changes: 0 additions & 54 deletions .github/workflows/pr-check_markdownlint.yml

This file was deleted.

45 changes: 0 additions & 45 deletions .github/workflows/reviewdog.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"*": "prettier --ignore-unknown --write",
"*.md": "markdownlint-cli2-fix"
"!*.md": "prettier --ignore-unknown --write",
"*.md": ["markdownlint-cli2 --fix", "prettier --write"]
}
21 changes: 7 additions & 14 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,30 @@ build/
/files/fr/web/css/place-self/index.md
/files/fr/web/javascript/reference/global_objects/array/includes/index.md
/files/fr/web/javascript/reference/global_objects/intl/displaynames/of/index.md
/files/ja/web/api/audiobuffer/audiobuffer/index.md
/files/ja/web/svg/content_type/index.md
/files/ko/web/css/css_flow_layout/block_and_inline_layout_in_normal_flow/index.md
/files/pt-br/learn/server-side/django/forms/index.md
/files/pt-br/web/svg/content_type/index.md
/files/ru/learn/server-side/django/forms/index.md
/files/ru/learn/server-side/django/introduction/index.md
/files/ru/learn/html/introduction_to_html/the_head_metadata_in_html/index.md
/files/ru/web/css/computed_value/index.md
/files/ru/web/css/justify-content/index.md
/files/ru/web/html/element/abbr/index.md
/files/ru/web/javascript/guide/expressions_and_operators/index.md
/files/zh-cn/learn/server-side/django/forms/index.md
/files/zh-cn/web/javascript/reference/operators/exponentiation/index.md
/files/zh-cn/web/javascript/reference/operators/exponentiation_assignment/index.md

# A full pass on all Markdown files is being performed.
# The following folders still need a full pass:

# es
/files/es/web/css/**/*.md
/files/es/web/javascript/reference/**/*.md

# ja
/files/ja/mdn/**/*.md
/files/ja/web/api/**/*.md
/files/ja/web/css/**/*.md
/files/ja/web/html/**/*.md
/files/ja/web/http/**/*.md
/files/ja/web/javascript/**/*.md
/files/ja/web/svg/**/*.md

# ko
/files/ko/web/css/**/*.md
Expand All @@ -58,15 +58,8 @@ build/
# pt-br
/files/pt-br/web/api/**/*.md
/files/pt-br/web/css/**/*.md
/files/pt-br/web/html/**/*.md
/files/pt-br/web/http/**/*.md
/files/pt-br/web/javascript/**/*.md
/files/pt-br/web/svg/**/*.md

# ru
/files/ru/web/api/**/*.md
/files/ru/web/css/**/*.md
/files/ru/web/html/**/*.md
/files/ru/web/http/**/*.md
/files/ru/web/javascript/**/*.md
/files/ru/web/svg/**/*.md
Loading

0 comments on commit f86015e

Please sign in to comment.