Skip to content

Commit

Permalink
Test: reviewdog on all linters
Browse files Browse the repository at this point in the history
  • Loading branch information
OnkarRuikar committed Jul 28, 2023
1 parent b1050f2 commit c4b91a8
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 52 deletions.
50 changes: 0 additions & 50 deletions .github/workflows/pr-check_markdownlint.yml

This file was deleted.

103 changes: 103 additions & 0 deletions .github/workflows/pr-review-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Add lint reviews to PRs

on:
pull_request:
branches:
- main
paths:
- .nvmrc
- "**/*.md"

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
# documenation: 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: |
#echo "::add-matcher::.github/workflows/markdownlint-problem-matcher.json"
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}
- name: Setup reviewdog
uses: reviewdog/action-setup@v1
with:
reviewdog_version: latest

- name: Suggest changes using diff
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TMPFILE=$(mktemp)
git diff >"${TMPFILE}"
git stash -u && git stash drop
echo "Running rd"
reviewdog \
-name="MDNLinter" \
-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.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: Log and fail if front-matter linter fails
if: env.FM_LINT_STATUS == '1'
run: |
echo "${{ env.FM_LINT_LOG }}"
exit 1
15 changes: 13 additions & 2 deletions files/en-us/games/index.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
---
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

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
- 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.
Expand Down

0 comments on commit c4b91a8

Please sign in to comment.