From 110439a613d169e896e726c364e686d76993c9e2 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Mon, 14 Aug 2023 15:26:53 -0700 Subject: [PATCH] Lint front matter (#14355) * Lint frontmatter during Markdown auto-fix workflow * Lint front matter during main linting run --- .github/workflows/markdown-lint-fix.yml | 22 ++++++++++++++++- .github/workflows/pr-check-lint_content.yml | 27 +++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/.github/workflows/markdown-lint-fix.yml b/.github/workflows/markdown-lint-fix.yml index e58d760b4dd25f..9e36c761edf1a0 100644 --- a/.github/workflows/markdown-lint-fix.yml +++ b/.github/workflows/markdown-lint-fix.yml @@ -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() diff --git a/.github/workflows/pr-check-lint_content.yml b/.github/workflows/pr-check-lint_content.yml index c9fe1855f63eb5..a17a2921a06260 100644 --- a/.github/workflows/pr-check-lint_content.yml +++ b/.github/workflows/pr-check-lint_content.yml @@ -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: | @@ -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}