Skip to content

Conversation

luancazarine
Copy link
Collaborator

@luancazarine luancazarine commented Dec 10, 2024

Resolves #14859

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced several actions for managing GitHub workflows: enabling, disabling, creating dispatch events, and retrieving workflow runs.
    • Added a new constant LIMIT to manage workflow run retrieval limits.
    • New source components for handling workflow job and run completion events.
  • Bug Fixes

    • Enhanced error handling for workflow-related actions to provide clearer feedback.
  • Documentation

    • Updated metadata for new actions and sources to improve clarity and usability.

Sources
- New Workflow Run Completed (Instant)
- New Run Job Completed (Instant)

Actions
 - Create Workflow Dispatch
 - Enable Workflow
 - Disable Workflow
 - List Workflow Runs
 - Get Workflow Run
@luancazarine luancazarine linked an issue Dec 10, 2024 that may be closed by this pull request
Copy link

vercel bot commented Dec 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Dec 10, 2024 10:29pm
pipedream-docs ⬜️ Ignored (Inspect) Dec 10, 2024 10:29pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Dec 10, 2024 10:29pm

Copy link
Contributor

coderabbitai bot commented Dec 10, 2024

Warning

Rate limit exceeded

@luancazarine has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 17 minutes and 51 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 5582cfb and 5885f16.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (44)
  • components/github/actions/create-branch/create-branch.mjs (1 hunks)
  • components/github/actions/create-gist/create-gist.mjs (1 hunks)
  • components/github/actions/create-issue-comment/create-issue-comment.mjs (1 hunks)
  • components/github/actions/create-issue/create-issue.mjs (1 hunks)
  • components/github/actions/create-or-update-file-contents/create-or-update-file-contents.mjs (1 hunks)
  • components/github/actions/create-pull-request/create-pull-request.mjs (1 hunks)
  • components/github/actions/create-repository/create-repository.mjs (1 hunks)
  • components/github/actions/get-issue-assignees/get-issue-assignees.mjs (1 hunks)
  • components/github/actions/get-repository-content/get-repository-content.mjs (1 hunks)
  • components/github/actions/get-repository/get-repository.mjs (1 hunks)
  • components/github/actions/get-reviewers/get-reviewers.mjs (1 hunks)
  • components/github/actions/get-workflow-run/get-workflow-run.mjs (1 hunks)
  • components/github/actions/list-gists-for-a-user/list-gists-for-a-user.mjs (1 hunks)
  • components/github/actions/list-releases/list-releases.mjs (1 hunks)
  • components/github/actions/list-workflow-runs/list-workflow-runs.mjs (1 hunks)
  • components/github/actions/search-issues-and-pull-requests/search-issues-and-pull-requests.mjs (1 hunks)
  • components/github/actions/update-gist/update-gist.mjs (1 hunks)
  • components/github/actions/update-issue/update-issue.mjs (1 hunks)
  • components/github/actions/update-project-v2-item-status/update-project-v2-item-status.mjs (1 hunks)
  • components/github/package.json (2 hunks)
  • components/github/sources/new-branch/new-branch.mjs (1 hunks)
  • components/github/sources/new-card-in-column/new-card-in-column.mjs (1 hunks)
  • components/github/sources/new-collaborator/new-collaborator.mjs (1 hunks)
  • components/github/sources/new-commit-comment/new-commit-comment.mjs (1 hunks)
  • components/github/sources/new-commit/new-commit.mjs (1 hunks)
  • components/github/sources/new-discussion/new-discussion.mjs (1 hunks)
  • components/github/sources/new-fork/new-fork.mjs (1 hunks)
  • components/github/sources/new-gist/new-gist.mjs (1 hunks)
  • components/github/sources/new-issue-with-status/new-issue-with-status.mjs (1 hunks)
  • components/github/sources/new-label/new-label.mjs (1 hunks)
  • components/github/sources/new-mention/new-mention.mjs (1 hunks)
  • components/github/sources/new-notification/new-notification.mjs (1 hunks)
  • components/github/sources/new-or-updated-issue/new-or-updated-issue.mjs (1 hunks)
  • components/github/sources/new-or-updated-milestone/new-or-updated-milestone.mjs (1 hunks)
  • components/github/sources/new-or-updated-pull-request/new-or-updated-pull-request.mjs (1 hunks)
  • components/github/sources/new-organization/new-organization.mjs (1 hunks)
  • components/github/sources/new-release/new-release.mjs (1 hunks)
  • components/github/sources/new-repository/new-repository.mjs (1 hunks)
  • components/github/sources/new-review-request/new-review-request.mjs (1 hunks)
  • components/github/sources/new-security-alert/new-security-alert.mjs (1 hunks)
  • components/github/sources/new-star-by-user/new-star-by-user.mjs (1 hunks)
  • components/github/sources/new-star/new-star.mjs (1 hunks)
  • components/github/sources/new-team/new-team.mjs (1 hunks)
  • components/github/sources/webhook-events/webhook-events.mjs (1 hunks)

Walkthrough

The pull request introduces multiple new modules and functionalities related to GitHub workflows. Key additions include actions for creating, enabling, disabling, and retrieving workflow runs, as well as handling webhook events for workflow job completions. A new constant, LIMIT, is also added to enhance the existing constants module. These changes collectively enhance the interaction with GitHub's workflow capabilities without altering existing functionalities.

Changes

File Path Change Summary
components/github/actions/common/constants.mjs Added constant LIMIT set to 100 and updated default export to include LIMIT.
components/github/actions/create-workflow-dispatch/create-workflow-dispatch.mjs Introduced a new action for creating GitHub workflow dispatch events with necessary properties.
components/github/actions/disable-workflow/disable-workflow.mjs Introduced a new action for disabling GitHub workflows with error handling and API integration.
components/github/actions/enable-workflow/enable-workflow.mjs Introduced a new action for enabling GitHub workflows with structured error handling.
components/github/actions/get-workflow-run/get-workflow-run.mjs Introduced a new action for retrieving specific workflow runs from GitHub repositories.
components/github/actions/list-workflow-runs/list-workflow-runs.mjs Introduced a new action for listing workflow runs with pagination and a limit on results.
components/github/github.app.mjs Added new methods for workflow management and updated propDefinitions to include workflowId and workflowRunId.
components/github/sources/new-workflow-job-completed/new-workflow-job-completed.mjs Introduced a new source for handling webhook events related to completed workflow jobs.
components/github/sources/new-workflow-run-completed/new-workflow-run-completed.mjs Introduced a new source for handling webhook events related to completed workflow runs.

Assessment against linked issues

Objective Addressed Explanation
Emit new event when a GitHub Actions workflow run completes (related to #14859)
Emit new event when a job within a workflow completes (related to #14859)
Trigger a workflow using the workflow_dispatch event (related to #14859)
Enable a workflow by ID or filename (related to #14859)
Disable a workflow by ID or filename (related to #14859)

Possibly related PRs

  • GitHub app actions improvements #14058: This PR improves GitHub actions usability, which may relate to the main PR's changes in constants and exports that enhance the functionality of GitHub actions.
  • [Components]: heyy #14430: The changes in this PR introduce new actions related to messaging, which could be relevant if the main PR's constants are used in messaging contexts.
  • New Components - skyvern #14629: This PR introduces new components related to workflows, which may connect with the main PR's constants if they are used in workflow management.
  • [Components] x_ai #14667 #14735: This PR adds actions for model management, which could relate to the main PR if the constants are used in model-related functionalities.

Suggested labels

action, trigger / source

Suggested reviewers

  • michelle0927

Poem

In the land of code where rabbits hop,
New workflows bloom, and never stop.
With actions to create and enable with glee,
Disabling and listing, oh what a spree!
Constants added to guide our way,
In GitHub's garden, we frolic and play! 🐇✨


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. (Experiment)
  • @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: 11

🧹 Outside diff range and nitpick comments (11)
components/github/sources/new-workflow-job-completed/new-workflow-job-completed.mjs (2)

35-37: Include Workflow Job Name in Event Summary

To make the emitted event summary more informative, consider including the workflow job's name. This will help users quickly identify which job has completed.

You can modify the summary as follows:

this.$emit({
  ...getRelevantHeaders(headers),
  ...body,
}, {
  id: headers["x-github-delivery"],
- summary: "New workflow job completed.",
+ summary: `Workflow job completed: ${body.workflow_job.name}`,
  ts: new Date(),
});

43-43: Enhance Clarity of Error Message

The error message thrown when the user lacks admin access could be clearer. Consider rephrasing it to guide the user on how to proceed.

Update the error message as follows:

- throw new Error("Webhooks are only supported on repos where you have admin access.");
+ throw new Error("Admin access required: Please ensure you have admin permissions on the repository to create webhooks.");
components/github/github.app.mjs (1)

762-772: Consider Consistent Use of HTTP Client Methods

While most API requests use this._client().request, the createWorkflowDispatch method uses this._makeRequest. For consistency and maintainability, consider using this._client().request unless there's a specific reason to use _makeRequest.

Update the method as follows:

createWorkflowDispatch({
  repoFullname,
  workflowId,
  ...opts
}) {
- return this._makeRequest({
-   method: "POST",
-   path: `/repos/${repoFullname}/actions/workflows/${workflowId}/dispatches`,
-   ...opts,
- });
+ return this._client().request(`POST /repos/${repoFullname}/actions/workflows/${workflowId}/dispatches`, opts);
}
components/github/actions/common/constants.mjs (1)

9-13: Organize Exported Constants for Clarity

Consider organizing the exported constants alphabetically or logically grouped to enhance readability and maintainability.

Reorder the exports as follows:

const LIMIT = 100;
const PULL_REQUEST_STATES = [
  "APPROVED",
  "CHANGES_REQUESTED",
  "COMMENTED",
  "DISMISSED",
  "PENDING",
];

export default {
+ LIMIT,
  PULL_REQUEST_STATES,
- LIMIT,
};
components/github/actions/enable-workflow/enable-workflow.mjs (1)

33-33: Include Workflow Name in Success Summary

To provide more informative feedback, consider including the workflow's name in the success summary after enabling it.

Modify the summary as follows:

$.export("$summary", `Successfully enabled the workflow with Id: ${this.workflowId}!`);
+ const { name } = await this.github.getWorkflow({
+   repoFullname: this.repoFullname,
+   workflowId: this.workflowId,
+ });
+ $.export("$summary", `Successfully enabled the workflow: ${name} (ID: ${this.workflowId})!`);
components/github/actions/disable-workflow/disable-workflow.mjs (1)

38-40: Enhance error handling specificity

The current error handling catches all errors and attempts to extract a message from the response. Consider handling specific error cases differently.

Consider this enhanced error handling:

-    } catch (e) {
-      throw new ConfigurationError(e?.response?.data?.message);
+    } catch (error) {
+      if (error.response?.status === 404) {
+        throw new ConfigurationError(`Workflow with ID ${this.workflowId} not found`);
+      }
+      if (error.response?.status === 403) {
+        throw new ConfigurationError("Insufficient permissions to disable workflow");
+      }
+      throw new ConfigurationError(error.response?.data?.message || "Failed to disable workflow");
     }
components/github/sources/new-workflow-run-completed/new-workflow-run-completed.mjs (2)

41-44: Improve error message for admin permissions

The error message could be more helpful by suggesting how to resolve the permission issue.

Consider this enhanced error message:

-      throw new Error("Webhooks are only supported on repos where you have admin access.");
+      throw new Error(
+        "Webhooks require admin access to the repository. Please ensure you have admin " +
+        "permissions or contact the repository owner to grant you admin access."
+      );

31-38: Use ISO timestamp format

For consistency and proper timestamp handling, use ISO format for the timestamp.

     this.$emit({
       ...getRelevantHeaders(headers),
       ...body,
     }, {
       id: headers["x-github-delivery"],
       summary: "New workflow run completed.",
-      ts: new Date(),
+      ts: new Date().toISOString(),
     });
components/github/actions/list-workflow-runs/list-workflow-runs.mjs (2)

6-6: Consider removing API version from documentation link

The documentation link includes a specific API version (apiVersion=2022-11-28). Consider removing this to ensure the link remains valid when the API version changes.


25-25: Extract perPage as a constant

The perPage value should be extracted as a named constant at the module level for better maintainability.

+const PER_PAGE = 100;
+
 export default {
   // ...
   async run({ $ }) {
     let page = 1;
-    const perPage = 100;
+    const perPage = PER_PAGE;
components/github/actions/create-workflow-dispatch/create-workflow-dispatch.mjs (1)

7-7: Consider removing API version from documentation link

The documentation link includes a specific API version (apiVersion=2022-11-28). Consider removing this to ensure the link remains valid when the API version changes.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 84bba87 and 5582cfb.

📒 Files selected for processing (9)
  • components/github/actions/common/constants.mjs (1 hunks)
  • components/github/actions/create-workflow-dispatch/create-workflow-dispatch.mjs (1 hunks)
  • components/github/actions/disable-workflow/disable-workflow.mjs (1 hunks)
  • components/github/actions/enable-workflow/enable-workflow.mjs (1 hunks)
  • components/github/actions/get-workflow-run/get-workflow-run.mjs (1 hunks)
  • components/github/actions/list-workflow-runs/list-workflow-runs.mjs (1 hunks)
  • components/github/github.app.mjs (3 hunks)
  • components/github/sources/new-workflow-job-completed/new-workflow-job-completed.mjs (1 hunks)
  • components/github/sources/new-workflow-run-completed/new-workflow-run-completed.mjs (1 hunks)
🔇 Additional comments (1)
components/github/github.app.mjs (1)

777-790: 🛠️ Refactor suggestion

Handle API Response and Errors Appropriately

The disableWorkflow and enableWorkflow methods do not handle API responses or possible errors. Consider adding error handling or at least returning the API response for better transparency.

Modify the methods to return the response:

async disableWorkflow({
  repoFullname,
  workflowId,
}) {
- return this._makeRequest({
+ const response = await this._makeRequest({
    method: "PUT",
    path: `/repos/${repoFullname}/actions/workflows/${workflowId}/disable`,
  });
+ return response;
}

async enableWorkflow({
  repoFullname,
  workflowId,
}) {
- return this._makeRequest({
+ const response = await this._makeRequest({
    method: "PUT",
    path: `/repos/${repoFullname}/actions/workflows/${workflowId}/enable`,
  });
+ return response;
}

Likely invalid or redundant comment.

@vunguyenhung vunguyenhung merged commit 3db8dff into master Dec 12, 2024
11 checks passed
@vunguyenhung vunguyenhung deleted the 14859-components-github branch December 12, 2024 03:24
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.

[Components] github
3 participants