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 github action to generate typedoc json automatically #2555

Merged
merged 2 commits into from
Feb 13, 2025

Conversation

MrKou47
Copy link
Member

@MrKou47 MrKou47 commented Feb 13, 2025

Summary by CodeRabbit

  • New Features
    • Introduced an automated process that generates and deploys up-to-date API documentation during releases and via manual triggers.
  • Chores
    • Improved the documentation generation process by adding flexible options for specifying the output location.

Copy link

coderabbitai bot commented Feb 13, 2025

Walkthrough

This pull request introduces a new GitHub Actions workflow to automate the generation and deployment of TypeDoc documentation. Triggered on pushes to tags matching "v*" and manual initiation, the workflow performs steps such as checking out the repository, setting up Node.js with pnpm, building the engine, preparing the output directory, and executing a script to generate TypeDoc JSON documentation which is subsequently uploaded to a CDN. Additionally, the typedoc.sh script has been updated to include configurable variables for the Typedoc version and output directory.

Changes

File Path Change Summary
.github/workflows/typedoc.yml New GitHub Actions workflow for TypeDoc documentation. Triggers on tag pushes and manual dispatch with steps for checkout, pnpm/Node.js setup, engine build, output directory creation, script execution, and CDN upload.
scripts/typedoc.sh Updated script with a new TYPEDOC variable (specifying version typedoc@0.23.28), removal of previous validation, and addition of an OUTPUT_DIR variable for customizable output path configuration.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant GitHubActions
    participant Checkout
    participant NodeSetup
    participant BuildEngine
    participant TypedocScript
    participant CDN

    User->>GitHubActions: Push tag "v*" or trigger workflow_dispatch
    GitHubActions->>Checkout: Checkout repository
    GitHubActions->>NodeSetup: Setup pnpm and Node.js LTS
    NodeSetup->>BuildEngine: Run engine build (pnpm b:all)
    BuildEngine->>TypedocScript: Execute typedoc.sh (using TYPEDOC & OUTPUT_DIR)
    TypedocScript->>CDN: Upload generated TypeDoc JSON
Loading

Possibly related PRs

Suggested labels

ignore for release

Suggested reviewers

  • GuoLei1990

Poem

Hi there, I'm a happy little bunny,
Hopping through code, never too runny.
New docs now spring forth with glee,
Automated steps for all to see.
With changes neat and bugs on the run,
I celebrate these updates—oh, what fun!
🐇✨


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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

@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: 0

🧹 Nitpick comments (1)
.github/workflows/typedoc.yml (1)

40-43: Add error handling for version extraction.

The version extraction from package.json should include error handling in case the file or version field is missing.

 - name: Create package.json for galacean-typedoc
   run: |
+    if [ ! -f "${{ github.workspace }}/packages/galacean/package.json" ]; then
+      echo "Error: package.json not found"
+      exit 1
+    fi
     VERSION=$(jq -r '.version' ${{ github.workspace }}/packages/galacean/package.json)
+    if [ -z "$VERSION" ] || [ "$VERSION" = "null" ]; then
+      echo "Error: version not found in package.json"
+      exit 1
+    fi
     echo "{\"name\": \"galacean-typedoc\", \"version\": \"$VERSION\"}" > ${{ github.workspace }}/galacean-typedoc/package.json
     cat ${{ github.workspace }}/galacean-typedoc/package.json
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 24d2589 and ff38b2b.

📒 Files selected for processing (3)
  • .github/workflows/typedoc.yml (1 hunks)
  • packages/core/src/physics/joint/Joint.ts (1 hunks)
  • scripts/typedoc.sh (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: build (22.x, windows-latest)
  • GitHub Check: codecov
  • GitHub Check: e2e (22.x)
🔇 Additional comments (5)
packages/core/src/physics/joint/Joint.ts (1)

288-288: Verify if commenting out joint rotation was intentional.

This change disables the native joint rotation update, which seems unrelated to the PR's objective of adding TypeDoc generation. Please verify if this was intentional or if it was accidentally included.

Likely an incorrect or invalid review comment.

scripts/typedoc.sh (2)

9-10: LGTM! Good improvement in configurability.

The addition of a configurable output directory with a sensible default is a good improvement that makes the script more flexible.

Also applies to: 17-19


7-7:

❓ Verification inconclusive

Verify if TypeDoc version 0.23.28 is appropriate.

The script uses a fixed version of TypeDoc which is good for consistency, but version 0.23.28 is quite old.


🌐 Web query:

What is the latest version of TypeDoc and are there any known issues with version 0.23.28?

💡 Result:

The latest version of TypeDoc is v0.27.7, released on February 9, 2025[1][9]. This update introduced several features and fixes:

  • File injection via @includeCode/@inline using regions or line numbers
  • Japanese localization improvements (replacing deprecated jp with ja)
  • Enhanced --watch mode for broader file monitoring[1][7]

For version 0.23.x, no direct information about issues appears in the search results - this version predates current documentation references (which focus on ≥v0.27). However:

1. Known limitations from earlier versions that might apply:

  • Older versions lacked modern validation features like link checking[7]
  • Pre-v0.24 had different anchor generation rules[7]
  • Earlier releases didn't support TypeScript ≥5.x features[1]

2. General upgrade considerations from release notes:

  • Version 0.27 introduced breaking changes including ESM conversion and TS5+ requirements[1][7]
  • Security scans show no vulnerabilities for current versions[6]

While no specific issues are documented for v0.23.28, users should upgrade due to significant improvements in:

  • API documentation accuracy
  • Markdown handling
  • Watch mode reliability
  • TypeScript compatibility (now requiring TS5+)[1][7][9]

Citations:


Action: Verify TypeDoc Version and Consider Future Upgrade

  • The fixed version (typedoc@0.23.28) ensures consistency but is significantly older than the current release (v0.27.7 as of February 2025).
  • Although no explicit issues or vulnerabilities were reported for v0.23.28, this version lacks several improvements found in later releases (e.g., enhanced watch mode, improved Markdown handling, and better TypeScript ≥5.x compatibility).
  • The configurable output directory setup is a strong improvement and can remain as is.

Please verify whether the benefits of upgrading to v0.27.7 outweigh any potential compatibility or stability concerns in your project.

.github/workflows/typedoc.yml (2)

5-64: LGTM! Well-structured workflow with good security practices.

The workflow is well-structured with appropriate triggers, minimal permissions, and secure handling of sensitive data.


32-32:

✅ Verification successful

Verify Node.js version requirement.

The workflow requires Node.js >=22.6.0 which is unusually high and not an LTS version. Consider using an LTS version for better stability.


🌐 Web query:

What is the current LTS version of Node.js?

💡 Result:

The current Long Term Support (LTS) version of Node.js is v22.x (codename "Jod"), which entered Active LTS status on October 29, 2024[1][7]. This version will receive critical updates and security patches until April 30, 2027[1][8], with:

  • Active LTS support through October 21, 2025
  • Maintenance LTS support continuing until April 30, 2027[7][8]

Key features of this LTS release include:

  • Built-in WebSocket client for real-time communication[1]
  • Enhanced stability for production environments[1]
  • Extended support timeline compared to previous versions like Node.js 20 (now in maintenance mode)[1][5]

Major platforms like Netlify have adopted Node.js v22 as their default runtime since January 2025[3], and it remains the recommended choice for production systems requiring long-term reliability[8]. The next LTS release (v24.x) is scheduled for April 2025[7].

Citations:


Node.js Version Requirement Validated

The Node.js version configured as >=22.6.0 is correct—it aligns with the current LTS Node.js v22.x release ("Jod"), providing the expected stability and long-term support. No changes regarding the Node.js version are required at this time. You might still review the version extraction logic and consider adding path filters if beneficial.

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

🧹 Nitpick comments (3)
.github/workflows/typedoc.yml (3)

5-9: Consider adding branch restrictions for manual workflow dispatch.

The workflow can be manually triggered on any branch. Consider restricting manual runs to specific branches (e.g., main/master) to maintain better control over documentation generation.

 on:
   push:
     tags:
       - "v*"
   workflow_dispatch:
+    branches:
+      - main  # or your default branch

43-46: Add error handling for version extraction.

The version extraction process could fail silently. Consider adding error handling and validation.

 run: |
+  if [ ! -f "${{ github.workspace }}/packages/galacean/package.json" ]; then
+    echo "Error: package.json not found"
+    exit 1
+  fi
   VERSION=$(jq -r '.version' ${{ github.workspace }}/packages/galacean/package.json)
+  if [ -z "$VERSION" ]; then
+    echo "Error: Failed to extract version"
+    exit 1
+  fi
   echo "{\"name\": \"galacean-typedoc\", \"version\": \"$VERSION\"}" > ${{ github.workspace }}/galacean-typedoc/package.json
   cat ${{ github.workspace }}/galacean-typedoc/package.json

1-10: Add timeout and concurrency settings for better workflow management.

Consider adding timeout and concurrency settings to prevent long-running or conflicting workflow executions.

 name: Generate TypeDoc

 on:
   push:
     tags:
       - "v*"
   workflow_dispatch:
+
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: true

 jobs:
   release:
+    timeout-minutes: 30
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ff38b2b and 86f27b1.

📒 Files selected for processing (1)
  • .github/workflows/typedoc.yml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: build (22.x, windows-latest)
  • GitHub Check: e2e (22.x)
  • GitHub Check: codecov
🔇 Additional comments (2)
.github/workflows/typedoc.yml (2)

11-17: Well-configured job permissions!

The job uses appropriate permissions following the principle of least privilege, requesting only the necessary write access for contents and id-token.


54-57: Reconsider running upload step on workflow failure.

The upload step runs even when the workflow fails (if: success() || failure()). This could potentially upload invalid or incomplete documentation. Consider running only on success unless there's a specific reason to keep failed artifacts.

-        if: success() || failure()
+        if: success()

Comment on lines +32 to +34
node-version: '>=22.6.0'
registry-url: https://registry.npmjs.org/
cache: pnpm
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Specify an exact Node.js version for reproducible builds.

Using >=22.6.0 could lead to inconsistent builds across different environments. Consider pinning to a specific LTS version.

-          node-version: '>=22.6.0'
+          node-version: '22.6.0'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
node-version: '>=22.6.0'
registry-url: https://registry.npmjs.org/
cache: pnpm
node-version: '22.6.0'
registry-url: https://registry.npmjs.org/
cache: pnpm

Copy link

codecov bot commented Feb 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.92%. Comparing base (24d2589) to head (86f27b1).
Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2555      +/-   ##
==========================================
+ Coverage   68.91%   68.92%   +0.01%     
==========================================
  Files         961      961              
  Lines      100266   100266              
  Branches     8679     8686       +7     
==========================================
+ Hits        69094    69107      +13     
+ Misses      30912    30899      -13     
  Partials      260      260              
Flag Coverage Δ
unittests 68.92% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@MrKou47 MrKou47 merged commit 78f7415 into main Feb 13, 2025
9 checks passed
@GuoLei1990 GuoLei1990 added the bug Something isn't working label Feb 18, 2025
@GuoLei1990 GuoLei1990 deleted the chore/typedoc-action branch February 18, 2025 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants