Skip to content

Commit

Permalink
Merge branch 'master' into translation/web-css-pseudo-classes
Browse files Browse the repository at this point in the history
  • Loading branch information
undead404 committed Nov 23, 2023
2 parents 9de9f26 + 9c8a25b commit 36f4b28
Show file tree
Hide file tree
Showing 191 changed files with 10,840 additions and 1,164 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 }}"
149 changes: 149 additions & 0 deletions .github/workflows/spellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
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 }}
tmpHtmlFile=$(echo $file | sed 's/\.md/\.html/')
pandoc -f markdown -t html -o $tmpHtmlFile $file
newFileName=$(echo $file | sed 's/\.md/\.txt/')
pandoc -f html -t plain -o $newFileName $tmpHtmlFile
echo "translation=$newFileName" >> $GITHUB_OUTPUT
echo $newFileName
- if: steps.md2txt.outputs.translation == ''
name: Check translation is found
run: echo "No translation file found" && exit 1
- uses: actions/setup-java@v3
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
cat ../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
- env:
COMMIT_ID: ${{ github.event.pull_request.head.sha }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
name: Send results
run: node scripts/send-comments.js ${{ needs.prepare-translation.outputs.translation }}
timeout-minutes: 5
- name: Exit with error
run: echo "Spelling errors found" && cat result.json && exit 1
Loading

0 comments on commit 36f4b28

Please sign in to comment.