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

workflow to run all specs in src/simulator/spec #510

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

gitsofaryan
Copy link
Contributor

@gitsofaryan gitsofaryan commented Mar 7, 2025

Fixes #508

Describe the changes you have made in this PR -

  • Created a new workflow file called something like simulator-tests.yml
  • Sets up Node.js v22 (to match legacy version).

Screenshots of the changes (If any) -

Working
image

Note: Please check Allow edits from maintainers. if you would like us to assist in the PR.

Summary by CodeRabbit

  • New Features
    • Introduced an automated workflow that executes simulator tests on key branch updates to help ensure ongoing product reliability.
  • Style
    • Improved formatting and readability across various components, enhancing overall code maintainability without changing functionality.
  • Chores
    • Updated import paths for useSimulatorMobileStore to relative paths across multiple files for better module resolution.

Copy link
Contributor

coderabbitai bot commented Mar 7, 2025

Walkthrough

A new GitHub Actions workflow for simulator tests has been added. This workflow is triggered on pushes and pull requests to the main branch. It defines a job called run-simulator-tests that runs on the latest Ubuntu runner. The job includes steps for checking out the repository, setting up Node.js version 20, installing dependencies using npm, and executing simulator tests via a specified npm command. Additionally, various files have undergone formatting changes, primarily to improve readability, with import paths for useSimulatorMobileStore updated from absolute to relative paths.

Changes

File(s) Change Summary
.github/workflows/simulator-tests.yml Added a new GitHub Actions workflow that triggers on pushes and pull requests to main. The workflow includes steps for repository checkout, Node.js setup (v20), dependency installation, and running simulator tests.
src/components/Extra.vue Reformatted template and message display sections for improved readability; no functional changes.
src/components/Navbar/Navbar.vue Reformatted <nav> element for readability; updated import path for useSimulatorMobileStore from absolute to relative.
src/components/Navbar/QuickButton/QuickButtonMobile.vue Restructured template to add new UI elements while maintaining existing functionality; updated import path for useSimulatorMobileStore.
src/components/Panels/ElementsPanel/ElementsPanelMobile.vue Restructured template for clarity and improved organization; updated import paths for useSimulatorMobileStore and ElementsType.
src/components/Panels/PropertiesPanel/ModuleProperty/ProjectProperty.vue Updated import path for useSimulatorMobileStore from absolute to relative.
src/components/Panels/PropertiesPanel/PropertiesPanelMobile.vue Updated import path for useSimulatorMobileStore from absolute to relative.
src/components/Panels/TimingDiagramPanel/TimingDiagramButtons.vue Updated import path for useSimulatorMobileStore from absolute to relative.
src/components/Panels/TimingDiagramPanel/TimingDiagramMobile.vue Updated import path for useSimulatorMobileStore from absolute to relative.
src/components/Panels/VerilogEditorPanel/VerilogEditorPanelMobile.vue Updated import path for useSimulatorMobileStore from absolute to relative.
src/components/ReportIssue/ReportIssueButton.vue Updated import path for useSimulatorMobileStore from absolute to relative.
src/pages/simulatorHandler.vue Updated import path for useSimulatorMobileStore from absolute to relative.
src/simulator/src/Verilog2CV.js Updated import path for useSimulatorMobileStore from absolute to relative.
src/simulator/src/circuit.ts Updated import path for useSimulatorMobileStore from absolute to relative.
src/simulator/src/layoutMode.ts Updated import paths for useLayoutStore and useSimulatorMobileStore from absolute to relative.
src/simulator/src/listeners.js Updated import path for useSimulatorMobileStore from absolute to relative.
src/simulator/src/plotArea.js Updated import path for useSimulatorMobileStore from absolute to relative.
src/simulator/src/ux.js Updated import path for useSimulatorMobileStore from absolute to relative.

Sequence Diagram(s)

sequenceDiagram
    participant G as GitHub
    participant W as Workflow Runner
    participant C as Checkout Action
    participant N as Node Setup Action
    participant I as Install Dependencies
    participant T as Test Executor

    G->>W: Trigger workflow (push/PR to main)
    W->>C: Run checkout action
    C-->>W: Repository checked out
    W->>N: Setup Node.js v20
    N-->>W: Node environment ready
    W->>I: Execute 'npm install'
    I-->>W: Dependencies installed
    W->>T: Run simulator tests (npm run test -- src/simulator/spec)
    T-->>W: Test results returned
Loading

Suggested reviewers

  • niladrix719

Poem

I'm a jittery rabbit with a joyful code song,
Watching workflows spring to life all along.
Checkout, Node boot-up, and tests in a row —
My bunny hops dance as the pipelines flow.
With every push and pull, my heart skips a beat,
Celebrating each test run with a whimsical tweet!
🌟🐇 Happy coding, one hop at a time!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 09b2af2 and ec8e1e7.

📒 Files selected for processing (1)
  • .github/workflows/simulator-tests.yml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/simulator-tests.yml
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)

🪧 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.
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

Copy link

netlify bot commented Mar 7, 2025

Deploy Preview for circuitverse ready!

Name Link
🔨 Latest commit ec8e1e7
🔍 Latest deploy log https://app.netlify.com/sites/circuitverse/deploys/67cc4c1765c95f00085f18ef
😎 Deploy Preview https://deploy-preview-510--circuitverse.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 45
Accessibility: 72
Best Practices: 92
SEO: 80
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@gitsofaryan
Copy link
Contributor Author

@vedant-jain03 @niladrix719 @aryanndwi123 created workflow for spec files in src/simulator/spec.

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/simulator-tests.yml (1)

26-28: Dependency Installation Command
The workflow uses npm install to install dependencies. If a package-lock.json or similar exists and reproducibility is critical, consider using npm ci for a cleaner, reproducible build environment.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2a9f309 and 4da202b.

📒 Files selected for processing (1)
  • .github/workflows/simulator-tests.yml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (6)
.github/workflows/simulator-tests.yml (6)

1-2: Workflow Naming is Clear
The workflow name "Simulator Tests" clearly conveys its purpose and aligns with the PR objectives.


3-12: Trigger Event Configuration
The workflow is configured to trigger on both push and pull_request events for the "main" and "dev" branches. This setup meets the project requirements to run tests on relevant branches.


13-16: Job Configuration is Appropriate
The job "run-simulator-tests" is set to run on ubuntu-latest, which is a suitable environment for this workflow.


17-20: Repository Checkout Step
The "Checkout Repository" step correctly uses actions/checkout@v4 to ensure that the source code is available for the test run.


21-25: Node.js Setup Step
The Node.js setup is defined with actions/setup-node@v4 and sets node-version: 22 as specified. Confirm that Node.js 22 is indeed the legacy version consistently used across the project.


29-31: Simulator Test Execution Command
The command npm run test -- src/simulator/spec correctly targets the directory where the simulator specifications reside. Ensure that the test script in package.json supports receiving the additional argument and executes the intended tests.

@niladrix719
Copy link
Member

The tests are failing to even start

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

🔭 Outside diff range comments (1)
src/components/Extra.vue (1)

258-268: ⚠️ Potential issue

Fix TypeScript type annotation in event handler

There's a parsing error in the event handler due to the use of React.MouseEvent type in a Vue component. Update to use TypeScript's native event type.

-        @mousedown="(e: React.MouseEvent) => {
+        @mousedown="(e: MouseEvent) => {
        if(simulationArea.shiftDown == false) {
            simulationArea.shiftDown = true;
            selectMultiple = true;
        }
        else {
            simulationArea.shiftDown = false;
            selectMultiple = false;
            e.preventDefault();
        }
      }"
🧰 Tools
🪛 ESLint

[error] 258-258: Parsing error: Unexpected token :.

(vue/no-parsing-error)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4da202b and 63fed7a.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (17)
  • src/components/Extra.vue (10 hunks)
  • src/components/Navbar/Navbar.vue (2 hunks)
  • src/components/Navbar/QuickButton/QuickButtonMobile.vue (2 hunks)
  • src/components/Panels/ElementsPanel/ElementsPanelMobile.vue (5 hunks)
  • src/components/Panels/PropertiesPanel/ModuleProperty/ProjectProperty/ProjectProperty.vue (1 hunks)
  • src/components/Panels/PropertiesPanel/PropertiesPanelMobile.vue (1 hunks)
  • src/components/Panels/TimingDiagramPanel/TimingDiagramButtons.vue (1 hunks)
  • src/components/Panels/TimingDiagramPanel/TimingDiagramMobile.vue (1 hunks)
  • src/components/Panels/VerilogEditorPanel/VerilogEditorPanelMobile.vue (1 hunks)
  • src/components/ReportIssue/ReportIssueButton.vue (1 hunks)
  • src/pages/simulatorHandler.vue (1 hunks)
  • src/simulator/src/Verilog2CV.js (1 hunks)
  • src/simulator/src/circuit.ts (1 hunks)
  • src/simulator/src/layoutMode.ts (1 hunks)
  • src/simulator/src/listeners.js (1 hunks)
  • src/simulator/src/plotArea.js (1 hunks)
  • src/simulator/src/ux.js (1 hunks)
✅ Files skipped from review due to trivial changes (12)
  • src/simulator/src/circuit.ts
  • src/components/ReportIssue/ReportIssueButton.vue
  • src/pages/simulatorHandler.vue
  • src/simulator/src/Verilog2CV.js
  • src/components/Panels/VerilogEditorPanel/VerilogEditorPanelMobile.vue
  • src/components/Panels/PropertiesPanel/ModuleProperty/ProjectProperty/ProjectProperty.vue
  • src/components/Panels/TimingDiagramPanel/TimingDiagramButtons.vue
  • src/simulator/src/layoutMode.ts
  • src/simulator/src/ux.js
  • src/components/Panels/PropertiesPanel/PropertiesPanelMobile.vue
  • src/simulator/src/listeners.js
  • src/components/Navbar/Navbar.vue
🧰 Additional context used
🪛 ESLint
src/components/Extra.vue

[error] 47-51: Elements in iteration expect to have 'v-bind:key' directives.

(vue/require-v-for-key)


[error] 54-58: Elements in iteration expect to have 'v-bind:key' directives.

(vue/require-v-for-key)


[error] 258-258: Parsing error: Unexpected token :.

(vue/no-parsing-error)

🔇 Additional comments (10)
src/components/Panels/TimingDiagramPanel/TimingDiagramMobile.vue (1)

37-37: Import path updated to use relative path

The import path for useSimulatorMobileStore has been changed from an absolute path using the alias prefix #/ to a relative path. This change appears to be part of a consistent effort across multiple files to standardize import paths.

src/simulator/src/plotArea.js (1)

6-6: Import path updated to use relative path

The import path for useSimulatorMobileStore has been changed from an absolute path using the alias prefix #/ to a relative path. This change is consistent with similar updates across multiple files.

src/components/Navbar/QuickButton/QuickButtonMobile.vue (2)

2-123: Template reformatting and UI enhancements for mobile view

The template has been reformatted with improved indentation and expanded multi-line attributes for better readability. Two significant UI enhancements have been added:

  1. A hamburger menu navigation for mobile users (lines 97-102)
  2. A zoom slider with increment/decrement controls (lines 104-122)

These changes improve the mobile user experience while maintaining existing functionality.


130-130: Import path updated to use relative path

The import path for useSimulatorMobileStore has been changed from an absolute path using the alias prefix #/ to a relative path. This change is consistent with similar updates across multiple files.

src/components/Extra.vue (1)

378-378: Import path updated to use relative path

The import path for useSimulatorMobileStore has been changed from an absolute path using the alias prefix #/ to a relative path. This change is consistent with similar updates across multiple files.

src/components/Panels/ElementsPanel/ElementsPanelMobile.vue (5)

2-148: Improved template formatting

The template section has been reformatted with consistent indentation and spacing, making the component structure more readable while maintaining the same functionality.


200-236: Enhanced watch functions readability

The watch functions have been reformatted with improved indentation and structure, making the code easier to read and maintain.


302-314: Improved type safety with ElementsType

The selectCategory function now uses an explicit ElementsType parameter with a default value, which improves type safety.


325-424: Consistent style section formatting

The style section has been reformatted with consistent indentation and the CSS selectors for scrollbar styling have been logically grouped, improving readability.


158-158:

✅ Verification successful

Import path change from absolute to relative

The import path for useSimulatorMobileStore has been changed from an absolute path (likely #/store/simulatorMobileStore) to a relative path. This appears to be part of a broader effort to standardize import paths across the project as mentioned in the PR summary.

Make sure this change is consistent with the project's conventions for import paths.


🏁 Script executed:

#!/bin/bash
# Check for consistency in import path patterns for this store across the project
rg -l "useSimulatorMobileStore" --type vue | xargs grep -l "from.*store/simulatorMobileStore"

Length of output: 121


Import Path Change Consistency – Manual Verification Required

  • The useSimulatorMobileStore import in src/components/Panels/ElementsPanel/ElementsPanelMobile.vue has been updated from an absolute path (likely #/store/simulatorMobileStore) to a relative path (../../store/simulatorMobileStore), aligning with the PR’s effort to standardize import paths.
  • Our initial automated check using the file type filter (--type vue) resulted in an error (unrecognized file type: vue). This prevents us from conclusively verifying that all .vue files use the correct import pattern.
  • To further verify consistency, you might run an alternative command that explicitly targets Vue files. For example:

Please run this command or manually check that all occurrences of the store import adhere to the project conventions.


🏁 Script executed:

#!/bin/bash
# Re-verify by explicitly searching through .vue files using a glob pattern
rg -g '*.vue' -l "useSimulatorMobileStore" | xargs grep -l "from.*store/simulatorMobileStore"

Length of output: 823


Import Path Update Verified

  • The updated import in src/components/Panels/ElementsPanel/ElementsPanelMobile.vue now correctly uses a relative path (../../store/simulatorMobileStore).
  • A revised search targeting .vue files returned multiple files—including ElementsPanelMobile.vue—that reference store/simulatorMobileStore, which confirms that the project's switch to relative import paths is consistently applied.
  • Please manually confirm that none of these files still use the outdated absolute alias (e.g. #/store/simulatorMobileStore).

Comment on lines +54 to +60
<div
v-for="error in useState().errorMessages"
class="alert alert-danger"
role="alert"
>
{{ error }}
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add key directive to v-for elements

Elements in v-for iterations need to have a unique key for Vue's rendering optimization.

        <div
            v-for="error in useState().errorMessages"
+           :key="error"
            class="alert alert-danger"
            role="alert"
        >
            {{ error }}
        </div>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div
v-for="error in useState().errorMessages"
class="alert alert-danger"
role="alert"
>
{{ error }}
</div>
<div
v-for="error in useState().errorMessages"
:key="error"
class="alert alert-danger"
role="alert"
>
{{ error }}
</div>
🧰 Tools
🪛 ESLint

[error] 54-58: Elements in iteration expect to have 'v-bind:key' directives.

(vue/require-v-for-key)

Comment on lines +47 to +53
<div
v-for="mes in useState().successMessages"
class="alert alert-success"
role="alert"
>
{{ mes }}
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add key directive to v-for elements

Elements in v-for iterations need to have a unique key for Vue's rendering optimization.

        <div
            v-for="mes in useState().successMessages"
+           :key="mes"
            class="alert alert-success"
            role="alert"
        >
            {{ mes }}
        </div>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div
v-for="mes in useState().successMessages"
class="alert alert-success"
role="alert"
>
{{ mes }}
</div>
<div
v-for="mes in useState().successMessages"
:key="mes"
class="alert alert-success"
role="alert"
>
{{ mes }}
</div>
🧰 Tools
🪛 ESLint

[error] 47-51: Elements in iteration expect to have 'v-bind:key' directives.

(vue/require-v-for-key)

@gitsofaryan
Copy link
Contributor Author

@niladrix719 i fixed the prev errors coming while running the workflow. but i think errors are due to the tests fails. PTAL!

@niladrix719
Copy link
Member

try ignoring node_modules and v1/ v0/ dir for now, in the test config

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/simulator-tests.yml (2)

21-25: Node.js Setup Version Mismatch
The step uses Node.js version 20 (node-version: 20), but the PR objective mentions setting up Node.js version 22 to align with the legacy version used in the project. Please verify that the intended Node.js version is correctly specified. If Node.js version 22 is required, consider updating this configuration.

-          node-version: 20
+          node-version: 22

29-31: Test Command Configuration and Directory Exclusions
The command npm run test -- src/simulator/spec appears to be correct for running tests in the specified directory. However, given earlier comments regarding failing tests and the suggestion to ignore directories such as node_modules, v1/, and v0/, please ensure that the test runner configuration (for example, via a configuration file like Jest’s testPathIgnorePatterns) accommodates these exclusions. This will help prevent interference from non-test files.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 63fed7a and 09b2af2.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • .github/workflows/simulator-tests.yml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (5)
.github/workflows/simulator-tests.yml (5)

1-2: Workflow Name is Appropriately Defined
The workflow is named "Simulator Tests," which clearly reflects the intended purpose.


3-11: Workflow Triggers are Properly Configured
The workflow is set to trigger on both push and pull request events on the main branch. This is standard for ensuring CI runs on critical branches.


13-16: Job Definition is Correct
The job "run-simulator-tests" is correctly defined to run on the Ubuntu-latest runner. This setup aligns with typical CI environments.


17-20: Repository Checkout Step is Standard
Using actions/checkout@v4 ensures that the repository is properly cloned, which is a best practice for workflows.


26-28: Dependency Installation Step is Correct
Running npm install is the standard command to install dependencies. No changes are needed here.

@smritigarg
Copy link

@gitsofaryan Could you please try and run the specs and make sure everything passes ?

@gitsofaryan
Copy link
Contributor Author

gitsofaryan commented Mar 8, 2025

image
hey @smritigarg i tried and i guess tests are failing

Running this cmd npm run test -- src/simulator/spec

Copy link
Member

@ThatDeparted2061 ThatDeparted2061 left a comment

Choose a reason for hiding this comment

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

You have done a lot of things in the PR and a few of them make it unprofessional (I am sure you can improve them from next PRs ) :

  1. You have changed the paths from using aliases to a relative path , you should not do this since it breaks the continuity of the code, I am guessing you did this bcoz the tests were failing. Well that is bcoz of inconsistency of the alias declaration in the normal environment and runtime environment, so change that before running tests.

  2. You shoudnt make changes in yml and css etc in the same PR.

Your PR #515 is enough and you should close this one

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.

Create Workflow for simulator tests using yml file
4 participants