-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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: Add worklow to check cyclic deps in a PR #33197
Merged
Merged
Changes from 12 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
d19df6d
fix: Add worklow to check cyclic deps in a PR
dvj1988 25ac6be
Merge remote-tracking branch 'origin' into chore/add-cyclic-deps-chec…
dvj1988 3de556e
update yarn.lock
dvj1988 c9a02e4
Add the number of cylic deps in release branch
dvj1988 ce600c7
Fix the check
dvj1988 de60770
Test will less number of cyclic deps
dvj1988 54311e3
Format the message in the comment
dvj1988 db18010
Format the message in the comment
dvj1988 ebb099c
Format the message in the comment
dvj1988 84850ab
Change CIRCULAR_DEPS_IN_RELEASE
dvj1988 1b29d6f
Change messages
dvj1988 9362250
Change messages
dvj1988 158cbbb
Fix the number of CIRCULAR_DEPS_IN_RELEASE
dvj1988 5db9cf7
Merge remote-tracking branch 'origin' into chore/add-cyclic-deps-chec…
dvj1988 514299a
Comapre number of deps with release branch
dvj1988 d3ad2a1
Update counting of deps in release branch
dvj1988 b789cb8
Revert unnecessary changes
dvj1988 29afe05
Merge remote-tracking branch 'origin' into chore/add-cyclic-deps-chec…
dvj1988 92b0db3
Revert yarn.lock
dvj1988 d8b8d19
Git revert eslint file
dvj1988 0468373
Add test circular deps
dvj1988 62a85d1
Revert test files
dvj1988 c93f3e5
Remove log in github action
dvj1988 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
name: Cyclic Dependency Check | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
pr: | ||
description: "This is the PR number in case the workflow is being called in a pull request" | ||
required: false | ||
type: number | ||
|
||
jobs: | ||
check-cyclic-dependencies: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
has_more_cyclic_deps: ${{ steps.check_cyclic_deps.outputs.has_more_cyclic_deps }} | ||
defaults: | ||
run: | ||
working-directory: app/client | ||
shell: bash | ||
|
||
steps: | ||
# The checkout steps MUST happen first because the default directory is set according to the code base. | ||
# GitHub Action expects all future commands to be executed in the code directory. Hence, we need to check out | ||
# the code before doing anything else. | ||
|
||
# Check out merge commit with the base branch in case this workflow is invoked via pull request | ||
- name: Checkout the merged commit from PR and base branch | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: refs/pull/${{ inputs.pr }}/merge | ||
|
||
# In case this is second attempt try restoring status of the prior attempt from cache | ||
- name: Restore the previous run result | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/run_result | ||
key: ${{ github.run_id }}-${{ github.job }}-client | ||
|
||
# Fetch prior run result | ||
- name: Get the previous run result | ||
id: run_result | ||
run: cat ~/run_result 2>/dev/null || echo 'default' | ||
|
||
# In case of prior failure run the job | ||
- if: steps.run_result.outputs.run_result != 'success' | ||
run: echo "I'm alive!" && exit 0 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: app/client/package.json | ||
|
||
# actions/setup-node@v3 doesn’t work properly with Yarn 3 | ||
# when the project lives in a subdirectory: https://github.com/actions/setup-node/issues/488 | ||
# Restoring the cache manually instead | ||
- name: Restore Yarn cache | ||
if: steps.run_result.outputs.run_result != 'success' | ||
uses: actions/cache@v3 | ||
with: | ||
path: app/client/.yarn/cache | ||
key: v1-yarn3-${{ hashFiles('app/client/yarn.lock') }} | ||
restore-keys: | | ||
v1-yarn3- | ||
|
||
# Install all the dependencies | ||
- name: Install dependencies | ||
if: steps.run_result.outputs.run_result != 'success' | ||
run: yarn install --immutable | ||
|
||
# Check for cyclic dependencies and save the output | ||
- name: Check for Cyclic Dependencies | ||
if: steps.run_result.outputs.run_result != 'success' | ||
id: check_cyclic_deps | ||
run: | | ||
OUTPUT=$(yarn check-cyclic-deps 2>&1) || true | ||
|
||
if [[ $OUTPUT == *"Failed!"* ]]; then | ||
echo "has_more_cyclic_deps=true" >> "$GITHUB_OUTPUT" | ||
fi | ||
|
||
# Comment on the PR if cyclic dependencies are found | ||
- name: Comment the result on PR | ||
if: steps.check_cyclic_deps.outputs.has_more_cyclic_deps == 'true' | ||
uses: actions/github-script@v3 | ||
with: | ||
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, 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 | ||
}); | ||
|
||
# Saving the cache to use it in subsequent runs | ||
- name: Save Yarn cache | ||
uses: actions/cache/save@v3 | ||
with: | ||
path: app/client/.yarn/cache | ||
key: v1-yarn3-${{ hashFiles('app/client/yarn.lock') }} | ||
|
||
# Set status = success | ||
- name: Save the status of the run | ||
run: echo "run_result=success" >> $GITHUB_OUTPUT > ~/run_result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const { parseDependencyTree, parseCircular, prettyCircular } = require("dpdm"); | ||
|
||
const CIRCULAR_DEPS_IN_RELEASE = 2964; | ||
|
||
parseDependencyTree("./src", {}).then((tree) => { | ||
const circulars = parseCircular(tree); | ||
if (circulars.length > CIRCULAR_DEPS_IN_RELEASE) { | ||
console.log("Failed!"); | ||
} | ||
console.log(prettyCircular(circulars)); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Nit: Recommend removing these steps as it's not required in this particular job. We use this for long running jobs (like Cypress test etc) to prevent re-running of the same job after a failure. In this particular case, I don't think this is required.
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.
Removed them.