-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Detect unused dependencies (#693) #760
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
Changes from all commits
38dc363
63341a9
8a42d63
0651b21
79c2b4a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,346 @@ | ||||||
| # Dependency Check Workflow | ||||||
| # Detects unused and vulnerable dependencies in the project | ||||||
| # Run on: Pull requests and weekly schedule | ||||||
|
|
||||||
| name: Dependency Check | ||||||
|
|
||||||
| on: | ||||||
| workflow_dispatch: | ||||||
| inputs: | ||||||
| full_audit: | ||||||
| description: 'Run full audit including all dependencies' | ||||||
| required: false | ||||||
| default: 'false' | ||||||
| type: boolean | ||||||
| schedule: | ||||||
| # Run weekly on Sunday at 3 AM UTC | ||||||
| - cron: '0 3 * * 0' | ||||||
| pull_request: | ||||||
| paths: | ||||||
| - '**/package.json' | ||||||
| - '**/package-lock.json' | ||||||
| - '**/pnpm-lock.yaml' | ||||||
| - '**/requirements*.txt' | ||||||
| - '**/pyproject.toml' | ||||||
| - '.github/workflows/depcheck.yml' | ||||||
|
|
||||||
| # Cancel in-progress runs for the same branch | ||||||
| concurrency: | ||||||
| group: ${{ github.workflow }}-${{ github.ref }} | ||||||
| cancel-in-progress: true | ||||||
|
|
||||||
| jobs: | ||||||
| # Detect which parts of the project have changed | ||||||
| changes: | ||||||
| name: Detect Changes | ||||||
| runs-on: ubuntu-latest | ||||||
| timeout-minutes: 5 | ||||||
| outputs: | ||||||
| frontend: ${{ steps.filter.outputs.frontend }} | ||||||
| backend: ${{ steps.filter.outputs.backend }} | ||||||
| ai-engine: ${{ steps.filter.outputs.ai-engine }} | ||||||
| steps: | ||||||
| - name: Checkout code | ||||||
| uses: actions/checkout@v6 | ||||||
|
|
||||||
| - name: Filter paths | ||||||
| id: filter | ||||||
| run: | | ||||||
| echo "Checking for changes in frontend, backend, and ai-engine..." | ||||||
|
|
||||||
| # Check frontend changes | ||||||
| if git diff --name-only main...HEAD | grep -q "frontend/"; then | ||||||
| echo "frontend=true" >> $GITHUB_OUTPUT | ||||||
| else | ||||||
| echo "frontend=false" >> $GITHUB_OUTPUT | ||||||
| fi | ||||||
|
|
||||||
| # Check backend changes | ||||||
| if git diff --name-only main...HEAD | grep -q "backend/"; then | ||||||
| echo "backend=true" >> $GITHUB_OUTPUT | ||||||
| else | ||||||
| echo "backend=false" >> $GITHUB_OUTPUT | ||||||
| fi | ||||||
|
|
||||||
| # Check ai-engine changes | ||||||
| if git diff --name-only main...HEAD | grep -q "ai-engine/"; then | ||||||
| echo "ai-engine=true" >> $GITHUB_OUTPUT | ||||||
| else | ||||||
| echo "ai-engine=false" >> $GITHUB_OUTPUT | ||||||
| fi | ||||||
|
|
||||||
| echo "Frontend changed: ${{ steps.filter.outputs.frontend }}" | ||||||
| echo "Backend changed: ${{ steps.filter.outputs.backend }}" | ||||||
| echo "AI-Engine changed: ${{ steps.filter.outputs.ai-engine }}" | ||||||
|
|
||||||
| # Frontend: depcheck for npm/TypeScript dependencies | ||||||
| depcheck-frontend: | ||||||
| name: Depcheck - Frontend | ||||||
| runs-on: ubuntu-latest | ||||||
| needs: changes | ||||||
| if: ${{ needs.changes.outputs.frontend == 'true' || github.event.inputs.full_audit == 'true' }} | ||||||
|
||||||
| if: ${{ needs.changes.outputs.frontend == 'true' || github.event.inputs.full_audit == 'true' }} | |
| if: ${{ needs.changes.outputs.frontend == 'true' || github.event.inputs.full_audit == 'true' || github.event_name == 'schedule' }} |
Copilot
AI
Mar 8, 2026
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.
Same issue as the frontend job: on schedule triggers, this condition will always be false because github.event.inputs.full_audit is not available. Add || github.event_name == 'schedule' to ensure the weekly scan runs.
Copilot
AI
Mar 8, 2026
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.
pipdeptree --warn fail does not detect unused dependencies. It only detects dependency conflicts (version mismatches between installed packages). The step description says "check for unused dependencies" but pipdeptree is not designed for that purpose. For detecting unused Python imports/dependencies, consider tools like deptry which actually analyze source code to find unused dependencies. The current implementation will give a false sense of security regarding unused packages.
Copilot
AI
Mar 8, 2026
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.
Same issue as the frontend and backend jobs: on schedule triggers, this condition will always be false. Add || github.event_name == 'schedule' to ensure the weekly scan runs.
| if: ${{ needs.changes.outputs.ai-engine == 'true' || github.event.inputs.full_audit == 'true' }} | |
| if: ${{ needs.changes.outputs.ai-engine == 'true' || github.event.inputs.full_audit == 'true' || github.event_name == 'schedule' }} |
Copilot
AI
Mar 8, 2026
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.
Same issue as in the backend job: pipdeptree --warn fail detects dependency conflicts, not unused dependencies. The comment and output message claiming it checks for "unused dependencies" is misleading.
Copilot
AI
Mar 8, 2026
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.
Shell syntax error: there's an extra closing bracket ]] on this line. elif [ "${{ needs.depcheck-frontend.result }}" == "skipped" ]]; then should be elif [ "${{ needs.depcheck-frontend.result }}" == "skipped" ]; then (single ]). This will cause a bash syntax error and the summary job will fail.
| elif [ "${{ needs.depcheck-frontend.result }}" == "skipped" ]]; then | |
| elif [ "${{ needs.depcheck-frontend.result }}" == "skipped" ]; then |
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.
The
changesjob checkout does not includefetch-depth: 0, sogit diff --name-only main...HEADwill fail because themainref won't be available in a shallow clone. The CI workflow (ci.yml) correctly usesfetch-depth: 0for its change detection. Additionally, onscheduleandworkflow_dispatch(withoutfull_audit) triggers, HEAD is the default branch (main), somain...HEADwill show no changes and all jobs will be skipped — the weekly scheduled scan will never actually run any audits. Consider usingfetch-depth: 0and adding|| github.event_name == 'schedule'to the job conditions so scheduled runs audit everything.