Skip to content

Commit

Permalink
add md test
Browse files Browse the repository at this point in the history
  • Loading branch information
anshgoyalevil committed Oct 18, 2024
1 parent 25eb795 commit 8f547bd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
36 changes: 35 additions & 1 deletion .github/workflows/if-nodejs-pr-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
})
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down

0 comments on commit 8f547bd

Please sign in to comment.