Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions .github/workflows/ci-client-cyclic-deps-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,26 @@ jobs:
files: |
app/client/src/**

- name: Use Node.js
if: steps.changed-files.outputs.any_changed == 'true'
uses: actions/setup-node@v4
with:
node-version-file: app/client/package.json

# Globally install the npm package
- name: Install dpdm globally
if: steps.changed-files.outputs.any_changed == 'true'
run: npm install -g dpdm@3.14

- name: Count circular dependencies on PR branch
id: count-cyclic-deps-in-pr
if: steps.changed-files.outputs.any_changed == 'true'
run: |
npx dpdm ./src/* --circular --warning=false --tree=false > pr_circular_deps.txt
pr_count=$(cat pr_circular_deps.txt | wc -l)
dpdm "./src/**/*.{js,jsx,ts,tsx}" --circular --warning=false --tree=false > pr_circular_deps.txt
# awk 'NF' pr_circular_deps.txt: Filter out empty lines from the file
# wc -l: Count the number of lines in the file
# awk '{print $1 - 1}': Subtract 1 from the count because the first line is the header 'Circular Dependencies'
pr_count=$(awk 'NF' pr_circular_deps.txt | wc -l | awk '{print $1 - 1}')
Comment thread
dvj1988 marked this conversation as resolved.
Outdated
echo "pr_count=$pr_count" >> $GITHUB_OUTPUT
cat pr_circular_deps.txt

Expand All @@ -53,8 +67,11 @@ jobs:
id: coun-cyclic-deps-in-release
if: steps.changed-files.outputs.any_changed == 'true'
run: |
npx dpdm ./src/* --circular --warning=false --tree=false > release_circular_deps.txt
release_count=$(cat release_circular_deps.txt | wc -l)
dpdm "./src/**/*.{js,jsx,ts,tsx}" --circular --warning=false --tree=false > release_circular_deps.txt
# awk 'NF' release_circular_deps.txt: Filter out empty lines from the file
# wc -l: Count the number of lines in the file
# awk '{print $1 - 1}': Subtract 1 from the count because the first line is the header 'Circular Dependencies'
release_count=$(awk 'NF' release_circular_deps.txt | wc -l | awk '{print $1 - 1}')
Comment thread
dvj1988 marked this conversation as resolved.
Outdated
echo "release_count=$release_count" >> $GITHUB_OUTPUT
cat release_circular_deps.txt

Expand All @@ -79,9 +96,14 @@ jobs:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const prNumber = context.payload.pull_request.number;
const message = `⚠️ Cyclic Dependency Check:\n\nThis PR has increased the number of cyclic dependencies by ${{steps.compare-deps.outputs.diff}}, when compared with the release branch.\n\nRefer [this document](https://appsmith.notion.site/How-to-check-cyclic-dependencies-c47b08fe5f2f4261a3a234b19e13f2db) to identify the cyclic dependencies introduced by this PR.`;
const message = `🚨 Cyclic Dependency Check:\n\nThis PR has increased the number of cyclic dependencies by ${{steps.compare-deps.outputs.diff}}, when compared with the release branch.\n\nRefer [this document](https://appsmith.notion.site/How-to-check-cyclic-dependencies-c47b08fe5f2f4261a3a234b19e13f2db) to identify the cyclic dependencies introduced by this PR.`;
github.issues.createComment({
...context.repo,
issue_number: prNumber,
body: message
});

# 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
2 changes: 2 additions & 0 deletions .github/workflows/quality-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ jobs:
client-prettier,
client-unit-tests,
client-lint,
client-check-cyclic-deps,
]
if: always()
runs-on: ubuntu-latest
Expand All @@ -116,6 +117,7 @@ jobs:
"${{ needs.client-build.result }}" == "failure" || \
"${{ needs.client-prettier.result }}" == "failure" || \
"${{ needs.client-unit-tests.result }}" == "failure" || \
"${{ needs.client-check-cyclic-deps.result }}" == "failure" || \
"${{ needs.client-lint.result }}" == "failure" ]]; then
echo "Quality checks failed";
exit 1;
Expand Down