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

(Windows) build issues and contributing docs #1458

Merged
merged 10 commits into from
May 26, 2024

Conversation

WimTibackx
Copy link

I noticed some Windows-specific build failures and some gaps in the CONTRIBUTING.md docs.

I have the PR currently in draft mode because I am still doing some more checks on the tests, and I have yet to check the publishing. Felt it was sufficient to start opening it up to review, though.

I'd be happy to provide more details as needed.

This PR addresses the following:

  • Note that PNPM version currently used is version 8.x, not last version

I haven't verified yet whether PNPM 9.x works, but I figured it might be useful to specify the version reflected by the lockFileVersion. This part isn't really Windows specific, I hadn't really caught on to the Windows-specificness of my issues yet at this point :) .

  • For windows users, document that git setting core.symlinks should be true

The symlinks in use in the repo don't work out of the box on Windows, but require a bit of Windows settings fiddling and git settings fiddling.

  • Enforce the line endings as they are currently in use in the repo

This avoids Windows users executing pnpm build or adding new files and thereby introducing inconsistent line endings. Current settings in .gitattributes indicate that everything but .bat files use LF. I'm not sure whether the .bat file specifically has to be CRLF, but given that it's currently the case I assumed it would have to be.
I ran git add --update --normalize to verify line endings, but all current files match this configuration.

  • Make script arguments in package.json files play more nicely with Windows

Single quotes are a bit of an issue, unfortunately.
In glob-style arguments I replaced the single quotes with escaped double quotes - which are already in use in some glob-style arguments.
For the pack-destination param I removed the quotes, as some package.jsons already have that param without quotes - so I presumed it to be safe.

  • Execute the correct gradlew script for the current OS

I added a dependency on run-script-os for this. This seems like a fairly sensible and lightweight way to handle it.

  • Non-Windows specific: document that a postgres database is used in some tests and should be available for contributors executing tests.

  • Non-Windows specific: introduce environment variables to override default postgres connection details in integration tests.

In my case, I wanted to use a user other than the default postgres user, so I could have a bit more fine-grained control to the integration tests user. And honestly, so I wouldn't inadvertedly change the password to my root user and break my tests setup.
This would also allow development on a local system, with postgres running within docker or setups like that.

  • Ensure Windows paths are correctly handled in tests

Added some path normalization, because current processing was resulting in incorrect paths.

Copy link
Contributor

coderabbitai bot commented May 18, 2024

Walkthrough

Walkthrough

The recent updates bring significant enhancements to the project. Notably, improvements include the addition of a .gitattributes file for text file handling, updates in CONTRIBUTING.md for environment setup guidance, and changes in testtools package files like db.ts and schema.ts to utilize environment variables for configuration flexibility and path normalization.

Changes

File/Path Summary
.gitattributes Introduces configurations for text file attributes and end-of-line settings.
CONTRIBUTING.md Specifies Node.js and pnpm versions, adds PostgreSQL setup instructions, and provides Windows symlink guidance.
packages/testtools/src/db.ts Updates to use environment variables for database connection, introduces connect() function for dynamic pooling.
packages/testtools/src/schema.ts Modifies loadSchema function to normalize file paths during schema loading.

Tip

New Features and Improvements

Review Settings

Introduced new personality profiles for code reviews. Users can now select between "Chill" and "Assertive" review tones to tailor feedback styles according to their preferences. The "Assertive" profile posts more comments and nitpicks the code more aggressively, while the "Chill" profile is more relaxed and posts fewer comments.

AST-based Instructions

CodeRabbit offers customizing reviews based on the Abstract Syntax Tree (AST) pattern matching. Read more about AST-based instructions in the documentation.

Community-driven AST-based Rules

We are kicking off a community-driven initiative to create and share AST-based rules. Users can now contribute their AST-based rules to detect security vulnerabilities, code smells, and anti-patterns. Please see the ast-grep-essentials repository for more information.

New Static Analysis Tools

We are continually expanding our support for static analysis tools. We have added support for biome, hadolint, and ast-grep. Update the settings in your .coderabbit.yaml file or head over to the settings page to enable or disable the tools you want to use.

Tone Settings

Users can now customize CodeRabbit to review code in the style of their favorite characters or personalities. Here are some of our favorite examples:

  • Mr. T: "You must talk like Mr. T in all your code reviews. I pity the fool who doesn't!"
  • Pirate: "Arr, matey! Ye must talk like a pirate in all yer code reviews. Yarrr!"
  • Snarky: "You must be snarky in all your code reviews. Snark, snark, snark!"

Revamped Settings Page

We have redesigned the settings page for a more intuitive layout, enabling users to find and adjust settings quickly. This change was long overdue; it not only improves the user experience but also allows our development team to add more settings in the future with ease. Going forward, the changes to .coderabbit.yaml will be reflected in the settings page, and vice versa.

Miscellaneous

  • Turn off free summarization: You can switch off free summarization of PRs opened by users not on a paid plan using the enable_free_tier setting.
  • Knowledge-base scope: You can now set the scope of the knowledge base to either the repository (local) or the organization (global) level using the knowledge_base setting. In addition, you can specify Jira project keys and Linear team keys to limit the knowledge base scope for those integrations.
  • High-level summary placement: You can now customize the location of the high-level summary in the PR description using the high_level_summary_placeholder setting (default @coderabbitai summary).
  • Revamped request changes workflow: You can now configure CodeRabbit to auto-approve or request changes on PRs based on the review feedback using the request_changes_workflow setting.

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:

Note: Auto-reply has been disabled for this repository by the repository owner. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

@WimTibackx
Copy link
Author

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented May 18, 2024

Actions Performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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: 2

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 29962e0 and c7a82d5.
Files ignored due to path filters (9)
  • packages/ide/jetbrains/package.json is excluded by !**/*.json
  • packages/language/package.json is excluded by !**/*.json
  • packages/plugins/trpc/package.json is excluded by !**/*.json
  • packages/runtime/package.json is excluded by !**/*.json
  • packages/schema/package.json is excluded by !**/*.json
  • packages/sdk/package.json is excluded by !**/*.json
  • packages/server/package.json is excluded by !**/*.json
  • packages/testtools/package.json is excluded by !**/*.json
  • pnpm-lock.yaml is excluded by !pnpm-lock.yaml, !**/*.yaml
Files selected for processing (4)
  • .gitattributes (1 hunks)
  • CONTRIBUTING.md (1 hunks)
  • packages/testtools/src/db.ts (1 hunks)
  • packages/testtools/src/schema.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • .gitattributes
Additional Context Used
LanguageTool (7)
CONTRIBUTING.md (7)

Near line 12: Loose punctuation mark.
Context: ...stcommands. -ZENSTACK_TEST_DB_USER`: The postgres username, for a user with ...


Near line 13: Loose punctuation mark.
Context: ...t: postgres. - ZENSTACK_TEST_DB_PASS: Password for said user. Default: `abc12...


Near line 14: Loose punctuation mark.
Context: ...ult: abc123. - ZENSTACK_TEST_DB_NAME: Default database to connect onto. This ...


Near line 15: Loose punctuation mark.
Context: ...t: postgres. - ZENSTACK_TEST_DB_HOST: Hostname or IP to connect onto. Default...


Near line 16: Loose punctuation mark.
Context: ...: localhost. - ZENSTACK_TEST_DB_PORT: Port number to connect onto. Default: `...


Near line 68: As an alternative to the over-used intensifier ‘very’, consider replacing this phrase.
Context: ...# Development workflow ZenStack adopts a very simple development workflow: 1. Changes shou...


Near line 98: A comma may be missing after the conjunctive/linking adverb ‘Currently’.
Context: ... routes in a framework-independent way. Currently supports "rpc" and "rest" styles. 1. F...

Additional comments not posted (5)
packages/testtools/src/db.ts (2)

3-7: Environment variable usage enhances configuration flexibility and security.


9-17: Centralizing database connection logic in connect() enhances maintainability and reusability.

CONTRIBUTING.md (2)

8-16: Updated prerequisites section accurately specifies the required pnpm version and details for setting up a PostgreSQL database.


20-25: Clear instructions for configuring Git to handle symlinks on Windows.

packages/testtools/src/schema.ts (1)

175-175: Path normalization in loadSchema ensures compatibility across different operating systems.

packages/testtools/src/db.ts Outdated Show resolved Hide resolved
packages/testtools/src/db.ts Show resolved Hide resolved
@WimTibackx
Copy link
Author

As for the local publishing workflow, the suggestion in CONTRIBUTING.md to use Verdaccio seemed interesting to me so I tried it out. Two things I noted here:

  • The CONTRIBUTING.md points to publish-preview being set up to publish to a local Verdaccio instance, but this no longer seems to be the case.
  • When I manually ran more or less the same script but actually pointing to my local Verdaccio I bumped into the npm policy of not allowing republishes of the same version number. The package.jsons are currently on 2.1.1 which is an actually publically existing version number that I had probably pulled in via Verdaccio already; and so I couldn't publish that same version locally.

What I ended up doing was to first bump the package.json versions locally, and then publish with that:

pnpm -r exec pnpm version prerelease --no-git-tag-version && pnpm --filter "./packages/**" -r publish

This way, I could then install the prerelease version in my actual project and see my changes.
What's the current workflow you all are using for local development? Am I doing something wrong here, or is everyone using the linking workflow for local development?

…t usage of symlinks, which requires extra steps on Windows.
Running `pnpm build` on windows builds generated files with CRLF line endings. Adding the `eol=lf` entry in the `.gitattributes` file enforces LF line endings when files are staged, so line ending changes on those generated files are negated / ignored.

Furthermore, this ensures consistency on newly added files.
…ripts; and remove single quotes when we don't need them. This improves windows compatibility.
…nfiguring connection details through environment variables to allow slightly more flexibility.
@WimTibackx WimTibackx marked this pull request as ready for review May 24, 2024 13:57
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: 0

Outside diff range and nitpick comments (1)
CONTRIBUTING.md (1)

Line range hint 68-68: Consider using a less subjective description than "very simple" for the development workflow to maintain professional tone.

- ZenStack adopts a very simple development workflow:
+ ZenStack adopts a straightforward development workflow:
Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between c7a82d5 and 38623d5.
Files ignored due to path filters (9)
  • packages/ide/jetbrains/package.json is excluded by !**/*.json
  • packages/language/package.json is excluded by !**/*.json
  • packages/plugins/trpc/package.json is excluded by !**/*.json
  • packages/runtime/package.json is excluded by !**/*.json
  • packages/schema/package.json is excluded by !**/*.json
  • packages/sdk/package.json is excluded by !**/*.json
  • packages/server/package.json is excluded by !**/*.json
  • packages/testtools/package.json is excluded by !**/*.json
  • pnpm-lock.yaml is excluded by !pnpm-lock.yaml, !**/*.yaml
Files selected for processing (3)
  • .gitattributes (1 hunks)
  • CONTRIBUTING.md (1 hunks)
  • packages/testtools/src/db.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • .gitattributes
Additional Context Used
LanguageTool (7)
CONTRIBUTING.md (7)

Near line 12: Loose punctuation mark.
Context: ...stcommands. -ZENSTACK_TEST_DB_USER`: The postgres username, for a user with ...


Near line 13: Loose punctuation mark.
Context: ...t: postgres. - ZENSTACK_TEST_DB_PASS: Password for said user. Default: `abc12...


Near line 14: Loose punctuation mark.
Context: ...ult: abc123. - ZENSTACK_TEST_DB_NAME: Default database to connect onto. This ...


Near line 15: Loose punctuation mark.
Context: ...t: postgres. - ZENSTACK_TEST_DB_HOST: Hostname or IP to connect onto. Default...


Near line 16: Loose punctuation mark.
Context: ...: localhost. - ZENSTACK_TEST_DB_PORT: Port number to connect onto. Default: `...


Near line 68: As an alternative to the over-used intensifier ‘very’, consider replacing this phrase.
Context: ...# Development workflow ZenStack adopts a very simple development workflow: 1. Changes shou...


Near line 98: A comma may be missing after the conjunctive/linking adverb ‘Currently’.
Context: ... routes in a framework-independent way. Currently supports "rpc" and "rest" styles. 1. F...

Markdownlint (1)
CONTRIBUTING.md (1)

120: null
Bare URL used

Biome (1)
packages/testtools/src/db.ts (1)

7-7: Use Number.parseInt instead of the equivalent global.

Additional comments not posted (6)
packages/testtools/src/db.ts (4)

3-7: The use of environment variables for database configuration enhances flexibility and aligns with best practices.


9-17: Centralizing database connection settings in the connect function is a clean and maintainable approach.


20-24: Proper management of the database connection pool in createPostgresDb function, including appropriate cleanup, is well implemented.


28-30: Good practice in managing the database connection pool in dropPostgresDb function, ensuring resources are properly released.

CONTRIBUTING.md (2)

8-16: Updating the prerequisites with specific version requirements and detailed setup instructions for PostgreSQL enhances clarity for new contributors.


20-25: Clear instructions for setting up symlinks on Windows, including a useful external reference, will aid Windows users in setting up their development environment correctly.

packages/testtools/src/db.ts Dismissed Show dismissed Hide dismissed
packages/testtools/src/db.ts Dismissed Show dismissed Hide dismissed
Copy link
Member

@jiashengguo jiashengguo left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks for working on it!

packages/testtools/src/schema.ts Outdated Show resolved Hide resolved
packages/testtools/src/schema.ts Outdated Show resolved Hide resolved
@jiashengguo jiashengguo merged commit aade41d into zenstackhq:dev May 26, 2024
13 checks passed
@WimTibackx WimTibackx deleted the contributing-docs branch May 26, 2024 03:41
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.

None yet

2 participants