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

Check published types in CI #1702

Merged
merged 2 commits into from
Mar 2, 2025
Merged

Check published types in CI #1702

merged 2 commits into from
Mar 2, 2025

Conversation

alexeyr-ci
Copy link
Collaborator

@alexeyr-ci alexeyr-ci commented Mar 2, 2025

Summary

Add additional checks for package.json issues in CI.

Pull Request checklist

- [ ] Add/update test to cover these changes
- [ ] Update documentation

  • Update CHANGELOG file

This change is Reviewable

Summary by CodeRabbit

  • Chores
    • Enhanced the code quality checks by integrating a new linting step for package publishing in the automation workflow.
    • Updated the package’s primary entry point to streamline its consumption.
    • Refined dependency management by removing redundant packages and updating development dependencies for improved compatibility.
    • Added a new development dependency for enhanced tooling in the development environment.

Copy link
Contributor

coderabbitai bot commented Mar 2, 2025

Warning

Rate limit exceeded

@alexeyr-ci has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 21 minutes and 0 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between ff8b4d8 and b44f32d.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (1)
  • .github/workflows/lint-js-and-ruby.yml (1 hunks)

Walkthrough

This pull request introduces a new job step called "Lint package publishing" in the GitHub Actions workflow for linting JavaScript and Ruby. It updates the package configuration by changing the main entry point in package.json, adding a development dependency, and modifying a script to remove an outdated package. The new linting step executes the attw command with specific options and is integrated seamlessly into the workflow.

Changes

Files Change Summary
.github/workflows/lint-js-and-ruby.yml Added a new job step "Lint package publishing" after the "Type-check TypeScript" step, running the attw command with --pack and --profile options.
package.json Updated the "main" entry point from "node_package/lib/ReactOnRails.js" to "node_package/lib/ReactOnRails.full.js". A new development dependency "@arethetypeswrong/cli": "^0.17.4" was also added.
script/convert Updated comments regarding the removal of the "knip" package and added a line to remove the "@arethetypeswrong/cli" package from package.json.
knip.ts Added @arethetypeswrong/cli to the ignoreDependencies array in the config object.

Suggested reviewers

  • Judahmeek

Possibly related PRs

  • TypeScript cleanup #1651: The changes in the main PR, which add a new linting step for JavaScript and Ruby, are related to the retrieved PR as both involve enhancements to the linting process, specifically integrating TypeScript type-checking into the CI workflow.
  • Fix problems with GitHub actions #1691: The changes in the main PR, which add a new linting step in the GitHub Actions workflow, are directly related to the modifications in the retrieved PR that also enhance the GitHub Actions workflow by introducing Actionlint and improving error handling.
  • Detect dead code and unused dependencies #1687: The changes in the main PR, specifically the addition of the "Lint package publishing" step in the GitHub Actions workflow, are related to the modifications in the retrieved PR that also involve the integration of the Knip tool for detecting dead code and unused dependencies.

Poem

I'm a rabbit in code so new,
Hopping over tests, it's true,
With a skip and a bound,
New steps are found,
Linting and publishing in a joyful view.
🐇♪


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.
  • @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
Contributor

@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 UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 35a6aae and 8e4c86b.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (3)
  • .github/workflows/lint-js-and-ruby.yml (1 hunks)
  • package.json (2 hunks)
  • script/convert (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
package.json (1)
Learnt from: Romex91
PR: shakacode/react_on_rails#1697
File: package-scripts.yml:28-28
Timestamp: 2025-02-12T16:38:06.537Z
Learning: The file `node_package/lib/ReactOnRails.full.js` is autogenerated during the build process and should not be present in the repository.
🪛 GitHub Actions: Lint JS and Ruby
script/convert

[warning] 20-20: Rubocop: [Correctable] Style/RegexpLiteral: Use %r around regular expression.

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: rspec-package-tests (newest)
  • GitHub Check: build-dummy-app-webpack-test-bundles (newest)
  • GitHub Check: rspec-package-tests (oldest)
  • GitHub Check: build-dummy-app-webpack-test-bundles (oldest)
🔇 Additional comments (3)
.github/workflows/lint-js-and-ruby.yml (1)

90-95: LGTM! Good addition of type checking for published packages.

The new "Lint package publishing" step using attw is a valuable addition to ensure type correctness in the published package. The comments clearly explain why you're using the Node16 profile and ignoring certain CJS export rules, along with a plan to address this in version 15.0.0.

package.json (2)

5-5: Verify if using ReactOnRails.full.js as main entry point is correct.

According to previous feedback (PR #1697), the file node_package/lib/ReactOnRails.full.js is autogenerated during the build process and should not be present in the repository. This raises questions about whether it's appropriate to set it as the main entry point.

Since the exports field already references this file as the default export (line 9), is changing the main field necessary? Consider whether this might cause issues with bundlers or importers that don't yet support the exports field.


17-17: LGTM! Added dependency to support type checking in CI.

Adding @arethetypeswrong/cli as a dev dependency supports the new "Lint package publishing" step in the CI workflow, which aligns with the PR's goal of checking published types.

script/convert Outdated
Comment on lines 18 to 20
# The below packages don't work on the oldest supported Node version and aren't needed there anyway
gsub_file_content("../package.json", /"knip": "[^"]*",/, "")
gsub_file_content("../package.json", /"@arethetypeswrong\/cli": "[^"]*",/, "")
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix the regular expression style to follow Rubocop guidelines.

The regular expression at line 20 should use the %r notation as suggested by the Rubocop warning.

- gsub_file_content("../package.json", /"@arethetypeswrong\/cli": "[^"]*",/, "")
+ gsub_file_content("../package.json", %r{"@arethetypeswrong/cli": "[^"]*",}, "")

The purpose of this line is clear - it removes the @arethetypeswrong/cli package during conversion to support older Node versions, as explained in the comment.

📝 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
# The below packages don't work on the oldest supported Node version and aren't needed there anyway
gsub_file_content("../package.json", /"knip": "[^"]*",/, "")
gsub_file_content("../package.json", /"@arethetypeswrong\/cli": "[^"]*",/, "")
# The below packages don't work on the oldest supported Node version and aren't needed there anyway
gsub_file_content("../package.json", /"knip": "[^"]*",/, "")
gsub_file_content("../package.json", %r{"@arethetypeswrong/cli": "[^"]*",}, "")
🧰 Tools
🪛 GitHub Actions: Lint JS and Ruby

[warning] 20-20: Rubocop: [Correctable] Style/RegexpLiteral: Use %r around regular expression.

@alexeyr-ci alexeyr-ci force-pushed the alexeyr/attw-publint branch 3 times, most recently from 0b44d4f to 2e3a0eb Compare March 2, 2025 09:13
@alexeyr-ci alexeyr-ci force-pushed the alexeyr/attw-publint branch from 2e3a0eb to ff8b4d8 Compare March 2, 2025 09:20
Comment on lines +92 to +93
# --ignore-rules CJS default export can't be resolved at the moment,
# revisit in 15.0.0
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually, maybe we could fix it by using Babel to compile TS instead of TSC. I'm not sure it's worth the effort at the moment.

@alexeyr-ci alexeyr-ci force-pushed the alexeyr/attw-publint branch from 8ce19a6 to 83f8820 Compare March 2, 2025 09:25
@@ -2,7 +2,7 @@
"name": "react-on-rails",
"version": "14.1.1",
"description": "react-on-rails JavaScript for react_on_rails Ruby gem",
"main": "node_package/lib/ReactOnRails.js",
"main": "node_package/lib/ReactOnRails.full.js",
Copy link
Collaborator Author

@alexeyr-ci alexeyr-ci Mar 2, 2025

Choose a reason for hiding this comment

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

We don't have that file anymore.

@alexeyr-ci alexeyr-ci requested a review from Judahmeek March 2, 2025 09:27
@alexeyr-ci alexeyr-ci force-pushed the alexeyr/attw-publint branch from 83f8820 to b44f32d Compare March 2, 2025 09:28
@@ -87,6 +87,11 @@ jobs:
run: yarn start format.listDifferent
- name: Type-check TypeScript
run: yarn run type-check
- name: Lint package publishing
# --profile because we don't care about node10
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Resolving ReactOnRails/client under --moduleResolution node is technically possible, but better just to tell people to update their TS config. It isn't a breaking change because nobody needed to resolve it before (and the other change fixes resolution for ReactOnRails itself).

@Judahmeek Judahmeek merged commit 987dbb1 into master Mar 2, 2025
11 checks passed
@Judahmeek Judahmeek deleted the alexeyr/attw-publint branch March 2, 2025 19:55
@coderabbitai coderabbitai bot mentioned this pull request Mar 10, 2025
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.

3 participants