-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into JoanCamosTyk-patch-4
- Loading branch information
Showing
259 changed files
with
26,515 additions
and
16,693 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Docs Rule Engine | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize] | ||
|
||
jobs: | ||
run-script: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' # Change to your required version | ||
|
||
- name: Install dependencies | ||
run: | | ||
cd scripts/docs-rule-engine | ||
npm install | ||
- name: Run script | ||
run: | | ||
cd scripts/docs-rule-engine | ||
node index.js | ||
env: | ||
PR_NUMBER: ${{ github.event.pull_request.number }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub Token for API calls | ||
ANTHROPIC_KEY: ${{ secrets.ANTHROPIC_KEY }} # Org key already available |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Enforce PR Standards | ||
|
||
on: | ||
pull_request: | ||
types: [opened, edited, synchronize] | ||
|
||
jobs: | ||
check-pr: | ||
runs-on: ubuntu-latest | ||
if: ${{ !github.event.pull_request.draft }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '22' # Use your desired Node.js version | ||
|
||
- name: Install dependencies | ||
run: cd scripts/pr-review-bot/ && npm install | ||
|
||
- name: Install dependencies | ||
run: cd scripts/pr-review-bot/ && npm install | ||
|
||
- name: Run PR checklist script | ||
run: node scripts/pr-review-bot/index.js | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Use GitHub's automatically generated token | ||
PR_NUMBER: ${{ github.event.pull_request.number }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: EOD Report Generator | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
MAIN_REVIEWER: | ||
description: "The GitHub user ID of the primary reviewer whose approval is required for the PR." | ||
required: true | ||
default: "sharadregoti" | ||
PR_SCAN_DATE: | ||
description: "The date when the report was generated. Defaults to the current date (e.g., 2025-02-04)." | ||
required: false | ||
|
||
jobs: | ||
run-script: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' # Change to your required version | ||
|
||
- name: Install dependencies | ||
run: | | ||
cd scripts/eod-report-generator | ||
npm install | ||
- name: Run script | ||
run: | | ||
cd scripts/eod-report-generator | ||
node index.js | ||
env: | ||
MAIN_REVIEWER: ${{ inputs.MAIN_REVIEWER }} | ||
PR_SCAN_DATE: ${{ inputs.PR_SCAN_DATE }} | ||
GITHUB_TOKEN: ${{ secrets.TYK_SCRIPTS_TOKEN }} # GitHub Token for API calls | ||
ANTHROPIC_KEY: ${{ secrets.ANTHROPIC_KEY }} # Org key already available |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
rules: | ||
- id: 1 | ||
enable: true | ||
title: "Ensure that the internal links are using <ref> system" | ||
description: "" | ||
- id: 2 | ||
enable: true | ||
title: "Don’t add apostrophe in reference text" | ||
description: "Apostrophes in reference text does not render properly" | ||
- id: 3 | ||
enable: true | ||
title: "Use of wrong headers that don’t render in the right side Nav" | ||
description: "" | ||
- id: 4 | ||
enable: true | ||
title: "Ensure all the headings use Pascal Case" | ||
description: "" | ||
- id: 5 | ||
enable: true | ||
title: "Images & YouTube shortcodes should have alt section in it." | ||
description: "" | ||
- id: 6 | ||
enable: true | ||
title: "Release Notes should not have comments in it, always use the condensed version" | ||
description: "" | ||
# Not Implemented | ||
- id: 7 | ||
enable: true | ||
title: "Release Notes should follow condensed template." | ||
description: "" | ||
- id: 8 | ||
enable: true | ||
title: "Invalid Hugo frontmatter" | ||
description: "" | ||
- id: 9 | ||
enable: true | ||
title: "Don’t use ackronyms or shortcuts in headers" | ||
description: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
import { checkImageResolution } from './image.js' | ||
import { getPR } from './github.js' | ||
import { getFrontmatter, printMarkdown, getShorcodes, getComments, getLinks, getHeadings } from './markdown.js' | ||
import Case from 'case'; | ||
import yaml from 'js-yaml' | ||
import fs from 'fs' | ||
import { extractHeadings } from './sonet.js'; | ||
|
||
export async function evaluate(config, md) { | ||
const links = await getLinks(md) | ||
// console.log("Links", links) | ||
// return | ||
const headings = await getHeadings(md) | ||
const comments = await getComments(md) | ||
const shortCodes = await getShorcodes(md) | ||
|
||
for (let i = 0; i < config.rules.length; i++) { | ||
|
||
const rule = config.rules[i] | ||
|
||
if (!rule.enable) { | ||
// console.log(`Skipping rule: ${rule.title}`); | ||
continue | ||
} | ||
console.log('\n'); | ||
|
||
switch (rule.id) { | ||
case 1: | ||
const filteredLinks = links.filter(link => !(link.href.startsWith('http') || link.href.startsWith('https') || link.raw.includes('({{'))); | ||
|
||
if (filteredLinks.length > 0) { | ||
console.log(`Rule ID ${rule.id} Failing : ${rule.title}`); | ||
console.log(filteredLinks); | ||
} | ||
break; | ||
|
||
case 2: | ||
const invalidTextLinks = links.filter(link => link.text.includes("'")); | ||
|
||
if (invalidTextLinks.length > 0) { | ||
console.log(`Rule ID ${rule.id} Failing : ${rule.title}`); | ||
console.log(invalidTextLinks); | ||
} | ||
break; | ||
|
||
case 3: | ||
const headingsWithInvalidDepth = headings.filter(heading => { | ||
return [1, 5, 6].includes(heading.depth) | ||
}); | ||
|
||
if (headingsWithInvalidDepth.length > 0) { | ||
console.log(`Rule ID ${rule.id} Failing : ${rule.title}`); | ||
console.log(headingsWithInvalidDepth); | ||
} | ||
|
||
break; | ||
|
||
case 4: | ||
const filteredHeadings = headings.filter((heading, index) => { | ||
if (index === 0) { | ||
return false | ||
} | ||
return !["title", "capital"].includes(Case.of(heading.text)) | ||
}); | ||
|
||
if (filteredHeadings.length > 0) { | ||
console.log(`Rule ID ${rule.id} Failing : ${rule.title}`); | ||
console.log(filteredHeadings); | ||
} | ||
|
||
break; | ||
|
||
case 5: | ||
// Regular expression to match the alt attribute | ||
const altRegex = /alt\s*=\s*"([^"]*)"/; | ||
|
||
const filteredShortcodes = shortCodes.filter(shortCode => { | ||
// Check if alt attribute exists | ||
const hasAlt = altRegex.test(shortCode); | ||
|
||
// If alt exists, check if it's empty | ||
if (hasAlt) { | ||
return shortCode.match(altRegex)[1].trim() === ''; | ||
} | ||
|
||
// If alt doesn't exist, include it | ||
return true; | ||
}); | ||
|
||
if (filteredShortcodes.length > 0) { | ||
console.log(`Rule ID ${rule.id} Failing : ${rule.title}`); | ||
console.log(filteredShortcodes); | ||
} | ||
|
||
break; | ||
|
||
case 6: | ||
if (comments.length > 0) { | ||
console.log(`Rule ID ${rule.id} Failing : ${rule.title}`); | ||
} | ||
break; | ||
|
||
case 7: | ||
// Get condensed template | ||
// Get headings of it | ||
// Evaluate against ours | ||
if (comments.length > 0) { | ||
console.log("Comments are present") | ||
} | ||
break; | ||
|
||
case 8: | ||
const data = await getFrontmatter(md) | ||
|
||
if (Object.keys(data).length === 0) { | ||
console.log(`Rule ID ${rule.id} Failing : ${rule.title}`); | ||
} | ||
const requiredKeys = ['title', 'date', 'description', 'tags', 'categories', 'summary', 'keywords']; | ||
|
||
const missingKeys = requiredKeys.filter(key => !(key in data)); | ||
|
||
if (missingKeys.length > 0) { | ||
console.log(`Rule ID ${rule.id} Failing : ${rule.title}`); | ||
console.log(`Missing required frontmatter keys: ${missingKeys.join(', ')}`); | ||
} | ||
|
||
break; | ||
|
||
case 9: | ||
const combinedString = headings.map((heading, index) => { | ||
if (index === 0) { | ||
return '' | ||
} | ||
return `${index}. ${heading.text}\n`; | ||
}).join(''); | ||
|
||
const res = await extractHeadings(combinedString) | ||
|
||
const arr = JSON.stringify(res) | ||
|
||
if (arr.length > 0) { | ||
console.log(`Rule ID ${rule.id} Failing : ${rule.title}`); | ||
console.log(res); | ||
} | ||
|
||
break; | ||
|
||
default: | ||
break; | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.