From 8f547bdd48dd43d0fbe5f0c50b71e9b38e6dcb08 Mon Sep 17 00:00:00 2001 From: Ansh Goyal Date: Fri, 18 Oct 2024 15:36:28 +0000 Subject: [PATCH] add md test --- .github/workflows/if-nodejs-pr-testing.yml | 36 +++++++++++++++++++++- package.json | 1 + 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/.github/workflows/if-nodejs-pr-testing.yml b/.github/workflows/if-nodejs-pr-testing.yml index 2154143339cc..cb74406a6881 100644 --- a/.github/workflows/if-nodejs-pr-testing.yml +++ b/.github/workflows/if-nodejs-pr-testing.yml @@ -59,7 +59,7 @@ jobs: name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: "${{ steps.nodeversion.outputs.version }}" + node-version: '${{ steps.nodeversion.outputs.version }}' - name: Install dependencies run: npm ci - if: steps.packagejson.outputs.exists == 'true' @@ -72,3 +72,37 @@ jobs: name: Run release assets generation to make sure PR does not break it shell: bash run: npm run generate:assets --if-present + + # Run the test:md script and capture output + - if: steps.packagejson.outputs.exists == 'true' + name: Run markdown checks + id: markdown_check + run: | + OUTPUT=$(npm run test:md || true) + echo "$OUTPUT" | tee markdown_output.txt + echo "::set-output name=markdown_output::$OUTPUT" + shell: bash + + # Parse the output and post a comment on GitHub PR + - name: Post markdown check results + if: steps.packagejson.outputs.exists == 'true' + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const output = `steps.markdown_check.outputs.markdown_output`; + let body = "### Markdown Check Results\n\n"; + if (output.includes('Errors in file')) { + const errorLines = output.split('\\n').filter(line => line.startsWith('Errors in file')); + errorLines.forEach(errorLine => { + body += `- ${errorLine}\\n`; + }); + } else { + body += "✅ No markdown issues found."; + } + github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.pull_request.number, + body: body + }) diff --git a/package.json b/package.json index 04ba37b586eb..29269ed3e1d6 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "generate:videos": "node scripts/build-newsroom-videos.js", "generate:tools": "node scripts/build-tools.js", "test:netlify": "deno test --allow-env --trace-ops netlify/**/*.test.ts", + "test:md": "node scripts/markdown/check-markdown.js", "dev:storybook": "storybook dev -p 6006", "build:storybook": "storybook build" },