-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - circleci #15009
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
New Components - circleci #15009
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Skipped Deployments
|
WalkthroughThis pull request introduces new CircleCI integration components for Pipedream, including actions for retrieving job artifacts, rerunning workflows, and triggering pipelines. It enhances the CircleCI app's functionality by adding properties and methods for interacting with CircleCI's API, creating webhook sources for job and workflow events, and establishing a framework for managing CircleCI-related operations. Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
🔭 Outside diff range comments (1)
components/circleci/circleci.app.mjs (1)
Line range hint
147-220
: Unify pagination and handle 404 / missing resources.
The list methods (e.g., listPipelines, listPipelineWorkflows, listWorkflowJobs) each handle pagination individually. Consolidating pagination into a single utility could reduce duplication and ensure that missing resource errors (such as invalid pipelineId) are caught and communicated properly.
🧹 Nitpick comments (11)
components/circleci/sources/common/base.mjs (2)
43-48
: Handle potential errors when deleting the webhook.
If the webhook ID is invalid or CircleCI returns a failure, there’s no handling or log statement. Consider adding a try-catch block for better observability.
102-115
: Log and handle invalid requests more explicitly in the run method.
While you log “Invalid webhook signature,” it might be beneficial to add structured logging or metrics to track failed verification attempts for security monitoring.components/circleci/circleci.app.mjs (2)
1-31
: Validate pipeline existence and handle errors gracefully.
When listing pipelines (lines 16–23) for a given projectSlug, the code expects valid data. Consider handling scenarios where no items are returned or the user lacks permission. Logs or error messages would aid troubleshooting.
130-146
: Consider adding retry or rate-limit logic in _makeRequest.
API calls to CircleCI may be rate-limited or occasionally fail. A retry mechanism (e.g., exponential backoff) could improve stability, while logging or returning useful error messages helps to diagnose API call failures.components/circleci/sources/new-job-completed-instant/new-job-completed-instant.mjs (1)
19-21
: Provide a fallback if event.job or event.job.name is undefined.
In some scenarios, the event might not include job details. Consider safe navigation or defaulting the name to avoid potential runtime errors.components/circleci/sources/new-workflow-completed-instant/new-workflow-completed-instant.mjs (1)
19-21
: Be prepared for missing or incomplete event.workflow data.
If the event doesn’t include “workflow” or the “name” property, accessing them directly could cause an error. Consider optional chaining or a fallback message.components/circleci/actions/get-job-artifacts/get-job-artifacts.mjs (1)
45-53
: Add error handling for API failures.While the implementation is correct, consider adding try-catch block to handle potential API errors gracefully.
async run({ $ }) { + try { const response = await this.circleci.getJobArtifacts({ $, projectSlug: this.projectSlug, jobNumber: this.jobNumber, }); $.export("$summary", `Successfully retrieved artifacts for job number: ${this.jobNumber}`); return response; + } catch (error) { + $.export("$summary", `Failed to retrieve artifacts: ${error.message}`); + throw error; + } },components/circleci/actions/rerun-workflow/rerun-workflow.mjs (1)
56-61
: Add description for sparseTree property.The sparseTree property is missing a description. This should be documented to help users understand its purpose and impact.
components/circleci/sources/new-workflow-completed-instant/test-event.mjs (2)
4-4
: Use realistic dates and URLs in test event.
- The test event uses future dates (2024-12-18) which might cause confusion
- The workflow URL is empty, consider using a placeholder URL for better testing
- "happened_at": "2024-12-18T18:44:38.000100Z", + "happened_at": "2023-12-18T18:44:38.000100Z", ... "workflow": { - "created_at": "2024-12-18T18:44:20.682Z", + "created_at": "2023-12-18T18:44:20.682Z", - "stopped_at": "2024-12-18T18:44:37.867Z", + "stopped_at": "2023-12-18T18:44:37.867Z", - "url": "", + "url": "https://app.circleci.com/pipelines/workflows/example",Also applies to: 12-15
1-75
: Add JSDoc comment to document test event structure.Consider adding documentation to explain the purpose and structure of this test event.
+/** + * Sample webhook payload for a completed workflow event. + * This event data is used for testing the new-workflow-completed-instant source. + * + * @see https://circleci.com/docs/api/v2/index.html#operation/getWebhookPayloadSchema + */ export default {components/circleci/actions/trigger-pipeline/trigger-pipeline.mjs (1)
7-7
: Consider starting with version 1.0.0Since this appears to be a production-ready component with a complete feature set, consider starting with version 1.0.0 instead of 0.0.1 to better reflect its maturity level.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (10)
components/circleci/actions/get-job-artifacts/get-job-artifacts.mjs
(1 hunks)components/circleci/actions/rerun-workflow/rerun-workflow.mjs
(1 hunks)components/circleci/actions/trigger-pipeline/trigger-pipeline.mjs
(1 hunks)components/circleci/circleci.app.mjs
(1 hunks)components/circleci/package.json
(1 hunks)components/circleci/sources/common/base.mjs
(1 hunks)components/circleci/sources/new-job-completed-instant/new-job-completed-instant.mjs
(1 hunks)components/circleci/sources/new-job-completed-instant/test-event.mjs
(1 hunks)components/circleci/sources/new-workflow-completed-instant/new-workflow-completed-instant.mjs
(1 hunks)components/circleci/sources/new-workflow-completed-instant/test-event.mjs
(1 hunks)
✅ Files skipped from review due to trivial changes (2)
- components/circleci/package.json
- components/circleci/sources/new-job-completed-instant/test-event.mjs
🔇 Additional comments (5)
components/circleci/sources/common/base.mjs (1)
95-100
: Implement or override placeholder methods for getEvents / getSummary.
The default implementations throw errors. Verify that all sources extending this base properly override them. Otherwise, activating a source without providing these methods will cause runtime errors.
✅ Verification successful
Based on the search results, I can generate the final response since I have enough information to verify the implementation of getEvents
and getSummary
methods across the codebase.
All sources properly override the placeholder methods.
The search results show that sources extending the base class in components/circleci/sources/common/base.mjs
correctly implement both getEvents()
and getSummary()
methods. This is evidenced by:
- Base implementations that throw errors are found in common/base files:
components/circleci/sources/common/base.mjs
components/zoho_salesiq/sources/common/common.mjs
components/zoho_commerce/sources/common/common.mjs
components/zoho_crm/sources/common/http-based/base.mjs
- All source files that extend these bases properly override the methods with actual implementations:
- Webhook-based sources implement
getEvents()
with specific event types (e.g.,tawk_to
,stripe
,whop
sources) - Polling-based sources implement
getSummary()
with descriptive messages (e.g.,leadoku
,zoho_sheet
,voilanorbert
sources)
The error-throwing base implementations serve as intended - forcing child classes to provide their own implementations, which they do.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Identify all references to `getEvents` or `getSummary` calls, ensuring they're overridden
rg "(\sgetEvents\(\)|\sgetSummary\(\))" -A 5
Length of output: 65762
components/circleci/sources/new-job-completed-instant/new-job-completed-instant.mjs (1)
14-18
: Ensure “job-completed” event usage matches CircleCI’s actual event name.
Double-check that “job-completed” is the correct event name consistently used by CircleCI. If the integration expects a different string (like “job.finished”), the source might not emit as intended.
✅ Verification successful
Let me search for CircleCI's webhook documentation or related configuration files to verify the correct event name.
Let me check the test event file and CircleCI app implementation to verify the event type format.
The "job-completed" event name is correctly implemented
Based on the test event file (test-event.mjs
), the event type "job-completed" matches CircleCI's webhook payload format, where the type
field contains exactly "job-completed". This is confirmed by the test event's structure and the successful implementation in the codebase.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search the codebase for references to "job-completed" to confirm usage alignment
rg "job-completed"
Length of output: 676
Script:
#!/bin/bash
# Search for CircleCI webhook or event related configuration files
fd -e json -e yaml -e yml circleci
# Look for any documentation files that might contain webhook information
fd README -e md | grep -i circleci
# Search for any references to CircleCI webhooks or events in the codebase
rg -i "webhook" -A 3 -B 3 | grep -i circleci
Length of output: 6011
Script:
#!/bin/bash
# Check the test event file for the job-completed event
cat components/circleci/sources/new-job-completed-instant/test-event.mjs
# Look for event type handling in the CircleCI app
cat components/circleci/circleci.app.mjs
Length of output: 7527
components/circleci/sources/new-workflow-completed-instant/new-workflow-completed-instant.mjs (1)
14-18
: Confirm the string “workflow-completed” matches CircleCI’s webhook payload.
Similar to the job-completed event, verify that “workflow-completed” truly aligns with CircleCI’s event type. If it differs, you may need to adjust the strings to ensure correct emission.
components/circleci/actions/get-job-artifacts/get-job-artifacts.mjs (1)
11-43
: LGTM! Props chain creates a logical selection flow.
The props chain (projectSlug -> pipelineId -> workflowId -> jobNumber) is well-structured, ensuring users select values in the correct order with proper dependencies.
components/circleci/actions/trigger-pipeline/trigger-pipeline.mjs (1)
1-1
: Verify integration with CircleCI app
Let's verify that the triggerPipeline
method exists in the CircleCI app and matches the expected interface.
Also applies to: 54-54
✅ Verification successful
The verification results show that:
- The
triggerPipeline
method exists incircleci.app.mjs
and acceptsprojectSlug
and other options as parameters - The method is properly used in the trigger-pipeline action with the correct parameters
- The interface matches between the app and the action component
Integration with CircleCI app verified successfully
The triggerPipeline
method exists in the CircleCI app with the expected interface, accepting projectSlug
and additional options. The action component correctly imports and uses this method with the required parameters.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check if triggerPipeline method exists in CircleCI app and verify its interface
# Search for triggerPipeline method definition
ast-grep --pattern 'triggerPipeline($$$) {
$$$
}'
# Search for any usage of triggerPipeline method
rg -A 5 'triggerPipeline'
Length of output: 1784
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
♻️ Duplicate comments (1)
components/circleci/actions/rerun-workflow/rerun-workflow.mjs (1)
63-78
:⚠️ Potential issueFix property name mismatch and add validation.
The issues identified in the previous review are still valid:
- Property name mismatch:
this.from_failed
should bethis.fromFailed
- Missing validation for mutually exclusive parameters
- Potential JSON parse error needs handling
Please refer to the previous review comment for the suggested fixes.
🧹 Nitpick comments (3)
components/circleci/actions/rerun-workflow/rerun-workflow.mjs (2)
56-61
: Add description for sparseTree property.The description field for the sparseTree property is empty. Please add a clear description explaining its purpose and impact on the workflow rerun.
63-78
: Consider adding rate limiting and error handling.Since this component interacts with CircleCI's API for workflow operations:
- Consider implementing rate limiting to avoid hitting API limits
- Add proper error handling for API failures with meaningful error messages
- Consider adding retry logic for transient failures
components/circleci/sources/common/base.mjs (1)
70-80
: Safeguard against missing or invalid signature format.If “v1” is missing after splitting the “circleci-signature” header, “signatureFromHeader” would be undefined. You may want to check for a defined value before calling “Buffer.from(...)”.
if (!headers["circleci-signature"]) { return false; } const secret = this._getSigningSecret(); const parts = headers["circleci-signature"].split(","); const signatureMap = parts.reduce((acc, pair) => { const [key, value] = pair.split("="); acc[key] = value; return acc; }, {}); + if (!signatureMap.v1) { + return false; + } const signatureFromHeader = signatureMap.v1;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
components/circleci/actions/rerun-workflow/rerun-workflow.mjs
(1 hunks)components/circleci/sources/common/base.mjs
(1 hunks)
🔇 Additional comments (4)
components/circleci/actions/rerun-workflow/rerun-workflow.mjs (2)
1-8
: LGTM! Well-structured component metadata.
The component metadata is well-defined with proper documentation link and versioning.
35-46
: 🛠️ Refactor suggestion
Add prop-level validation for mutually exclusive parameters.
While the description mentions that enableSsh
and fromFailed
are mutually exclusive, there's no validation enforcing this constraint at the prop level.
Consider adding validation using the async validate({ enableSsh, fromFailed })
method:
+ async validate({ enableSsh, fromFailed }) {
+ if (enableSsh && fromFailed) {
+ throw new Error("The parameters 'Enable SSH' and 'From Failed' are mutually exclusive and cannot be used together.");
+ }
+ },
Likely invalid or redundant comment.
components/circleci/sources/common/base.mjs (2)
25-42
: Add error handling for the webhook creation request.
This operation can fail for various reasons (e.g., network issues, invalid project ID) and currently the exception would remain unhandled. A try/catch block ensures the error is gracefully reported without halting execution unexpectedly.
66-68
: Good defensive check for the “circleci-signature” header.
Returning false when the header is absent protects against crashes if the request is malformed or fails to include the signature. This prevents runtime errors and improves resilience.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
/approve |
Resolves #14846.
Summary by CodeRabbit
Release Notes
New Features
Enhancements
Package Management
Documentation