Skip to content

Add Github Actions step for generating docs #2954

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

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

ckeshava
Copy link
Collaborator

@ckeshava ckeshava commented Apr 3, 2025

High Level Overview of Change

This PR aims to generate fresh documentation with every commit. Specifically, js.xrpl.org will host the documentation of the latest version of the main branch. Other functional aspects of the client library are not affected.

Additionally, the settings of this repository will be updated. Documentation will be deployed from Github Actions, instead of reading from the docs/ folder (this is the existing behavior)

An artifact pertaining to the new documentation is generated in every CI run. The link can be found in the Upload documentation files as artifact step of the Github Actions workflow.

Context of Change

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Tests (You added tests for code that already exists, or your new feature included in this PR)
  • Documentation Updates
  • Release

Did you update HISTORY.md?

  • Yes
  • No, this change does not impact library users

Test Plan

The generated artifact and deployed documentation matches the expectation.

Copy link

coderabbitai bot commented Apr 3, 2025

Walkthrough

This update modifies the GitHub Actions workflow for Node.js CI by adding two new jobs: generate-documentation and deploy-docs-pages. The generate-documentation job runs on Node.js 22.x with npm v10, caches dependencies, builds the project, generates documentation, and uploads it as an artifact. The deploy-docs-pages job depends on the documentation generation, runs only on the main branch, and deploys the documentation to GitHub Pages if the event is a semantic version tag. Additionally, Node.js 18.x was removed from the job matrices, triggers were updated to include all tags and remove the 1.x branch, and the project history file was updated to document the new automated documentation generation step.

Changes

File(s) Change Summary
.github/workflows/nodejs.yml Updated workflow triggers to include all tags and remove 1.x branch; removed Node.js 18.x from job matrices; added generate-documentation job to build and generate docs with caching and npm v10; added deploy-docs-pages job to publish docs to GitHub Pages on semantic version tags.
packages/xrpl/HISTORY.md Added an entry documenting the new GitHub Actions step for automated documentation generation.

Possibly related PRs

Poem

🐇 Hopping through code with a joyful cheer,
Docs now build and deploy, crystal clear!
Two new jobs dance in the CI light,
Making sure our pages take flight.
With every commit, the future’s bright! 🌟📚


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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.

@khancode khancode requested review from Patel-Raj and khancode April 9, 2025 16:11
- run: npm run build

- name: Generate Documentation
run: npm run docgen
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for this PR! I think this will just make sure that docgen runs. js.xrpl.org still picks up the files from /docs folder of the main branch. Can you try this suggestion to publish a site from generated artifacts of CI pipeline?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks. I have updated the code here: 2ed20e1

I'm not able to test the "deploy" step via the workflow. Github does not allow me to deploy from non-main branch. Do you have any ideas on how we can fix that?

The generated artifact looks correct to me, I have handpicked some of the files and verified it's contents.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can try merging ckeshava:genDocs branch in your fork's main branch and see if the GitHub Pages is deployed or not.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have not configured Github Pages website to deploy the documentation ://

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since the generated documentation artifacts are correct (pending PR reviewers approval), only the "deploy-pages" could fail with an unknown error. However, this does not place incorrect docs in the public domain. The only risk is that the docs are not in-sync with the main branch.

In case of such an unknown error, we will need to propose a fix PR and merge that into the main branch.

What do you think of this method?

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/nodejs.yml (1)

198-246: New Documentation Generation Job – Validate Build and Docgen Steps

The addition of the generate-documentation job is a solid approach to automate documentation generation on every commit. A few points to verify:

  • Command Accuracy: Ensure that npm run docgen correctly builds the documentation into the expected docs/ directory. Verify that the build step (npm run build) preceding it is necessary for the doc generation or if it could be omitted to speed up the workflow.
  • Caching & Environment: The reuse of Node.js setup, npm version 10, and caching configurations is consistent with other jobs. This promotes consistency across your CI jobs.

If the build step isn’t required for generating documentation, consider removing it to reduce execution time.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 494ad82 and 9e00a7f.

📒 Files selected for processing (1)
  • .github/workflows/nodejs.yml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: integration (22.x)
  • GitHub Check: browser (18.x)
  • GitHub Check: integration (20.x)
  • GitHub Check: integration (18.x)
🔇 Additional comments (1)
.github/workflows/nodejs.yml (1)

247-257:

❓ Verification inconclusive

Deploy Job – Verify Environment URL Output Reference

The deploy job specifies an environment URL as

url: ${{ steps.docs-artifact.outputs.page_url }}

However, please ensure that:

  • The actions/deploy-pages@v4 step (with id docs-artifact) properly produces an output named page_url.
  • If the intended URL comes from the output of the generate-documentation job, you may need to propagate that value as a job output (e.g., via needs.generate-documentation.outputs) rather than referencing a step in the current deploy job.

This misreference might result in an undefined URL for the GitHub Pages environment. Please verify that the expected output is available when the deploy job starts executing.


Action Required: Verify the Environment URL Source

Please double-check that the deploy job’s reference for the environment URL—

url: ${{ steps.docs-artifact.outputs.page_url }}

—correctly points to a valid output. In particular:

  • Confirm that the actions/deploy-pages@v4 step (with id docs-artifact) indeed produces an output named page_url. According to its documentation, it should provide this output, but it's worth verifying in your specific context.
  • If the intended URL should come from the generate-documentation job instead, consider propagating that value as a job output (e.g., using needs.generate-documentation.outputs.page_url) and update the reference accordingly.

Please review the current configuration in the workflow to ensure the URL is defined as expected when the deploy job starts executing.

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/nodejs.yml (1)

247-259: Deployment to GitHub Pages from artifact is correct and addresses previous feedback.

The deploy job correctly depends on the documentation artifact and deploys it to GitHub Pages only on the main branch. This resolves the concern from the previous review about deploying from CI artifacts rather than the /docs folder directly. The use of actions/deploy-pages@v4 is appropriate.

Nitpick: For clarity, consider renaming the step to "Deploy Documentation to GitHub Pages" (add "Documentation") to make the workflow intent even clearer.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9e00a7f and af04fb0.

📒 Files selected for processing (1)
  • .github/workflows/nodejs.yml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: snippets (22.x)
  • GitHub Check: snippets (18.x)
  • GitHub Check: integration (18.x)
  • GitHub Check: snippets (20.x)
  • GitHub Check: browser (18.x)
🔇 Additional comments (1)
.github/workflows/nodejs.yml (1)

198-246: Automated documentation generation and artifact upload are well-implemented.

The generate-documentation job follows best practices for CI: it builds, generates docs, and uploads them as an artifact for deployment. This approach is robust and aligns with GitHub's recommendations for Pages deployments from CI artifacts.

- name: Generate Documentation
run: npm run docgen

- name: Upload documentation files as artifact
Copy link
Collaborator

Choose a reason for hiding this comment

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

It doesn't look like this PR actually commits the docs changes to the repo

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, that is true.

Additionally, the settings of this repository will be updated. Documentation will be deployed from Github Actions, instead of reading from the docs/ folder (this is the existing behavior)

This PR proposes a different way of deploying the documentation. docs/ folder is obviated by the Github Actions workflow.

@ckeshava
Copy link
Collaborator Author

@Patel-Raj Thanks for investigating the deployment of Github Pages! It was very helpful. I have added your suggestions in 9c885f5

runs-on: ubuntu-latest
needs: generate-documentation
# Deploy docs only pushes into the main branch
if: success() && github.ref == 'refs/heads/main'
Copy link
Collaborator

@mvadari mvadari Apr 15, 2025

Choose a reason for hiding this comment

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

This should be run on a new published (non-beta) version, not on every commit

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  1. On the documentation website, I don't observe a menu of various versions. Usually, softwares allow users to select a version before viewing the relevant docs. Does this need to be configure for Typedoc/Github Pages?

  2. I agree with your point:

This should be run on a new published (non-beta) version, not on every commit

However, is there any harm in publishing the docs on every commit? (Provided we specify the necessary disclaimers to the users) ?

Especially, if we don't have the infrastructure to render versioned-documentation, I believe its good to keep the docs fresh.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This should be run on a new published (non-beta) version, not on every commit

If you feel strongly about it, I can accomplish this with modifications to the if-condition.

Copy link
Collaborator

Choose a reason for hiding this comment

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

However, is there any harm in publishing the docs on every commit? (Provided we specify the necessary disclaimers to the users) ?

It'll be a lot more confusing if users think there's a feature out because the documentation says so, but it's not released.

We don't necessarily need to have the infra for versioned documentation (though we could try to set something up with readthedocs), but the trigger of this action could just be changed to be on a non-beta tag instead, for example.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok. updated in 70d8ced

@ckeshava
Copy link
Collaborator Author

@khancode Please review this PR at a convenient time.

@ckeshava ckeshava requested a review from mvadari April 21, 2025 19:51
@khancode khancode requested a review from pdp2121 April 23, 2025 16:09
@ckeshava
Copy link
Collaborator Author

@khancode @pdp2121 can one of you review this PR?

@Patel-Raj can you please review this PR again?


strategy:
matrix:
node-version: [18.x]
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should use 22 here since node 18 maintenance cycle ended last month

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok fecab1e

We need to upgrade the dev-dependencies into Node v20 (or) v22. However, dependendabot should alert us about that package.

if: steps.cache-nodemodules.outputs.cache-hit != 'true'
run: npm ci

- run: npm run build
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably should have a name for build

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This step is a part of a job titled generate-documentation. Since I'm not referencing this step anywhere else in the workflow file, I did not add a title. Do you feel strongly about it?

Copy link
Collaborator

@pdp2121 pdp2121 left a comment

Choose a reason for hiding this comment

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

LGTM other than those small changes

@ckeshava
Copy link
Collaborator Author

ckeshava commented May 1, 2025

@Patel-Raj can you please re-review with your alternate github handle?

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

♻️ Duplicate comments (1)
.github/workflows/nodejs.yml (1)

249-272: ⚠️ Potential issue

Critical: Deployment condition prevents any publishing.
The deploy-docs-pages job is gated by if: success() && github.ref == 'refs/heads/main', so on tag pushes (where you want to release docs) it never runs—and on branch pushes the semantic tag check never passes. As a result, docs will never be deployed.

Proposed fix:

-    if: success() && github.ref == 'refs/heads/main'
+    # Only deploy on semantic version tags
+    if: success() && startsWith(github.ref, 'refs/tags/v')
🧹 Nitpick comments (1)
.github/workflows/nodejs.yml (1)

200-248: New documentation generation job.
Great addition of the generate-documentation job. It installs Node.js/npm, builds the project, runs npm run docgen, and uploads the docs/ folder as an artifact.

  • Please confirm that npm run docgen indeed outputs to docs/.
  • Verify that actions/upload-pages-artifact@v3 is the correct action for storing documentation artifacts.
    Optionally, consider adding a job-level name: for improved readability in the UI.
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7aa8b29 and fecab1e.

📒 Files selected for processing (1)
  • .github/workflows/nodejs.yml (6 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: mvadari
PR: XRPLF/xrpl.js#2788
File: .github/workflows/nodejs.yml:25-25
Timestamp: 2024-09-26T21:14:56.813Z
Learning: In `.github/workflows/nodejs.yml`, the `build-and-lint` job's actions `actions/setup-node` and `actions/cache` are updated to `@v4`.
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: snippets (20.x)
  • GitHub Check: snippets (22.x)
  • GitHub Check: integration (22.x)
  • GitHub Check: browser (22.x)
  • GitHub Check: integration (20.x)
🔇 Additional comments (6)
.github/workflows/nodejs.yml (6)

11-13: Verify trigger configuration covers intended events.
The workflow now runs on pushes to main and all tag references ('**'). Ensure you intend to generate artifacts on every tag (including non-semantic tags) and that pull requests don’t require documentation previews. If you only want to deploy on semantic version tags, consider narrowing the tag filter (e.g., v*.*.*).


24-24: Update build-and-lint matrix to Node.js 22.x.
Node.js v18 has been removed from the build-and-lint job matrix, pinning this job to 22.x only, which aligns with current LTS support.


64-64: Update unit test matrix to Node.js 20.x and 22.x.
The unit job now runs on Node.js 20.x and 22.x, removing deprecated v18 and ensuring broad LTS coverage.


104-104: Align integration tests with active Node.js versions.
Integration tests now run on Node.js 20.x and 22.x, matching the unit test matrix to avoid environment drift.


155-155: Pin browser tests to Node.js 22.x.
The browser job has been reduced to Node.js 22.x only, as Node 18 maintenance has ended. This satisfies past feedback to drop older versions.


279-279: Update snippets job matrix to Node.js 20.x and 22.x.
The snippets job now aligns with others by removing Node.js 18, ensuring consistency across CI.

@Patel-Raj11 Patel-Raj11 self-requested a review May 1, 2025 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants