Skip to content

chore: Add Markdownlint checking and CI #541

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
17 changes: 17 additions & 0 deletions .github/workflows/markdownlint-problem-matcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"problemMatcher": [
{
"owner": "markdownlint",
"pattern": [
{
"regexp": "^([^:]*):(\\d+):?(\\d+)?\\s([\\w-\\/]*)\\s(.*)$",
"file": 1,
"line": 2,
"column": 3,
"code": 4,
"message": 5
}
]
}
]
}
50 changes: 50 additions & 0 deletions .github/workflows/markdownlint-translations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Markdownlint Translations

on:
pull_request:
branches:
- translations
push:
branches:
- translations

jobs:
see_if_should_skip:
runs-on: ubuntu-latest

outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@36feb0d8d062137530c2e00bd278d138fe191289
with:
cancel_others: 'false'
github_token: ${{ github.token }}
paths: '["translations/**/*.md", "package*.json", ".markdownlint.json", ".github/workflows/markdownlint-translations.yml", ".github/workflows/markdownlint-problem-matcher.json"]'
lint:
runs-on: ubuntu-latest
needs: see_if_should_skip
if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
steps:
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f

- name: Get npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"

- name: Cache node modules
uses: actions/cache@0781355a23dac32fd3bac414512f4b903437991a
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install dependencies
run: npm ci

- name: Run Markdownlint
run: |
echo "::add-matcher::.github/workflows/markdownlint-problem-matcher.json"
npm run markdownlint:translations
51 changes: 51 additions & 0 deletions .github/workflows/markdownlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Markdownlint

on:
pull_request:
branches-ignore:
- translations
push:
branches:
- main

jobs:
see_if_should_skip:
runs-on: ubuntu-latest

outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@36feb0d8d062137530c2e00bd278d138fe191289
with:
cancel_others: 'false'
github_token: ${{ github.token }}
paths: '["**/*.md", "!translations/**", "package*.json", ".markdownlint.json", ".github/workflows/markdownlint.yml", ".github/workflows/markdownlint-problem-matcher.json"]'
paths_ignore: '["translations/**"]'
lint:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename this to something other than "lint" to avoid confusion with the JavaScript-linting job? Maybe mdlint or markdown-lint? 🤷‍♂️

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Figured it was better to use the same job name so it stays a required check

runs-on: ubuntu-latest
needs: see_if_should_skip
if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
steps:
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f

- name: Get npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"

- name: Cache node modules
uses: actions/cache@0781355a23dac32fd3bac414512f4b903437991a
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install dependencies
run: npm ci

- name: Run Markdownlint
run: |
echo "::add-matcher::.github/workflows/markdownlint-problem-matcher.json"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this line doing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This registers the problem matcher file so that PRs get in-line comments on the file tab if the markdownlint job puts any issues to the jobs console

npm run markdownlint
36 changes: 36 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"default": true,
"MD001": false,
"MD003": false,
"MD004": false,
"MD005": false,
"MD007": false,
"MD009": false,
"MD010": false,
"MD012": false,
"MD013": false,
"MD014": false,
"MD019": false,
"MD020": false,
"MD022": false,
"MD023": false,
"MD024": false,
"MD025": false,
"MD026": false,
"MD029": false,
"MD030": false,
"MD031": false,
"MD032": false,
"MD033": false,
"MD034": false,
"MD036": false,
"MD037": false,
"MD038": false,
"MD039": false,
"MD040": false,
"MD041": false,
"MD042": false,
"MD045": false,
"MD046": false,
"MD047": false
}
113 changes: 113 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
"jest-silent-reporter": "^0.2.1",
"jest-slow-test-reporter": "^1.0.0",
"make-promises-safe": "^5.1.0",
"markdownlint-cli": "^0.25.0",
"mime": "^2.4.4",
"mock-express-response": "^0.2.2",
"nock": "^13.0.4",
Expand All @@ -137,8 +138,10 @@
"rest-dev": "script/rest/update-files.js && npm run dev",
"build": "cross-env NODE_ENV=production npx webpack --mode production",
"start-all-languages": "cross-env NODE_ENV=development nodemon server.js",
"lint": "eslint --fix . && prettier -w \"**/*.{yml,yaml}\"",
"test": "jest && eslint . && prettier -c \"**/*.{yml,yaml}\" && npm run check-deps",
"lint": "eslint --fix . && prettier -w \"**/*.{yml,yaml}\" && npm run markdownlint -- --fix",
"test": "jest && eslint . && prettier -c \"**/*.{yml,yaml}\" && npm run markdownlint && npm run check-deps",
"markdownlint": "markdownlint \"**/*.md\" -i \"node_modules\" -i \"translations\"",
"markdownlint:translations": "markdownlint \"translations/**/*.md\"",
"prebrowser-test": "npm run build",
"browser-test": "start-server-and-test browser-test-server 4001 browser-test-tests",
"browser-test-server": "cross-env NODE_ENV=production ENABLED_LANGUAGES='en,ja' PORT=4001 node server.js",
Expand Down