Skip to content

Commit

Permalink
Merge branch 'master' into JoanCamosTyk-patch-4
Browse files Browse the repository at this point in the history
  • Loading branch information
sharadregoti authored Feb 10, 2025
2 parents 9013020 + 6cf37cd commit 12ce239
Show file tree
Hide file tree
Showing 259 changed files with 26,515 additions and 16,693 deletions.
6 changes: 5 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
- [ ] I have [reviewed the guidelines](https://github.com/TykTechnologies/tyk-docs/blob/master/CONTRIBUTING.md) for contributing to this repository.
- [ ] I have [read the technical guidelines](https://github.com/TykTechnologies/tyk-docs/blob/master/CONTRIBUTING-TECHNICAL-GUIDE.md) for contributing to this repository.
- [ ] Make sure you have started *your change* off *our latest `master`*.
- [ ] I **labeled** the PR
- [ ] **For Tyk Members** - Please add a Jira DX PR ticket to the subject!
- [ ] **For Tyk Members** - I have added the appropriate release label to this PR:
- If it is for a future release, label it as **`future-release`** and specify the version (e.g., `future-release, 6.0`).
- If it should be merged into an older version, use the specific version label (e.g., `4.1`, `5.1`).
- If no label is added, it will be assumed that the PR should be merged into the latest current version (e.g., `5.5`) and `master`.
<!-- Label your PR according to the type of changes that your code introduces. This ensures that we know how/when to publish the PR. These are the options:
- Fixing typo (please merge to production) - add the label `now`
- Documenting a new feature (please merge to production) - add the label `now`
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/docs-rule-engine.yaml
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
30 changes: 30 additions & 0 deletions .github/workflows/enforce-pr-standards.yaml
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 }}
40 changes: 40 additions & 0 deletions .github/workflows/eod-report-generator.yaml
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
4 changes: 2 additions & 2 deletions .github/workflows/link-checker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ jobs:
echo "Base PR commit: $commit_before_pull_request"
cd tyk-docs && bash ../scripts/urlcheck.sh $commit_before_pull_request
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: always()
with:
name: urlcheck-new
path: /tmp/urlcheck.new.json
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: always()
with:
name: urlcheck-prev
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release-to-branches-in-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
- name: Add a comment to the merged PR (only if labeler is in the org)
uses: actions/github-script@v7
with:
github-token: ${{ secrets.TYK_SCRIPTS_TOKEN }}
script: |
// 1. The label format: e.g., "release-1", "release-1.0"
const labelRegex = /^release-[0-9]+(\.[0-9]+)?$/;
Expand Down
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ node_modules/
node_modules
package-lock.json
package.json
changed-files.txt
changed-files.txt

# Allow specific files
!scripts/docs-rule-engine/package.json
!scripts/docs-rule-engine/package-lock.json
!scripts/pr-review-bot/package.json
!scripts/pr-review-bot/package-lock.json
!scripts/eod-report-generator/package.json
!scripts/eod-report-generator/package-lock.json
2 changes: 1 addition & 1 deletion CONTRIBUTING-TECHNICAL-GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ Learn how to segment and view your API traffic and activity
Tyk supports GraphQL natively. Proxy to existing service or build it from scratch.
{{< /badge >}}
{{< badge title="Integration" href="/docs/advanced-configuration/integrate/sso/" >}}
{{< badge title="Integration" href="/docs/api-management/external-service-integration#single-sign-on-sso" >}}
#### Single Sign On
Log into the dashboard and portal with your existing IDP.
Expand Down
38 changes: 38 additions & 0 deletions scripts/docs-rule-engine/config.yaml
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: ""
153 changes: 153 additions & 0 deletions scripts/docs-rule-engine/evaluate.js
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;
}
}

}
Loading

0 comments on commit 12ce239

Please sign in to comment.