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

Fix: Extract the correct SDK version during build #1530

Merged
merged 3 commits into from
Dec 3, 2024
Merged

Conversation

nicktrn
Copy link
Collaborator

@nicktrn nicktrn commented Dec 3, 2024

Summary by CodeRabbit

Release Notes

  • New Features

    • Added "CLI Version" display in deployment details for enhanced visibility.
    • Integrated SDK version extraction into the build process for better version management.
  • Bug Fixes

    • Updated SDK version in the build manifest to ensure compatibility.
  • Refactor

    • Enhanced the DeploymentPresenter to include CLI version in deployment responses.
  • Chores

    • Updated plugin handling in the build worker to streamline SDK version integration.

Copy link

changeset-bot bot commented Dec 3, 2024

🦋 Changeset detected

Latest commit: 0e2b2c2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
trigger.dev Patch
@trigger.dev/build Patch
@trigger.dev/core Patch
@trigger.dev/react-hooks Patch
@trigger.dev/rsc Patch
@trigger.dev/sdk Patch
@trigger.dev/database Patch
@trigger.dev/otlp-importer Patch
@internal/redis-worker Patch
@internal/zod-worker Patch
@internal/testcontainers Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

coderabbitai bot commented Dec 3, 2024

Walkthrough

This pull request updates the SDK version in the build manifest and introduces enhancements to the DeploymentPresenter class and related components. The changes include adding a cliVersion property to the deployment data model and the UI, as well as implementing an SdkVersionExtractor class to manage SDK version extraction within the build process. These modifications collectively improve the handling of SDK versioning and deployment details without altering existing logic or error handling.

Changes

File Change Summary
.changeset/fuzzy-doors-know.md Updated SDK version in the build manifest.
apps/webapp/app/presenters/v3/DeploymentPresenter.server.ts Added cliVersion property to findUniqueOrThrow method and returned in the call method.
apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.v3.$projectParam.deployments.$deploymentParam/route.tsx Added "CLI Version" entry to deployment details, conditionally displaying the cliVersion.
packages/cli-v3/src/build/buildWorker.ts Added SdkVersionExtractor import, modified buildManifest to use sdkVersionExtractor.sdkVersion.
packages/cli-v3/src/build/plugins.ts Introduced SdkVersionExtractor class with methods for extracting and managing SDK version dynamically.

Possibly related PRs

🐰 In the meadow, where code does play,
A new version hops in, brightening the day.
With CLI and SDK, together they dance,
Enhancing our builds, giving progress a chance.
So let’s cheer for the changes, let’s give them a shout,
For a better tomorrow, there’s no doubt! 🌼

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/webapp/app/presenters/v3/DeploymentPresenter.server.ts

Oops! Something went wrong! :(

ESLint: 8.45.0

ESLint couldn't find the config "custom" to extend from. Please check that the name of the config is correct.

The config "custom" was referenced from the config file in "/.eslintrc.js".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.


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

🧹 Outside diff range and nitpick comments (1)
packages/cli-v3/src/build/plugins.ts (1)

95-184: Consider adding unit tests for SdkVersionExtractor

To ensure reliability and facilitate future maintenance, consider adding unit tests for the SdkVersionExtractor class. Testing scenarios should include:

  • Successful extraction of the SDK version.
  • Handling cases where the package is not found.
  • Situations where the package does not have the expected name or version.
  • Error conditions during file reading or JSON parsing.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between cf7dc8d and 0e2b2c2.

📒 Files selected for processing (5)
  • .changeset/fuzzy-doors-know.md (1 hunks)
  • apps/webapp/app/presenters/v3/DeploymentPresenter.server.ts (2 hunks)
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.v3.$projectParam.deployments.$deploymentParam/route.tsx (1 hunks)
  • packages/cli-v3/src/build/buildWorker.ts (4 hunks)
  • packages/cli-v3/src/build/plugins.ts (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/fuzzy-doors-know.md
🔇 Additional comments (7)
packages/cli-v3/src/build/plugins.ts (2)

7-10: Approved the addition of necessary imports

The new imports for esmResolveSync, readPackageJSON, resolvePackageJSON, dirname, and readJSONFile are appropriate and necessary for the functionality introduced in the SdkVersionExtractor class.


95-184: Implementation of SdkVersionExtractor class is well-structured

The SdkVersionExtractor class effectively encapsulates the logic for extracting the SDK version from the package. The use of an esbuild plugin to integrate this extraction into the build process is appropriate. Error handling and logging provide clarity during debugging.

apps/webapp/app/presenters/v3/DeploymentPresenter.server.ts (2)

111-111: Approved inclusion of cliVersion in worker selection

Including cliVersion in the worker selection ensures that the CLI version is retrieved alongside other relevant data.


149-149: Approved addition of cliVersion to deployment data

Adding cliVersion to the deployment object correctly exposes the CLI version in the response, enabling it to be used in the UI and other components.

packages/cli-v3/src/build/buildWorker.ts (2)

30-30: Integration of SdkVersionExtractor into build process is appropriate

The inclusion of SdkVersionExtractor and its plugin into the build process allows for dynamic extraction of the SDK version during the build. This enhancement is well-integrated and maintains the extensibility of the build system.

Also applies to: 65-66, 75-75


87-87: Approved setting packageVersion using extracted SDK version

Using sdkVersionExtractor.sdkVersion for packageVersion, with a fallback to CORE_VERSION, ensures that the build manifest reflects the correct SDK version. This approach maintains compatibility while dynamically incorporating version information.

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.v3.$projectParam.deployments.$deploymentParam/route.tsx (1)

154-157: Approved addition of CLI Version to deployment details

Displaying the CLI Version in the deployment details provides users with valuable information about the deployment environment. The implementation follows the existing pattern and handles the absence of cliVersion gracefully.

logger.debug("[SdkVersionExtractor] Extracting SDK version", { args });

try {
const resolvedPath = esmResolveSync(args.path, {
Copy link
Member

Choose a reason for hiding this comment

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

You'll need to dynamically require mlly or else the CLI won't build

Copy link
Member

Choose a reason for hiding this comment

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

Actually scratch that, it's not true. Leaving this here for self-shame reasons.

Copy link

pkg-pr-new bot commented Dec 3, 2024

@trigger.dev/build

npm i https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/build@1530

@trigger.dev/core

npm i https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/core@1530

@trigger.dev/react-hooks

npm i https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/react-hooks@1530

trigger.dev

npm i https://pkg.pr.new/triggerdotdev/trigger.dev@1530

@trigger.dev/sdk

npm i https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/sdk@1530

@trigger.dev/rsc

npm i https://pkg.pr.new/triggerdotdev/trigger.dev/@trigger.dev/rsc@1530

commit: 0e2b2c2

@nicktrn nicktrn changed the title Fix: extract the correct SDK version during build Fix: Extract the correct SDK version during build Dec 3, 2024
@nicktrn nicktrn merged commit cd7a451 into main Dec 3, 2024
9 checks passed
@nicktrn nicktrn deleted the fix/sdk-cli-versions branch December 3, 2024 10:00
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.

2 participants