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

chore: make cyclic deps check an error #38543

Merged
merged 25 commits into from
Jan 9, 2025

Conversation

dvj1988
Copy link
Contributor

@dvj1988 dvj1988 commented Jan 8, 2025

Description

Make cyclic dependency check a mandatory quality check.

Sample failure run
Sample skipped run - Skipped when there are no changes in the app/client folder
Sample successful run

Fixes #Issue Number
or
Fixes Issue URL

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

/ok-to-test tags="@tag.Sanity"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12683029082
Commit: 49cca4c
Cypress dashboard.
Tags: @tag.Sanity
Spec:


Thu, 09 Jan 2025 04:07:26 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

Summary by CodeRabbit

  • Chores
    • Updated GitHub Actions workflow for cyclic dependency checking.
    • Modified quality checks workflow to include cyclic dependency job as a dependency.
    • Enhanced dependency checking process with more robust reporting and failure conditions.
    • Updated warning messaging in PR comments for cyclic dependencies, changing the emoji to indicate urgency.

@dvj1988 dvj1988 requested a review from sharat87 as a code owner January 8, 2025 13:10
Copy link
Contributor

coderabbitai bot commented Jan 8, 2025

Walkthrough

The pull request modifies two GitHub Actions workflow files to enhance cyclic dependency checking. The ci-client-cyclic-deps-check.yml workflow now conditionally sets up Node.js and installs the dpdm package, with improved dependency counting logic. The quality-checks.yml workflow is updated to incorporate the cyclic dependency check results into the overall quality check evaluation, creating a more comprehensive dependency validation process.

Changes

File Change Summary
.github/workflows/ci-client-cyclic-deps-check.yml - Added conditional Node.js setup
- Globally installed dpdm package
- Updated dependency counting logic
- Added step to fail workflow if cyclic dependencies increase
- Modified PR comment emoji from ⚠️ to 🔴🔴🔴
.github/workflows/quality-checks.yml - Added client-check-cyclic-deps as a dependency for qc-result job
- Updated conditional logic to include cyclic dependency check results

Possibly related PRs

Suggested reviewers

  • sharat87
  • KelvinOm

Poem

🔄 Cycles checked with care and might,
Dependencies dancing left and right,
No circular paths shall break our code,
Quality flows down this workflow road!
🔴🔴🔴 Dependency drama, now in sight! 🕸️

Finishing Touches

  • 📝 Generate Docstrings

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.

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.

@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Jan 8, 2025
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

🧹 Nitpick comments (2)
.github/workflows/ci-client-cyclic-deps-check.yml (2)

89-92: Enhance the failure step with better error messaging

The step implementation is correct, but consider improving the error visibility in CI logs.

       # Fail the workflow if cyclic dependencies are found
       - name: Fail the workflow if cyclic dependencies are found
         if: steps.compare-deps.outputs.has_more_cyclic_deps == 'true' && steps.changed-files.outputs.any_changed == 'true'
-        run: exit 1
+        run: |
+          echo "::error::Found ${steps.compare-deps.outputs.diff} new cyclic dependencies compared to release branch"
+          exit 1

Line range hint 40-40: Fix typo in step ID

There's a typo in the step ID 'coun-cyclic-deps-in-release'.

-      - name: Count circular dependencies on release branch
-        id: coun-cyclic-deps-in-release
+      - name: Count circular dependencies on release branch
+        id: count-cyclic-deps-in-release
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8efce1d and 086bd6e.

📒 Files selected for processing (1)
  • .github/workflows/ci-client-cyclic-deps-check.yml (1 hunks)
🔇 Additional comments (1)
.github/workflows/ci-client-cyclic-deps-check.yml (1)

91-91: Well-structured conditional checks

The condition combining both has_more_cyclic_deps and any_changed ensures accurate workflow failure triggers.

Copy link

github-actions bot commented Jan 8, 2025

⚠️ Cyclic Dependency Check:

This PR has increased the number of cyclic dependencies by 1, when compared with the release branch.

Refer this document to identify the cyclic dependencies introduced by this PR.

Copy link

github-actions bot commented Jan 8, 2025

⚠️ Cyclic Dependency Check:

This PR has increased the number of cyclic dependencies by 1, when compared with the release branch.

Refer this document to identify the cyclic dependencies introduced by this PR.

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

🧹 Nitpick comments (2)
app/client/src/instrumentation/dummy.ts (1)

5-8: Consider moving DummyType interface

After creating a common types file, this interface should also be moved there to maintain consistency and prevent future cyclic dependencies.

app/client/src/instrumentation/types.ts (1)

12-12: Simplify type exports

Once types are moved to a common file, this re-export becomes unnecessary.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 370b0e5 and fc56f5a.

📒 Files selected for processing (3)
  • .github/workflows/quality-checks.yml (2 hunks)
  • app/client/src/instrumentation/dummy.ts (1 hunks)
  • app/client/src/instrumentation/types.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-build / client-build
  • GitHub Check: client-lint / client-lint
🔇 Additional comments (2)
.github/workflows/quality-checks.yml (2)

105-105: LGTM! Clean integration of cyclic deps check.

The cyclic dependency check is properly integrated into the workflow dependencies while maintaining alphabetical order.


120-120: LGTM! Consistent failure condition implementation.

The cyclic dependency check result is correctly integrated into the failure conditions, following the established pattern.

Comment on lines 1 to 3
import type { Attributes as OTELAttributes } from "@opentelemetry/api";
import type { Span } from "./types";
export type Attributes = OTELAttributes;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Break the cyclic dependency with types.ts

There's a circular dependency between this file and types.ts. This file imports Span from ./types while types.ts imports Attributes from here.

Consider moving common types to a separate types file to break this cycle. For example:

- import type { Span } from "./types";
- export type Attributes = OTELAttributes;
+ // Move to a new file: commonTypes.ts
+ export type Attributes = OTELAttributes;
+ export type Span = OTELSpan;

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines 1 to 2
import type { TimeInput, Span as OTELSpan } from "@opentelemetry/api";
import type { Attributes as DummyAttributes } from "./dummy";
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove circular dependency with dummy.ts

This file imports from ./dummy which creates a circular dependency. This could cause issues with bundling and type resolution.

Move shared types to a common file:

- import type { Attributes as DummyAttributes } from "./dummy";
+ import type { Attributes } from "./commonTypes";

Committable suggestion skipped: line range outside the PR's diff.

Copy link

github-actions bot commented Jan 8, 2025

🚨 Cyclic Dependency Check:

This PR has increased the number of cyclic dependencies by 1, when compared with the release branch.

Refer this document to identify the cyclic dependencies introduced by this PR.

Copy link

github-actions bot commented Jan 8, 2025

🚨 Cyclic Dependency Check:

This PR has increased the number of cyclic dependencies by 1, when compared with the release branch.

Refer this document to identify the cyclic dependencies introduced by this PR.

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

🧹 Nitpick comments (3)
.github/workflows/ci-client-cyclic-deps-check.yml (3)

43-46: Consider using a version range for dpdm

Instead of fixing the version to 3.14, consider using a version range (e.g., ^3.14.0) to receive minor updates and security patches while avoiding breaking changes.

-        run: npm install -g dpdm@3.14
+        run: npm install -g dpdm@^3.14.0

70-74: Extract duplicated counting logic

The same awk pipeline is duplicated. Consider extracting it into a reusable function.

+      - name: Set count function
+        if: steps.changed-files.outputs.any_changed == 'true'
+        run: |
+          count_deps() {
+            awk 'NF' "$1" | wc -l | awk '{print $1 - 1}'
+          }
+
       - name: Count circular dependencies on release branch
         id: coun-cyclic-deps-in-release
         if: steps.changed-files.outputs.any_changed == 'true'
         run: |
           dpdm "./src/**/*.{js,jsx,ts,tsx}" --circular --warning=false --tree=false > release_circular_deps.txt
-          release_count=$(awk 'NF' release_circular_deps.txt | wc -l | awk '{print $1 - 1}')
+          release_count=$(count_deps release_circular_deps.txt)

99-109: Fix typo in step ID

There's a typo in the step ID 'coun-cyclic-deps-in-release' which could cause issues if referenced elsewhere.

-        id: coun-cyclic-deps-in-release
+        id: count-cyclic-deps-in-release
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d774508 and 12c0947.

📒 Files selected for processing (1)
  • .github/workflows/ci-client-cyclic-deps-check.yml (3 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/ci-client-cyclic-deps-check.yml

51-51: shellcheck reported issue in this script: SC2086:info:6:30: Double quote to prevent globbing and word splitting

(shellcheck)

.github/workflows/ci-client-cyclic-deps-check.yml Outdated Show resolved Hide resolved
@dvj1988 dvj1988 requested review from riodeuno and mohanarpit January 8, 2025 15:28
@dvj1988 dvj1988 added the ok-to-test Required label for CI label Jan 8, 2025
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

🧹 Nitpick comments (1)
.github/workflows/ci-client-cyclic-deps-check.yml (1)

43-47: Consider using npx instead of global installation.

Global package installation could lead to version conflicts across different workflows. Consider using npx to run a specific version instead.

-      - name: Install dpdm globally
-        if: steps.changed-files.outputs.any_changed == 'true'
-        run: npm install -g dpdm@3.14
+      - name: Run dpdm check
+        if: steps.changed-files.outputs.any_changed == 'true'
+        run: npx dpdm@3.14
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 12c0947 and ef115da.

📒 Files selected for processing (1)
  • .github/workflows/ci-client-cyclic-deps-check.yml (3 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/ci-client-cyclic-deps-check.yml

51-51: shellcheck reported issue in this script: SC2086:info:6:30: Double quote to prevent globbing and word splitting

(shellcheck)

🔇 Additional comments (2)
.github/workflows/ci-client-cyclic-deps-check.yml (2)

37-42: LGTM! Efficient Node.js setup.

The conditional setup based on file changes and version management through package.json follows best practices.


106-109: LGTM! Proper error handling.

The workflow failure on increased cyclic dependencies aligns with the PR objective and is implemented correctly.

.github/workflows/ci-client-cyclic-deps-check.yml Outdated Show resolved Hide resolved
.github/workflows/ci-client-cyclic-deps-check.yml Outdated Show resolved Hide resolved
@dvj1988 dvj1988 force-pushed the chore/make-cyclic-dep-check-error branch from 98369ae to 658e605 Compare January 9, 2025 02:58
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

🧹 Nitpick comments (1)
.github/workflows/ci-client-cyclic-deps-check.yml (1)

82-86: Reduce code duplication and fix shell quoting.

  1. Quote GITHUB_OUTPUT to prevent word splitting:
-          echo "release_count=$release_count" >> $GITHUB_OUTPUT
+          echo "release_count=$release_count" >> "$GITHUB_OUTPUT"
  1. Consider refactoring the duplicate counting logic into a reusable composite action or shell function:
count_dependencies() {
  local branch_name=$1
  local output_file="${branch_name}_circular_deps.txt"
  local count_var_name="${branch_name}_count"
  
  dpdm "./src/**/*.{js,jsx,ts,tsx}" --circular --warning=false --tree=false > "$output_file"
  local count
  count="$(awk 'NF' "$output_file" | wc -l | awk '{print $1 - 1}')"
  echo "${count_var_name}=${count}" >> "$GITHUB_OUTPUT"
  cat "$output_file"
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ef115da and 49cca4c.

📒 Files selected for processing (1)
  • .github/workflows/ci-client-cyclic-deps-check.yml (3 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/ci-client-cyclic-deps-check.yml

57-57: shellcheck reported issue in this script: SC2086:info:6:30: Double quote to prevent globbing and word splitting

(shellcheck)


81-81: shellcheck reported issue in this script: SC2086:info:6:40: Double quote to prevent globbing and word splitting

(shellcheck)

🔇 Additional comments (3)
.github/workflows/ci-client-cyclic-deps-check.yml (3)

37-53: LGTM! Well-structured Node.js setup and dependency installation.

The setup is robust with:

  • Conditional execution based on changed files
  • Pinned dpdm version for stability
  • Immutable yarn installs for reproducibility

Line range hint 94-121: LGTM! Well-implemented comparison and failure handling.

The implementation:

  • Correctly compares dependency counts
  • Provides clear PR feedback with documentation
  • Appropriately fails the workflow on regression

58-62: 🛠️ Refactor suggestion

Quote GITHUB_OUTPUT to prevent word splitting.

The shell script should properly quote the GITHUB_OUTPUT variable.

-          echo "pr_count=$pr_count" >> $GITHUB_OUTPUT
+          echo "pr_count=$pr_count" >> "$GITHUB_OUTPUT"

Likely invalid or redundant comment.

@dvj1988
Copy link
Contributor Author

dvj1988 commented Jan 9, 2025

@mohanarpit Please re-review.

@mohanarpit mohanarpit merged commit 4662317 into release Jan 9, 2025
45 checks passed
@mohanarpit mohanarpit deleted the chore/make-cyclic-dep-check-error branch January 9, 2025 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants