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

Support ignoring test/spec files inside trigger dirs (fixes #1593) #1596

Merged
merged 2 commits into from
Jan 10, 2025

Conversation

ericallam
Copy link
Member

@ericallam ericallam commented Jan 10, 2025

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced configuration options for trigger.dev tasks, including project specification, directory configuration, and ignore patterns
    • Added support for custom instrumentations and build extensions
    • Introduced more flexible retry and logging configurations
  • Documentation

    • Updated configuration file documentation with new sections explaining task directory and file handling
    • Improved clarity on configuration options and their usage
  • Dependencies

    • Added chokidar and tinyglobby to support advanced file watching and globbing functionalities
  • Improvements

    • Streamlined build process with more robust entry point management
    • Enhanced file detection and exclusion mechanisms for tasks

Copy link

changeset-bot bot commented Jan 10, 2025

🦋 Changeset detected

Latest commit: b145274

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

This PR includes changesets to release 12 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
references-nextjs-realtime 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 Jan 10, 2025

Warning

Rate limit exceeded

@ericallam has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 28 minutes and 27 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 d01a9d2 and b145274.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (16)
  • .changeset/famous-grapes-film.md (1 hunks)
  • docs/config/config-file.mdx (1 hunks)
  • docs/mint.json (9 hunks)
  • packages/cli-v3/package.json (2 hunks)
  • packages/cli-v3/src/build/bundle.ts (4 hunks)
  • packages/cli-v3/src/build/entryPoints.ts (1 hunks)
  • packages/cli-v3/src/dev/devSession.ts (1 hunks)
  • packages/core/src/v3/config.ts (4 hunks)
  • references/nextjs-realtime/batchinput.jsonl (1 hunks)
  • references/nextjs-realtime/src/app/openai/page.tsx (1 hunks)
  • references/nextjs-realtime/src/components/BatchProgressIndicator.tsx (1 hunks)
  • references/nextjs-realtime/src/components/BatchSubmissionForm.tsx (1 hunks)
  • references/nextjs-realtime/src/components/ui/alert.tsx (1 hunks)
  • references/nextjs-realtime/src/components/ui/textarea.tsx (1 hunks)
  • references/nextjs-realtime/src/trigger/csv.ts (2 hunks)
  • references/nextjs-realtime/src/trigger/openaiBatch.ts (1 hunks)

Walkthrough

This pull request introduces enhancements to the configuration and build process for Trigger.dev, focusing on improving directory and file management. The changes include new configuration options for specifying task directories, adding ignore patterns, and implementing more robust entry point management during the build process. These modifications provide developers with greater flexibility in defining and processing task directories while introducing more sophisticated file watching and build capabilities.

Changes

File Change Summary
.changeset/famous-grapes-film.md Added support for ignoring test and specification files in trigger directories
docs/config/config-file.mdx Added new "Dirs" section documenting dirs and ignorePatterns configuration options
docs/mint.json Minor formatting adjustments to JSON structure
packages/cli-v3/package.json Added chokidar and tinyglobby dependencies
packages/cli-v3/src/build/bundle.ts Refactored entry point management with new createEntryPointManager and createBuildOptions functions
packages/cli-v3/src/build/entryPoints.ts Introduced createEntryPointManager for dynamic entry point handling
packages/core/src/v3/config.ts Added multiple new configuration properties and deprecated some existing ones

Sequence Diagram

sequenceDiagram
    participant Config as Trigger Config
    participant EntryPointManager as Entry Point Manager
    participant FileWatcher as Chokidar Watcher
    participant BuildProcess as Build Process

    Config->>EntryPointManager: Initialize with directories
    EntryPointManager->>FileWatcher: Set up file watching
    FileWatcher-->>EntryPointManager: Detect file changes
    EntryPointManager->>BuildProcess: Update entry points
    BuildProcess->>BuildProcess: Rebuild with new entry points
Loading

Possibly related PRs

Suggested reviewers

  • matt-aitken

Poem

🐰 Hop, hop, through trigger's grove,
Where files dance and configs rove,
Chokidar watches, globby gleams bright,
Ignoring tests with pure delight!
A build that's smart, a system clean,
In Trigger's world, where code convenes! 🚀


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

🧹 Nitpick comments (9)
references/nextjs-realtime/src/trigger/openaiBatch.ts (1)

24-24: Delete temporary files after use to prevent accumulation

The file batchinput.jsonl is written to disk but not deleted after upload. This could lead to accumulation of temporary files. Consider deleting the file once it's no longer needed.

Apply this diff to delete the file after uploading:

 const file = await openai.files.create({
   file: createReadStream(batchFilename),
   purpose: "batch",
 });

+unlinkSync(batchFilename);
 
 logger.log("Created file", { file });
 // ...
references/nextjs-realtime/src/trigger/csv.ts (1)

82-82: Consider using a more meaningful timeout duration.

The timeout duration of 1012 seems arbitrary. Consider using a round number like 1000 for better readability, or document why this specific duration was chosen.

-    await setTimeout(200 + Math.random() * 1012); // 200ms - 1.2s
+    await setTimeout(200 + Math.random() * 1000); // 200ms - 1.2s
references/nextjs-realtime/src/components/BatchSubmissionForm.tsx (1)

40-53: Enhance accessibility with ARIA attributes.

The textarea should have additional ARIA attributes for better screen reader support.

 <Textarea
   id="jsonl-input"
   value={jsonlContent}
   onChange={(e) => setJsonlContent(e.target.value)}
   placeholder="Paste your JSONL content here..."
   className="w-full h-48 p-2 text-sm bg-gray-50 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"
   required
+  aria-label="JSONL Content"
+  aria-describedby="jsonl-help"
 />
+<div id="jsonl-help" className="text-sm text-gray-500 mt-1">
+  Enter valid JSONL content with one JSON object per line
+</div>
packages/core/src/v3/config.ts (1)

33-50: Consider adding examples for ignorePatterns.

While the default patterns are well documented, it would be helpful to provide examples of custom ignore patterns.

   /**
    * Specify glob patterns to ignore when detecting task files. By default we ignore:
    *
    * - *.test.ts
    * - *.spec.ts
    * - *.test.mts
    * - *.spec.mts
    * - *.test.cts
    * - *.spec.cts
    * - *.test.js
    * - *.spec.js
    * - *.test.mjs
    * - *.spec.mjs
    * - *.test.cjs
    * - *.spec.cjs
+   * 
+   * @example
+   * ```ts
+   * ignorePatterns: [
+   *   "**/__tests__/**",
+   *   "**/*.mock.*"
+   * ]
+   * ```
    */
   ignorePatterns?: string[];
packages/cli-v3/src/dev/devSession.ts (1)

155-157: TODO comments need implementation.

The comments indicate planned functionality for entry point management using glob and chokidar, but the implementation is missing.

Would you like me to help create a GitHub issue to track the implementation of these features? I can provide a detailed implementation plan for:

  1. Using glob to find initial entry points
  2. Setting up chokidar for watching entry point changes
  3. Implementing the build update logic
references/nextjs-realtime/batchinput.jsonl (1)

1-20: Consider rate limiting implications.

While the JSONL structure is correct, submitting 20 concurrent requests might hit API rate limits. Consider adding a retry configuration or implementing request batching.

You could modify the requests to include rate limiting parameters:

 {
   "custom_id":"request-1",
   "method":"POST",
   "url":"/v1/chat/completions",
   "body":{
     "model":"gpt-3.5-turbo-0125",
     "messages":[...],
-    "max_tokens":150
+    "max_tokens":150,
+    "retry_settings": {
+      "max_retries": 3,
+      "initial_delay": 1000,
+      "max_delay": 10000
+    }
   }
 }
references/nextjs-realtime/src/components/BatchProgressIndicator.tsx (3)

26-37: Consider making the initial state configurable via props.

The component currently uses hardcoded values for the initial state. Consider accepting these values as props to make the component more reusable and testable.

-export default function BatchProgressIndicator() {
+interface BatchProgressIndicatorProps {
+  initialBatch?: Partial<BatchInfo>;
+}
+
+export default function BatchProgressIndicator({ 
+  initialBatch = {
+    id: "batch_abc123",
+    status: "in_progress",
+    totalRequests: 1000,
+    completedRequests: 750,
+    failedRequests: 10,
+    inputFileName: "input.jsonl",
+    outputFileName: null,
+    errorFileName: null,
+    createdAt: new Date().toISOString(),
+    completedAt: null,
+  }
+}: BatchProgressIndicatorProps) {
   const [batchInfo, setBatchInfo] = useState<BatchInfo>({
-    id: "batch_abc123",
-    status: "in_progress",
-    totalRequests: 1000,
-    completedRequests: 750,
-    failedRequests: 10,
-    inputFileName: "input.jsonl",
-    outputFileName: null,
-    errorFileName: null,
-    createdAt: "2023-03-15T10:30:00Z",
-    completedAt: null,
+    ...initialBatch as BatchInfo
   });

85-182: Enhance accessibility and user experience.

The component needs accessibility improvements and better user feedback:

  1. Add ARIA labels and roles
  2. Include loading states
  3. Add error handling UI
  4. Implement keyboard navigation for interactive elements

Example improvements:

 <Card className="w-full max-w-2xl bg-white text-gray-800 border border-gray-200 shadow-sm font-mono">
+  <div role="region" aria-label="Batch Progress Status">
     <CardHeader className="border-b border-gray-200">
       <CardTitle className="flex items-center justify-between text-lg">
         <span className="font-bold">Batch Progress: {batchInfo.id}</span>
         <Badge
           variant="outline"
+          role="status"
+          aria-live="polite"
           className={`${getStatusColor(
             batchInfo.status
           )} px-2 py-1 text-xs font-semibold rounded border`}
         >

158-179: Add confirmation dialog for batch cancellation.

The Cancel Batch button should include a confirmation dialog to prevent accidental cancellations.

 <Button
   variant="destructive"
   size="sm"
   className="bg-red-100 text-red-600 hover:bg-red-200 border border-red-300"
   disabled={
     batchInfo.status === "completed" ||
     batchInfo.status === "failed" ||
     batchInfo.status === "expired"
   }
+  onClick={() => {
+    if (window.confirm('Are you sure you want to cancel this batch?')) {
+      // Handle batch cancellation
+    }
+  }}
 >
   Cancel Batch
 </Button>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 51a054f and d01a9d2.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (16)
  • .changeset/famous-grapes-film.md (1 hunks)
  • docs/config/config-file.mdx (1 hunks)
  • docs/mint.json (9 hunks)
  • packages/cli-v3/package.json (2 hunks)
  • packages/cli-v3/src/build/bundle.ts (4 hunks)
  • packages/cli-v3/src/build/entryPoints.ts (1 hunks)
  • packages/cli-v3/src/dev/devSession.ts (1 hunks)
  • packages/core/src/v3/config.ts (4 hunks)
  • references/nextjs-realtime/batchinput.jsonl (1 hunks)
  • references/nextjs-realtime/src/app/openai/page.tsx (1 hunks)
  • references/nextjs-realtime/src/components/BatchProgressIndicator.tsx (1 hunks)
  • references/nextjs-realtime/src/components/BatchSubmissionForm.tsx (1 hunks)
  • references/nextjs-realtime/src/components/ui/alert.tsx (1 hunks)
  • references/nextjs-realtime/src/components/ui/textarea.tsx (1 hunks)
  • references/nextjs-realtime/src/trigger/csv.ts (2 hunks)
  • references/nextjs-realtime/src/trigger/openaiBatch.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • docs/mint.json
🧰 Additional context used
🪛 Biome (1.9.4)
packages/cli-v3/src/build/entryPoints.ts

[error] 61-61: Comparing to itself is potentially pointless.

(lint/suspicious/noSelfCompare)

⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (buildjet-8vcpu-ubuntu-2204 - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (buildjet-8vcpu-ubuntu-2204 - npm)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (13)
packages/cli-v3/src/build/bundle.ts (1)

Line range hint 49-114: Efficient implementation of dynamic entry point management

The introduction of entryPointManager and the use of ESBuild's context API for dynamic rebuilding enhance the efficiency of the build process. The code correctly handles the rebuilding of the context when entry points change, ensuring that the latest entry points are always used.

references/nextjs-realtime/src/app/openai/page.tsx (1)

7-11: LGTM! Clean component structure.

The component follows Next.js best practices with proper prop passing and semantic layout using Tailwind CSS.

references/nextjs-realtime/src/components/ui/textarea.tsx (2)

5-19: LGTM! Well-structured reusable component.

The component follows React best practices with:

  • Proper TypeScript typing
  • Ref forwarding
  • Comprehensive styling for various states
  • Accessibility considerations

20-20: LGTM! Proper display name.

Setting the display name helps with debugging in React DevTools.

references/nextjs-realtime/src/components/ui/alert.tsx (3)

6-20: LGTM! Well-structured variant system.

The alert variants are well-defined using class-variance-authority with proper default variants.


22-33: LGTM! Properly implemented Alert component.

The component follows best practices with:

  • Proper role attribute for accessibility
  • TypeScript integration with VariantProps
  • Clean prop spreading

47-57: LGTM! Well-implemented AlertDescription component.

The component follows best practices with proper typing and styling.

references/nextjs-realtime/src/trigger/csv.ts (1)

11-11: LGTM! Improved log message clarity.

The log message now correctly reflects that multiple files may be handled.

references/nextjs-realtime/src/components/BatchSubmissionForm.tsx (1)

12-22: Consider adding error handling for hook initialization.

The useTaskTrigger and useRealtimeRun hooks might fail if the access token is invalid or if there are network issues. Consider adding error boundaries or try-catch blocks.

packages/core/src/v3/config.ts (1)

19-30: LGTM! Well-documented configuration options.

The new configuration options are clearly documented with proper references to external documentation.

packages/cli-v3/package.json (1)

94-94: LGTM! Dependencies added for file watching and glob pattern matching.

The additions of chokidar and tinyglobby are appropriate for implementing file watching and glob pattern matching capabilities. The caret version constraints allow for minor and patch updates while maintaining compatibility.

Also applies to: 123-123

.changeset/famous-grapes-film.md (1)

1-5: LGTM! Changeset correctly describes the feature addition.

The patch version bump is appropriate for this backward-compatible feature addition that enables ignoring test/spec files in trigger directories.

docs/config/config-file.mdx (1)

50-75: LGTM! Documentation is clear, comprehensive, and well-structured.

The new "Dirs" section effectively documents both the dirs and ignorePatterns configuration options, providing clear examples and explaining the default behavior. The documentation maintains consistency with the existing style and provides all necessary information for users to implement these features.

Copy link

pkg-pr-new bot commented Jan 10, 2025

@trigger.dev/build

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

trigger.dev

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

@trigger.dev/react-hooks

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

@trigger.dev/core

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

@trigger.dev/rsc

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

@trigger.dev/sdk

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

commit: b145274

@ericallam ericallam merged commit 9e0f036 into main Jan 10, 2025
10 of 11 checks passed
@ericallam ericallam deleted the ea-branch-4 branch January 10, 2025 19:40
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.

1 participant