Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ci): recycle the weekly spelling check issue #35653

Merged
merged 6 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions .github/workflows/spelling-check-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,33 @@ jobs:
npm install
echo Running spelling check...
output=$(npx cspell --no-progress --gitignore --config .vscode/cspell.json "**/*.md" || exit 0)
output=$(node scripts/linkify-logs.js "${output}")
output=$(echo "$output" | sed 's/^/- /')
echo "$output"
echo "OUTPUT<<EOF" >> $GITHUB_ENV
echo "$output" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV

- name: Create an issue
- name: Report issues
OnkarRuikar marked this conversation as resolved.
Show resolved Hide resolved
if: env.OUTPUT != ''
uses: dacbd/create-issue-action@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: Weekly spelling check
body: |
Typos and unknown words:

```
${{ env.OUTPUT }}
```

> [!TIP]
> To exclude words from the spellchecker, you can add valid words (web technology terms or abbreviations) to the [terms-abbreviations.txt](https://github.com/mdn/content/blob/main/.vscode/terms-abbreviations.txt) dictionary for IDE autocompletion. To ignore strings that are not words (`AABBCC` in code, for instance), you can add them to [ignore-list.txt](https://github.com/mdn/content/blob/main/.vscode/ignore-list.txt).
run: |
comment_body=$(cat<<EOM
Typos and unknown words:

${OUTPUT}

> [!TIP]
> To exclude words from the spellchecker, you can add valid words (web technology terms or abbreviations) to the [terms-abbreviations.txt](https://github.com/mdn/content/blob/main/.vscode/terms-abbreviations.txt) dictionary for IDE autocompletion. To ignore strings that are not words (\`AABBCC\` in code, for instance), you can add them to [ignore-list.txt](https://github.com/mdn/content/blob/main/.vscode/ignore-list.txt).
EOM
)
comment_body+=$'\n\n'$(echo "_(comment last updated: $(date +'%Y-%m-%d %H:%M:%S'))_")
gh api \
--method PATCH \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/mdn/content/issues/35634 \
-f "state=open" \
-f "body=${comment_body}"
env:
OUTPUT: ${{ env.OUTPUT }}
GH_TOKEN: ${{ github.token }}
16 changes: 16 additions & 0 deletions scripts/linkify-logs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* The script converts file paths to GitHub source links in the provided text.
* Usage: node scripts/linkify-logs.js ${logs}
*/

const logs = process.argv[2];

console.log(
logs.replaceAll(/(files\/.*?\/index.md):?(\d+)?/g, (_, path, lineNo) => {
OnkarRuikar marked this conversation as resolved.
Show resolved Hide resolved
let link = `[${path}](https://github.com/mdn/content/blob/main/${path}?plain=1`;
if (lineNo) {
return link + `#L${lineNo}):${lineNo}`;
}
return link + `)`;
}),
);
Loading