-
Notifications
You must be signed in to change notification settings - Fork 22.5k
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
Feature: provide automated PR reviews for linting related changes #28240
Changes from all commits
ecf3c5d
f1a2ba6
51328d9
602f68f
ded39e2
b14c09f
4bf39b7
ec457b4
aa8689c
fdd3794
ef19e6b
74650b6
d67c910
f13e0de
2c2a4ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
name: Add lint reviews to PRs | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- .nvmrc | ||
- "**/*.md" | ||
|
||
permissions: write-all | ||
|
||
jobs: | ||
lint-docs: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- 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: | | ||
# 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 "^files/.*\.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 | ||
env: | ||
# https://github.com/microsoft/vscode-ripgrep#github-api-limit-note | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Lint and format markdown files | ||
run: | | ||
# Generate random delimiter | ||
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings | ||
EOF="$(openssl rand -hex 8)" | ||
|
||
echo "Running markdownlint --fix" | ||
files_to_lint="${{ env.DIFF_DOCUMENTS }}" | ||
MD_LINT_STATUS=0 | ||
MD_LINT_LOG=$(yarn markdownlint-cli2 --fix ${files_to_lint} 2>&1) || MD_LINT_STATUS=1 | ||
echo "MD_LINT_LOG<<${EOF}" >> $GITHUB_ENV | ||
echo "${MD_LINT_LOG}" >> $GITHUB_ENV | ||
echo "${EOF}" >> $GITHUB_ENV | ||
echo "MD_LINT_STATUS=${MD_LINT_STATUS}" >> $GITHUB_ENV | ||
|
||
echo "Linting front-matter" | ||
FM_LINT_STATUS=0 | ||
FM_LINT_LOG=$(node scripts/front-matter_linter.js --fix true ${files_to_lint} 2>&1) || FM_LINT_STATUS=1 | ||
echo "FM_LINT_LOG<<${EOF}" >> $GITHUB_ENV | ||
echo "${FM_LINT_LOG}" >> $GITHUB_ENV | ||
echo "${EOF}" >> $GITHUB_ENV | ||
echo "FM_LINT_STATUS=${FM_LINT_STATUS}" >> $GITHUB_ENV | ||
|
||
echo "Running Prettier" | ||
yarn prettier -w ${files_to_lint} | ||
|
||
if [[ -n $(git diff) || "${MD_LINT_STATUS}" == "1" || "${FM_LINT_STATUS}" == "1" ]]; then | ||
echo "CHANGES_REQUIRED=true" >> $GITHUB_ENV | ||
fi | ||
|
||
- name: check available tokens | ||
run: | | ||
echo GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} | ||
echo REVIEW_TOKEN=${{ secrets.PR_REVIEW_PAT }} | ||
cat <<EOF | ||
${{ toJSON(secrets) }} | ||
EOF | ||
cat <<EOF | ||
${{ toJSON(inputs) }} | ||
EOF | ||
cat <<EOF | ||
${{ toJSON(github) }} | ||
EOF | ||
|
||
- name: Setup reviewdog | ||
uses: reviewdog/action-setup@v1 | ||
with: | ||
reviewdog_version: latest | ||
|
||
- name: Suggest changes using diff | ||
env: | ||
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.PR_REVIEW_PAT }} | ||
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 markdonwlint errors | ||
if: env.MD_LINT_STATUS == '1' | ||
env: | ||
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.PR_REVIEW_PAT }} | ||
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: Log and fail if front-matter linter fails | ||
if: env.FM_LINT_STATUS == '1' | ||
run: | | ||
echo "${{ env.FM_LINT_LOG }}" | ||
exit 1 | ||
|
||
- name: Fail till changes are pending | ||
if: env.CHANGES_REQUIRED == 'true' | ||
run: | | ||
echo "Please fix all the linting issues suggested in the review comments." | ||
exit 1 |
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,22 +1,33 @@ | ||||||||||||
--- | ||||||||||||
title: Game development | ||||||||||||
slug: Games | ||||||||||||
page-type: landing-page | ||||||||||||
slug: Games | ||||||||||||
--- | ||||||||||||
|
||||||||||||
{{GamesSidebar}} | ||||||||||||
|
||||||||||||
Gaming is one of the most popular computer activities. New technologies are constantly arriving to make it possible to develop better and more powerful games that can be run in any standards-compliant web browser. | ||||||||||||
|
||||||||||||
## Develop web games | ||||||||||||
```css | ||||||||||||
body { background-color: aqua; } | ||||||||||||
div { | ||||||||||||
color: red; | ||||||||||||
} | ||||||||||||
``` | ||||||||||||
|
||||||||||||
# Develop web games | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [markdownlint] reported by reviewdog 🐶 |
||||||||||||
|
||||||||||||
Welcome to the MDN game development center! In this area of the site, we provide resources for web developers wanting to develop games. You will find many useful tutorials and technique articles in the main menu on the left, so feel free to explore. | ||||||||||||
|
||||||||||||
* item 1 | ||||||||||||
+ item 2 | ||||||||||||
Comment on lines
+22
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [mdn-linter] reported by reviewdog 🐶
Suggested change
|
||||||||||||
- item 3 | ||||||||||||
|
||||||||||||
We've also included a reference section so you can easily find information about all the most common APIs used in game development. | ||||||||||||
|
||||||||||||
> **Note:** Creating games on the web draws on a number of core web technologies such as HTML, CSS, and JavaScript. The [Learning Area](/en-US/docs/Learn) is a good place to go to get started with the basics. | ||||||||||||
## Port native games to the Web | ||||||||||||
## Port native games to the Web | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [mdn-linter] reported by reviewdog 🐶
Suggested change
|
||||||||||||
|
||||||||||||
If you are a native developer (for example writing games in C++), and you are interested in how you can port your games over to the Web, you should learn more about our [Emscripten](https://emscripten.org/index.html) tool — this is an LLVM to JavaScript compiler, which takes LLVM bytecode (e.g. generated from C/C++ using Clang, or from another language) and compiles that into [asm.js](/en-US/docs/Games/Tools/asm.js), which can be run on the Web. | ||||||||||||
|
||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[mdn-linter] reported by reviewdog 🐶