Skip to content

Commit

Permalink
Lint front matter (#14355)
Browse files Browse the repository at this point in the history
* Lint frontmatter during Markdown auto-fix workflow

* Lint front matter during main linting run
  • Loading branch information
queengooborg authored Aug 14, 2023
1 parent ba9f02c commit 110439a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
22 changes: 21 additions & 1 deletion .github/workflows/markdown-lint-fix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,30 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HUSKY: 0

- name: Lint markdown files
- uses: actions/checkout@v3
with:
repository: mdn/content
path: mdn/content

- name: Setup Node.js environment for mdn/content
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: "yarn"
cache-dependency-path: mdn/content/yarn.lock

- name: Install all yarn packages for mdn/content
working-directory: ${{ github.workspace }}/mdn/content
run: yarn --frozen-lockfile
env:
# https://github.com/microsoft/vscode-ripgrep#github-api-limit-note
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Lint Markdown files
run: |
yarn markdownlint-cli2-fix "**/${{ matrix.lang }}/**/*.md"
yarn prettier -w "**/${{ matrix.lang }}/**/*.md"
cd ${{ github.workspace }}/mdn/content && yarn fix:fm --config-file ${{ github.workspace }}/front-matter-config.json --files "${{ github.workspace }}/files/${{ matrix.lang }}"
- name: Create PR with only fixable issues
if: success()
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/pr-check-lint_content.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,25 @@ jobs:
- name: Install all yarn packages
run: yarn --frozen-lockfile

- uses: actions/checkout@v3
with:
repository: mdn/content
path: mdn/content

- name: Setup Node.js environment for mdn/content
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: "yarn"
cache-dependency-path: mdn/content/yarn.lock

- name: Install all yarn packages for mdn/content
working-directory: ${{ github.workspace }}/mdn/content
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
if: ${{ env.DIFF_DOCUMENTS }}
run: |
Expand All @@ -85,6 +104,14 @@ jobs:
echo "${EOF}" >> $GITHUB_ENV
echo "MD_LINT_FAILED=${MD_LINT_FAILED}" >> $GITHUB_ENV
echo "Linting front-matter"
FM_LINT_FAILED=false
FM_LINT_LOG=$(cd ${{ github.workspace }}/mdn/content && yarn fix:fm --config-file ${{ github.workspace }}/front-matter-config.json --fix true ${files_to_lint} 2>&1) || FM_LINT_FAILED=true
echo "FM_LINT_LOG<<${EOF}" >> $GITHUB_ENV
echo "${FM_LINT_LOG}" >> $GITHUB_ENV
echo "${EOF}" >> $GITHUB_ENV
echo "FM_LINT_FAILED=${FM_LINT_FAILED}" >> $GITHUB_ENV
echo "Running Prettier"
yarn prettier -w ${files_to_lint}
Expand Down

0 comments on commit 110439a

Please sign in to comment.