Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add workflow and script to check edit links on docs #3557

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

anshgoyalevil
Copy link
Member

@anshgoyalevil anshgoyalevil commented Jan 8, 2025

Description

  • This PR adds a script that programatically creates the doc URLs and fetch their head to check if their exist an edit link on AsyncAPI website.
  • The workflow would run once a week at midnight.
  • If their were any errors, the workflow would dump the error to Slack. Example message: https://asyncapi.slack.com/archives/C0884HHQZS5/p1736348664768859

Related issue(s)
fixes #3221

Summary by CodeRabbit

Release Notes

  • New Features

    • Added a weekly automated link checker to verify documentation links.
    • Introduced a new script to check markdown file edit links.
  • Chores

    • Updated configuration for documentation edit links.
  • Bug Fixes

    • Improved edit link generation for files with .mdx extension.
    • Fixed potential broken documentation links.

Copy link

coderabbitai bot commented Jan 8, 2025

Walkthrough

The pull request introduces a GitHub Actions workflow for automated checking of edit links, modifies the DocsLayout component to correctly transform .mdx links to .md, updates a configuration file with a new documentation URL, adds a new npm script for link checking, and implements a script for validating edit links in markdown files. These changes collectively aim to enhance the accuracy and functionality of edit links across the documentation.

Changes

File Change Summary
.github/workflows/check-edit-links.yml New workflow for weekly automated link checking
components/layout/DocsLayout.tsx Modified generateEditLink to handle .mdx to .md link conversion
config/edit-page-config.json Updated AsyncAPI generator documentation URL path
package.json Added test:editlinks script
scripts/markdown/check-editlinks.js New script for comprehensive edit link validation

Assessment against linked issues

Objective Addressed Explanation
Fix incorrect edit links for doc pages [#3221]

Poem

🐰 Hop, hop, through markdown's maze,
Fixing links with coding praise,
From .mdx to .md we dance,
No broken paths shall now entrance!
Edit links now shine so bright,
A rabbit's code-fixing delight! 🔗✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Jan 8, 2025

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit c13eb87
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/677e975db8594100082f2b08
😎 Deploy Preview https://deploy-preview-3557--asyncapi-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@asyncapi-bot
Copy link
Contributor

asyncapi-bot commented Jan 8, 2025

⚡️ Lighthouse report for the changes in this PR:

Category Score
🔴 Performance 43
🟢 Accessibility 98
🟢 Best practices 92
🟢 SEO 100
🔴 PWA 33

Lighthouse ran on https://deploy-preview-3557--asyncapi-website.netlify.app/

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
.github/workflows/check-edit-links.yml (2)

32-37: Improve shell script robustness.

The error extraction step could be more robust by following shell scripting best practices.

 - name: Extract 404 URLs from output
   id: extract-404
   run: |
-    ERRORS=$(sed -n '/URLs returning 404:/,$p' output.log)
-    echo "errors<<EOF" >> $GITHUB_OUTPUT
-    echo "$ERRORS" >> $GITHUB_OUTPUT
-    echo "EOF" >> $GITHUB_OUTPUT
+    {
+      ERRORS="$(sed -n '/URLs returning 404:/,$p' output.log)"
+      echo "errors<<EOF"
+      echo "${ERRORS}"
+      echo "EOF"
+    } >> "$GITHUB_OUTPUT"
🧰 Tools
🪛 actionlint (1.7.4)

32-32: shellcheck reported issue in this script: SC2129:style:2:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)


32-32: shellcheck reported issue in this script: SC2086:info:2:23: Double quote to prevent globbing and word splitting

(shellcheck)


32-32: shellcheck reported issue in this script: SC2086:info:3:19: Double quote to prevent globbing and word splitting

(shellcheck)


32-32: shellcheck reported issue in this script: SC2086:info:4:15: Double quote to prevent globbing and word splitting

(shellcheck)


38-49: Consider adding error categorization in Slack notification.

The Slack notification could be more informative by categorizing errors.

 SLACK_MESSAGE: |
   🚨 The following URLs returned 404 during the link check:

${{ steps.extract-404.outputs.errors }}

+  Note: These errors might be due to:
+  - Missing documentation files
+  - Incorrect edit link paths
+  - Repository structure changes
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4d002ce and 689a861.

📒 Files selected for processing (5)
  • .github/workflows/check-edit-links.yml (1 hunks)
  • components/layout/DocsLayout.tsx (1 hunks)
  • config/edit-page-config.json (2 hunks)
  • package.json (1 hunks)
  • scripts/markdown/check-editlinks.js (1 hunks)
🧰 Additional context used
🪛 eslint
scripts/markdown/check-editlinks.js

[error] 58-58: Unexpected await inside a loop.

(no-await-in-loop)


[error] 59-59: Unexpected await inside a loop.

(no-await-in-loop)

🪛 actionlint (1.7.4)
.github/workflows/check-edit-links.yml

32-32: shellcheck reported issue in this script: SC2129:style:2:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)


32-32: shellcheck reported issue in this script: SC2086:info:2:23: Double quote to prevent globbing and word splitting

(shellcheck)


32-32: shellcheck reported issue in this script: SC2086:info:3:19: Double quote to prevent globbing and word splitting

(shellcheck)


32-32: shellcheck reported issue in this script: SC2086:info:4:15: Double quote to prevent globbing and word splitting

(shellcheck)

⏰ Context from checks skipped due to timeout of 180000ms (1)
  • GitHub Check: Lighthouse CI
🔇 Additional comments (4)
components/layout/DocsLayout.tsx (1)

37-39: Ensure correct conversion of .mdx to .md in edit links

By replacing .mdx with .md in edit links, please verify that all .mdx files correspond to .md files in the repository. Ensure that this change does not introduce broken edit links for any files that should remain as .mdx.

config/edit-page-config.json (1)

4-4: Verify the updated href path for the AsyncAPI Generator docs

The href for /tools/generator has been updated to a new path. Please confirm that https://github.com/asyncapi/generator/tree/master/apps/generator/docs is the correct location for the generator's documentation and that the link is accessible.

.github/workflows/check-edit-links.yml (1)

3-7: LGTM! Well-configured workflow triggers.

The workflow is appropriately scheduled to run weekly and includes manual trigger capability.

package.json (1)

27-27: Verify the edit links checker script and its dependencies.

The script addition looks good, but let's ensure the required files and dependencies are in place.

✅ Verification successful

✓ Edit links checker implementation is complete and properly configured

All required dependencies and configuration files are in place:

  • node-fetch-2 is available in package.json
  • edit-page-config.json exists with valid mappings
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the edit links checker script and related files

# Check if the script file exists
if ! [ -f "scripts/markdown/check-editlinks.js" ]; then
  echo "Error: check-editlinks.js script is missing"
  exit 1
fi

# Check for required dependencies in package.json
rg "scripts/markdown/check-editlinks.js" -l

Length of output: 105


Script:

#!/bin/bash
# Check script content and dependencies
cat scripts/markdown/check-editlinks.js

# Also check package.json for any related dependencies
cat package.json | jq '.dependencies, .devDependencies'

Length of output: 9008


Script:

#!/bin/bash
# Check if the config file exists
if [ -f "config/edit-page-config.json" ]; then
    echo "Config file exists"
    cat config/edit-page-config.json
else
    echo "Config file missing"
fi

Length of output: 705

scripts/markdown/check-editlinks.js Show resolved Hide resolved
.github/workflows/check-edit-links.yml Show resolved Hide resolved
Copy link

codecov bot commented Jan 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (4d002ce) to head (c13eb87).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #3557   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           19        19           
  Lines          668       668           
=========================================
  Hits           668       668           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

'scripts/compose.js',
'scripts/tools/categorylist.js',
'scripts/tools/tags-color.js',
'scripts/markdown/check-editlinks.js'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added the new script to ignore Jest coverage to pass CI. Will create a new good first issue for other contributors to add test

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 689a861 and c13eb87.

📒 Files selected for processing (1)
  • jest.config.js (1 hunks)
⏰ Context from checks skipped due to timeout of 180000ms (3)
  • GitHub Check: Redirect rules - asyncapi-website
  • GitHub Check: Header rules - asyncapi-website
  • GitHub Check: Pages changed - asyncapi-website
🔇 Additional comments (1)
jest.config.js (1)

14-14: LGTM!

The testMatch pattern correctly excludes Netlify edge function tests while including other test files.

jest.config.js Show resolved Hide resolved
@asyncapi-bot asyncapi-bot added the bounty AsyncAPI Bounty program related label label Jan 9, 2025
@aeworxet
Copy link
Contributor

aeworxet commented Jan 9, 2025

@asyncapi/bounty_team

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bounty AsyncAPI Bounty program related label
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

Refactor the edit-this-page-on-github workflow
3 participants