Skip to content

Commit

Permalink
Merge branch 'master' into translation/web-css-syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
undead404 committed Nov 22, 2023
2 parents cd9d007 + 01bdb2a commit 828cf47
Show file tree
Hide file tree
Showing 402 changed files with 22,203 additions and 4,136 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/size-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: size-label
on: pull_request
jobs:
size-label:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: size-label
uses: "webdoky/size-label-action@main"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
154 changes: 154 additions & 0 deletions .github/workflows/spellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
name: spellcheck
on: [pull_request]
jobs:
prepare-translation:
outputs:
translation: ${{ steps.translation-check.outputs.translation }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: changed-files
run: git diff --diff-filter=d --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} > ./changed_files.txt
- name: Check translation
# Check there is only one translation change
# If there are more than one, the workflow will fail
id: translation-changes
run: |
changed_files=$(cat ./changed_files.txt)
if [ -z "$changed_files" ]; then
echo "No files changed"
else
translation_files=$(echo "$changed_files" | grep -E ".*\.md" || ./pass.sh)
echo "$translation_files"
echo "$translation_files" > ./translation_files.txt
fi
- id: translation-check
run: |
translation_files=$(cat ./translation_files.txt)
if [ -z "$translation_files" ]; then
echo "No translation files changed"
else
if [ $(echo "$translation_files" | wc -l) -gt 1 ]; then
echo "More than one translation file changed"
exit 1
else
echo "translation=$translation_files" >> $GITHUB_OUTPUT
fi
fi
languagetool:
if: ${{ needs.prepare-translation.outputs.translation != '' }}
name: runner / languagetool
needs: [prepare-translation]
outputs:
has_matches: ${{ steps.check-spelling.outputs.has_matches }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Remove code blocks
run: |
file=${{ needs.prepare-translation.outputs.translation }}
sed -i '/```/,/```/d' $file
# Strip all macros
- id: strip-macros
run: |
file=${{ needs.prepare-translation.outputs.translation }}
# Remove all macros with no arguments
sed -i 's/{{[a-zA-Z_-]*}}//' $file
# Replace macros with one argument
sed -i 's/{{[[:alnum:]_-]*(\("[[:alnum:]_-]*"\))}}/\1/g' $file
# Replace macros with two arguments
sed -i 's/{{[[:alnum:]_-]*(\("[[:alnum:]_-]*"\), \("[[:alnum:]_-]*"\))}}/\2/g' $file
# Replace macros with more than two arguments
sed -i 's/{{[[:alnum:]_-]*(\("[[:alnum:]_-]*"\), \("[[:alnum:]_-]*"\), \("[[:alnum:]_-]*"\))}}/\2/g' $file
# Reduce markdown to plain text
- run: sudo apt install pandoc -y
- id: md2txt
name: Convert markdown to plain text
run: |
file=${{ needs.prepare-translation.outputs.translation }}
newFileName=$(echo $file | sed 's/\.md/\.txt/')
pandoc -f markdown -t plain -o $newFileName $file
echo "translation=$newFileName" >> $GITHUB_OUTPUT
echo $newFileName
# Error if translation file is not found
- if: steps.md2txt.outputs.translation == ''
name: Check translation is found
run: echo "No translation file found" && exit 1
- uses: actions/setup-java@v2
with:
distribution: "temurin"
java-version: "8"
- name: Download LanguageTool
run: wget -q https://languagetool.org/download/LanguageTool-6.3.zip
- name: Unzip LanguageTool
run: unzip -qq LanguageTool-6.3.zip
- name: Add spelling additions
run: |
cat uk_spelling_additions.txt >> ./LanguageTool-6.3/org/languagetool/resource/uk/hunspell/spelling.txt
cat uk_ignore_additions.txt >> ./LanguageTool-6.3/org/languagetool/resource/uk/hunspell/ignore.txt
- id: disabled-rules
name: Determine disabled rules
run: echo "disabled_rules=$(cat disabled_rules.txt | tr '\n' ',')" >> $GITHUB_OUTPUT
- id: check-spelling
name: Check spelling
run: |
cd LanguageTool-6.3
java -jar languagetool-commandline.jar -d ${{steps.disabled-rules.outputs.disabled_rules}} -l uk --json ../${{ steps.md2txt.outputs.translation }} > ../result.json
matches=$(cat ../result.json | jq '.matches')
# Check if matches equal []
echo "has_matches=$(if [ "$matches" == "[]" ]; then echo "false"; else echo "true"; fi)" >> $GITHUB_OUTPUT
- name: Upload result.json
uses: actions/upload-artifact@v3
with:
name: result
path: result.json
- name: Upload text file
uses: actions/upload-artifact@v3
with:
name: text
path: ${{ steps.md2txt.outputs.translation }}
report-spelling:
if: ${{ needs.languagetool.outputs.has_matches != 'false' }}
name: Report spelling
needs: [prepare-translation, languagetool]
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v3
with:
name: result
path: .
- uses: actions/setup-node@v4
with:
node-version: "16"
- uses: actions/download-artifact@v3
with:
name: text
path: .
- name: Create mapping
run: node scripts/create-file-mapping.js ./index.txt ${{ needs.prepare-translation.outputs.translation }} > ./mapping.json && cat ./mapping.json
- id: create-message
name: Create message
run: node scripts/create-message.js ${{ needs.prepare-translation.outputs.translation }} > message.txt && cat ./message.txt
# - uses: reviewdog/action-setup@v1
# - name: Send results
# run: |
# export REVIEWDOG_GITHUB_API_TOKEN=${{ secrets.GITHUB_TOKEN }}
# cat ./message.txt | reviewdog -efm="%A%f:%l:%c:%e:%k: %m%Z" -fail-on-error -reporter=github-pr-review -filter-mode=nofilter -name="LanguageTool" -level=info
- name: Send results
uses: mshick/add-pr-comment@v2
with:
message-id: ${{ needs.prepare-translation.outputs.translation }}
message-path: ./message.txt
refresh-message-position: true
- name: Exit with error
run: echo "Spelling errors found" && cat result.json && exit 1
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules
.DS_Store
.DS_Store
/output.*
/input.*
9 changes: 9 additions & 0 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"!*.md": "prettier --ignore-unknown --write",
"*.md": [
"markdownlint-cli2 --fix",
"node scripts/front-matter_linter.js --fix true",
"prettier --write"
],
"tests/**/*.*": "yarn test:front-matter-linter"
}
56 changes: 31 additions & 25 deletions .markdownlint-cli2.jsonc
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
{
"config": {
"default": true,
// MD001 - Heading levels should only increment by one level at a time.
// -> Disabled, as some callouts include headings.
"MD001": false,
"MD004": {
// Disabled, as some callouts include headings.
"header-increment": false,
"ul-style": {
"style": "dash"
},
"MD007": {
"ul-indent": {
"indent": 2
},
"MD010": {
"no-hard-tabs": {
"spaces_per_tab": 2
},
"MD013": false,
"MD024": {
"line-length": false,
"no-duplicate-header": {
"allow_different_nesting": true
},
"MD025": {
"single-title": {
"front_matter_title": "^\\s*title\\s*[:=]"
},
"MD026": {
"no-trailing-punctuation": {
"punctuation": ".,;:"
},
// Consecutive Notes/Callouts currently don't conform with this rule
"MD028": false,
"no-blanks-blockquote": false,
// Force ordered numbering to catch accidental list ending from indenting
"MD029": {
"ol-prefix": {
"style": "ordered"
},
"MD033": {
"no-inline-html": {
"allowed_elements": [
"a",
"abbr",
Expand Down Expand Up @@ -100,24 +99,25 @@
"var"
]
},
"MD034": false,
// Pending https://github.com/mdn/content/pull/20115
"MD037": false,
"MD040": false,
"no-bare-urls": false,
// Produces too many false positives
"no-space-in-emphasis": false,
"fenced-code-language": true,
// See https://github.com/mdn/content/pull/20026, as macros currently break this
"MD042": false,
"MD046": {
"no-empty-links": false,
"code-block-style": {
"style": "fenced"
},
"MD049": {
"emphasis-style": {
"style": "underscore"
},
"MD050": {
"strong-style": {
"style": "asterisk"
},
// MD051 - Link fragments should be valid.
// -> Disabled, as yari generates link fragments by replacing spaces with underscores, not dashes.
"MD051": false,
// Disabled, as yari generates link fragments by replacing spaces with underscores, not dashes.
"link-fragments": false,

// https://github.com/OnkarRuikar/markdownlint-rule-search-replace
"search-replace": {
"rules": [
{
Expand Down Expand Up @@ -244,10 +244,16 @@
"search": "(/en-US/blog",
"replace": "(https://developer.mozilla.org/en-US/blog",
"searchScope": "text"
},
{
"name": "un-closed-md-link",
"message": "Missng closing bracket ')'",
"searchPattern": "/(\\[[^\\]]*?\\]\\(([^\\)\\n]|\\([^\\)\\n]\\)|\\s[\"'])+?)(\\n|\\s|[,:][\\s\\n])/gm",
"searchScope": "text"
}
]
}
},
"customRules": ["markdownlint-rule-search-replace"],
"ignores": ["node_modules", ".github", "tests"]
"ignores": ["node_modules", ".git", ".github", "tests"]
}
Loading

0 comments on commit 828cf47

Please sign in to comment.