Skip to content

feat : static analysis for GO and JS #155

Merged
khareyash05 merged 2 commits intokeploy:dev-review-setupfrom
EuclidStellar:dev-review-setup
Jun 27, 2025
Merged

feat : static analysis for GO and JS #155
khareyash05 merged 2 commits intokeploy:dev-review-setupfrom
EuclidStellar:dev-review-setup

Conversation

@EuclidStellar
Copy link
Copy Markdown

feat(ci): Optimize Static Analysis Workflow for Monorepo

This pull request overhauls our static analysis CI workflow (go-static-analysis.yml) with a dynamic, path-aware matrix, improving performance, cost-efficiency, and maintainability in a large monorepo environment.


Summary of Improvements

Feature Description
Dynamic Matrix Runs static analysis only on changed project directories using dorny/paths-filter.
Concurrency Control Prevents redundant runs by cancelling outdated workflow executions automatically.
Auto Project Bootstrap Automatically sets up go.mod, package.json, and eslint.config.mjs if missing.
Cleaner CI Only relevant jobs are triggered — no more cluttered "Checks" tab.
Cost Efficiency Reduces runner usage by 90%+ in repos with 20+ subfolders.

Example Code

# Job 1: Determines which directories have changed
filter:
  name: Determine Changed Directories
  runs-on: ubuntu-latest
  outputs:
    go_matrix: ${{ steps.matrix_builder.outputs.go_matrix }}
    js_matrix: ${{ steps.matrix_builder.outputs.js_matrix }}
  steps:
    # ... steps to filter paths and build matrix ...

# Job 2 & 3: Use the dynamic matrix
lint_and_fix_go:
  needs: filter
  if: ${{ needs.filter.outputs.go_matrix != '[]' }}
  strategy:
    matrix:
      working-directory: ${{ fromJSON(needs.filter.outputs.go_matrix) }}

🧪 Real-world Verification

Below are tested examples confirming correct behavior for both error and error-free cases, even for nested subdirectories.

Scenario Pull Request Workflow Run Status
❌ PR with Static Errors #86 Workflow Link ✅ Errors Detected
✅ PR with No Static Errors #87 Workflow Link ✅ Passed Cleanly

Automatic Setup Details

Language Auto Setup When Missing Description
Go go mod init, go mod tidy Ensures Go modules are configured correctly without manual intervention.
JavaScript package.json, eslint.config.mjs Bootstraps minimal config to allow linting and scaling new folders easily.

📈 Optimized for Large Monorepos

Designed to scale with 20, 50, or 100+ folders without overwhelming CI.

Benefits:

  • Faster feedback (runs only relevant jobs).
  • Smarter CI (path-based triggers).
  • Minimal noise in PR checks.
  • Reduced costs for self-hosted or GitHub-hosted runners.

🧰 Tech Used

  • dorny/paths-filter: For diff-based folder detection.
  • GitHub Actions Matrix Strategy: Dynamically created for scoped jobs.
  • Custom Bash logic: For conditional go and js tool setup.

flowchart TD
%% === Trigger ===
START([🚀 Pull Request Trigger]) --> TRIGGER{📋 Check Conditions}
TRIGGER -->|✅ Matched| CONCURRENCY[🔒 Concurrency Control]
TRIGGER -->|❌ Skipped| SKIP([🚫 Exit Workflow])

%% === Filter Changed Paths ===
CONCURRENCY --> FILTER[🔍 Run dorny/paths-filter]
FILTER --> MATRIX{🔧 Build Matrix from Changed Paths}

MATRIX -->|Go| GO_MATRIX[📁 Changed Go Dirs]
MATRIX -->|JS| JS_MATRIX[📁 Changed JS Dirs]
MATRIX -->|None| END_NO_CHANGES([✅ No Changes Found])

%% === Go Linting ===
GO_MATRIX --> GO_JOB{🐹 Run Go Lint?}
GO_JOB -->|Yes| GO_LINT[🔍 GolangCI-Lint via Reviewdog]
GO_JOB -->|No| SKIP_GO([⏭️ Skip Go])

%% === JS Linting ===
JS_MATRIX --> JS_JOB{🟨 Run JS Lint?}
JS_JOB -->|Yes| JS_LINT[🔍 ESLint via Reviewdog]
JS_JOB -->|No| SKIP_JS([⏭️ Skip JS])

%% === Results ===
GO_LINT --> RESULTS
JS_LINT --> RESULTS
SKIP_GO --> RESULTS
SKIP_JS --> RESULTS
END_NO_CHANGES --> RESULTS

RESULTS -->|✅ All Passed| SUCCESS([🎉 Workflow Success])
RESULTS -->|❌ Issues Found| FAILURE([🔴 Fix Issues])

%% === Styling with Better Contrast ===
classDef startEnd fill:#e3f2fd,stroke:#1976d2,stroke-width:3px,color:#000000
classDef decision fill:#fff3e0,stroke:#f57c00,stroke-width:2px,color:#000000
classDef linting fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px,color:#000000
classDef skip fill:#f5f5f5,stroke:#616161,stroke-width:2px,color:#424242
classDef result fill:#e8f5e8,stroke:#2e7d32,stroke-width:3px,color:#000000
classDef error fill:#ffebee,stroke:#c62828,stroke-width:3px,color:#000000

class START,SKIP startEnd
class TRIGGER,MATRIX,GO_JOB,JS_JOB decision
class CONCURRENCY,FILTER,GO_LINT,JS_LINT linting
class SKIP_GO,SKIP_JS,END_NO_CHANGES skip
class RESULTS,SUCCESS result
class FAILURE error

Loading

@keploy
Copy link
Copy Markdown

keploy Bot commented Jun 26, 2025

Keploy failed to create test cases for this PR. For retrying, please click here

@khareyash05 khareyash05 merged commit a7fd44c into keploy:dev-review-setup Jun 27, 2025
3 of 4 checks passed
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.

2 participants