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

Create simulator-tests.yml Workflow for simulator tests #378

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

Conversation

niladrix719
Copy link
Member

@niladrix719 niladrix719 commented Sep 2, 2024

Summary by CodeRabbit

  • New Features
    • Introduced a new automated testing workflow for the simulator, ensuring code reliability on updates to the main branch.
    • Added a new dependency to improve cross-browser handling of resize events, enhancing application responsiveness.
  • Bug Fixes
    • Improved testing capabilities by integrating a polyfill for ResizeObserver, ensuring tests involving responsive design function correctly.

Copy link
Contributor

coderabbitai bot commented Sep 2, 2024

Walkthrough

A new GitHub Actions workflow titled "Runs All Simulator tests" has been established. This workflow triggers on pushes and pull requests to the main branch, executing a job on the latest Ubuntu environment. It utilizes a matrix strategy for Node.js version 20.x, checks out the repository, installs dependencies, and runs simulator tests to ensure code functionality.

Changes

Files Change Summary
.github/workflows/simulator-tests.yml New workflow Runs All Simulator tests created.
package.json Added new dependency resize-observer-polyfill version ^1.5.1.
src/simulator/spec/*.spec.js Imported ResizeObserver from resize-observer-polyfill and assigned to global.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant GitHub Actions
    participant Node.js
    participant Simulator Tests

    Developer->>GitHub Actions: Push or Pull Request to main
    GitHub Actions->>Node.js: Set up Node.js 20.x
    GitHub Actions->>GitHub Actions: Check out code
    GitHub Actions->>Node.js: Install dependencies (npm ci)
    GitHub Actions->>Simulator Tests: Run tests (npm run test)
    Simulator Tests-->>GitHub Actions: Return test results
    GitHub Actions-->>Developer: Notify results
Loading

Poem

🐰 In the meadow where rabbits play,
A workflow hops in, brightening the day.
With tests that run, oh what a sight,
Code stays bouncy, fluffy, and light!
So let’s celebrate with a joyful cheer,
For every change brings us closer, my dear! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
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 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.

@niladrix719 niladrix719 marked this pull request as ready for review September 2, 2024 16:23
Copy link

netlify bot commented Sep 2, 2024

Deploy Preview for circuitverse ready!

Name Link
🔨 Latest commit 746ddef
🔍 Latest deploy log https://app.netlify.com/sites/circuitverse/deploys/66f13b38bf45bc0008e1bc72
😎 Deploy Preview https://deploy-preview-378--circuitverse.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

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

Outside diff range, codebase verification and nitpick comments (1)
.github/workflows/simulator-tests.yml (1)

9-17: Consider renaming the job to "test".

The job name "build" is not very descriptive for a job that runs tests. A more appropriate name would be "test".

Apply this diff to rename the job:

 jobs:
-  build:
+  test:
     runs-on: ubuntu-latest
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between cb13645 and c1519f8.

Files selected for processing (1)
  • .github/workflows/simulator-tests.yml (1 hunks)
Additional comments not posted (4)
.github/workflows/simulator-tests.yml (4)

1-7: LGTM!

The workflow name and trigger events are appropriate for running simulator tests.


18-24: LGTM!

The checkout and Node.js setup steps are correctly configured.


26-27: LGTM!

Using npm ci is the recommended way to install dependencies in CI environments.


28-29: Verify the test script.

Ensure that the test script is defined in package.json and runs the simulator tests.

Run the following script to verify the test script:

If the test script is not defined or does not run the simulator tests, I can help you update the script. Let me know if you would like me to suggest the changes.

.github/workflows/simulator-tests.yml Outdated Show resolved Hide resolved
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c1519f8 and 8e663ce.

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

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8e663ce and 1819323.

Files selected for processing (1)
  • .github/workflows/simulator-tests.yml (1 hunks)
Files skipped from review due to trivial changes (1)
  • .github/workflows/simulator-tests.yml

@niladrix719 niladrix719 requested a review from Arnabdaz September 6, 2024 10:29
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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1819323 and e041978.

Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
Files selected for processing (10)
  • package.json (1 hunks)
  • src/simulator/spec/bitConvertor.spec.js (1 hunks)
  • src/simulator/spec/combinationalAnalysis.spec.js (1 hunks)
  • src/simulator/spec/complexCircuit.spec.js (1 hunks)
  • src/simulator/spec/data.spec.js (1 hunks)
  • src/simulator/spec/decoders-plexers.spec.js (1 hunks)
  • src/simulator/spec/gates.spec.js (1 hunks)
  • src/simulator/spec/misc.spec.js (1 hunks)
  • src/simulator/spec/sequential.spec.js (1 hunks)
  • src/simulator/spec/subCircuit.spec.js (1 hunks)
Additional comments not posted (13)
package.json (1)

36-36: Approved addition of resize-observer-polyfill.

The addition of resize-observer-polyfill version ^1.5.1 is approved as it enhances cross-browser compatibility for resize events. Ensure to verify the compatibility of this new dependency with existing ones to avoid potential conflicts.

src/simulator/spec/subCircuit.spec.js (1)

13-15: Approved import and global assignment of ResizeObserver.

The import of ResizeObserver from resize-observer-polyfill and its assignment to the global scope are approved. Ensure to verify that this global modification does not interfere with existing global properties or lead to unexpected behavior.

Verification successful

Global ResizeObserver Assignment Verified

The global assignment of ResizeObserver is consistently used across multiple test files and is isolated to the testing environment. This ensures it does not interfere with the application runtime or existing global properties. The behavior of ResizeObserver is likely tested within these files, confirming its expected functionality.

  • Files with global ResizeObserver assignment:
    • src/simulator/spec/subCircuit.spec.js
    • src/simulator/spec/misc.spec.js
    • src/simulator/spec/decoders-plexers.spec.js
    • src/simulator/spec/gates.spec.js
    • src/simulator/spec/bitConvertor.spec.js
    • src/simulator/spec/complexCircuit.spec.js
    • src/simulator/spec/data.spec.js
    • src/simulator/spec/sequential.spec.js
    • src/simulator/spec/combinationalAnalysis.spec.js
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of global `ResizeObserver` on the application.

# Test: Search for any issues reported in test logs or runtime errors related to `ResizeObserver`.
echo "Check test logs and runtime errors for any issues related to the global 'ResizeObserver'."

Length of output: 194


Script:

#!/bin/bash
# Search for references to `ResizeObserver` in the codebase to check for potential conflicts.
rg 'ResizeObserver' --context 5

# Search for test cases related to `ResizeObserver` to ensure its behavior is tested.
rg 'ResizeObserver' --glob '*.{spec,test}.*' --context 5

Length of output: 17136

src/simulator/spec/bitConvertor.spec.js (1)

10-12: Approved import and global assignment of ResizeObserver.

The import of ResizeObserver from resize-observer-polyfill and its assignment to the global scope are approved. Ensure to verify the consistency and absence of side effects across different test files.

Verification successful

Consistent Global Assignment of ResizeObserver Across Test Files

The ResizeObserver is consistently imported and assigned to the global scope across multiple test files. This pattern appears intentional to ensure each test suite has its own setup, minimizing side effects. Ensure this approach is documented to maintain clarity and prevent future issues.

  • Files with global ResizeObserver assignment:
    • src/simulator/spec/combinationalAnalysis.spec.js
    • src/simulator/spec/gates.spec.js
    • src/simulator/spec/subCircuit.spec.js
    • src/simulator/spec/decoders-plexers.spec.js
    • src/simulator/spec/sequential.spec.js
    • src/simulator/spec/data.spec.js
    • src/simulator/spec/complexCircuit.spec.js
    • src/simulator/spec/bitConvertor.spec.js
    • src/simulator/spec/misc.spec.js
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the consistency and absence of side effects of global `ResizeObserver` across different test files.

# Test: Search for any inconsistencies or side effects in test files related to `ResizeObserver`.
echo "Check for any inconsistencies or side effects in test files related to the global 'ResizeObserver'."

Length of output: 214


Script:

#!/bin/bash
# Search for occurrences of 'ResizeObserver' in test files to check for inconsistencies or side effects.
rg 'ResizeObserver' --glob '**/*.{spec,test}.*' -A 5

Length of output: 4858

src/simulator/spec/combinationalAnalysis.spec.js (2)

12-12: Approved: Import of ResizeObserver from polyfill.

The import statement correctly includes ResizeObserver from resize-observer-polyfill, ensuring compatibility across environments where this feature may not be natively supported.


14-14: Approved with caution: Assignment of ResizeObserver to global scope.

Assigning ResizeObserver to the global scope ensures it is available throughout the testing environment. However, be cautious with modifications to the global scope as they can lead to side effects that affect other tests or components.

src/simulator/spec/complexCircuit.spec.js (2)

15-15: Approved: Import of ResizeObserver from polyfill.

Consistent with other test files, the import of ResizeObserver from resize-observer-polyfill ensures compatibility and functionality across different testing environments.


17-17: Approved with caution: Assignment of ResizeObserver to global scope.

This assignment ensures that ResizeObserver is available throughout the testing environment. As with other similar modifications, caution is advised to prevent unintended side effects that could affect other tests.

src/simulator/spec/sequential.spec.js (2)

13-13: Approved: Import of ResizeObserver from polyfill.

The import statement is correctly implemented and consistent across the testing suite, ensuring that ResizeObserver is available in environments where it might not be natively supported.


15-15: Approved with caution: Assignment of ResizeObserver to global scope.

This assignment is consistent with other test files and ensures that ResizeObserver is available throughout the testing environment. Caution is advised to manage potential side effects.

src/simulator/spec/gates.spec.js (1)

13-15: Addition of ResizeObserver to the global scope

The import and assignment of ResizeObserver to the global scope are correctly implemented. However, it's important to ensure that this addition does not interfere with existing properties on the global object or cause unexpected side effects in other parts of the application.

Consider adding a check to ensure ResizeObserver is not already defined on the global object before assignment to avoid potential conflicts:

+ if (!global.ResizeObserver) {
+   global.ResizeObserver = ResizeObserver;
+ }
src/simulator/spec/decoders-plexers.spec.js (1)

13-15: Consistent handling of ResizeObserver across test files

The addition of ResizeObserver to the global scope is replicated here as in the gates.spec.js file. Ensure that this pattern is consistently applied across all test files to avoid discrepancies in test environments.

As with the previous file, consider checking if ResizeObserver is already defined on the global object to prevent overwriting:

+ if (!global.ResizeObserver) {
+   global.ResizeObserver = ResizeObserver;
+ }
src/simulator/spec/misc.spec.js (1)

13-15: Uniform handling of ResizeObserver in test files

The import and assignment of ResizeObserver to the global scope are consistent with the other test files. This uniformity is good for maintaining a consistent test environment across different modules.

To prevent potential conflicts with other global properties, it's advisable to check if ResizeObserver is already defined on the global object:

+ if (!global.ResizeObserver) {
+   global.ResizeObserver = ResizeObserver;
+ }
src/simulator/spec/data.spec.js (1)

25-25: Import of ResizeObserver

The import of ResizeObserver from resize-observer-polyfill is correctly implemented. This ensures that the functionality is available in environments where it may not be natively supported.

@@ -22,6 +22,9 @@ import { createRouter, createWebHistory } from 'vue-router';
import i18n from '#/locales/i18n';
import vuetify from '#/plugins/vuetify';
import { routes } from '#/router';
import ResizeObserver from 'resize-observer-polyfill';

global.ResizeObserver = ResizeObserver;
Copy link
Contributor

@coderabbitai coderabbitai bot Sep 6, 2024

Choose a reason for hiding this comment

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

Assignment to global.ResizeObserver

Assigning the imported ResizeObserver to global.ResizeObserver effectively makes it available globally. This is a common practice for polyfills to ensure compatibility across different environments. However, modifying the global object can have side effects if not handled carefully.

Consider adding a check to ensure that global.ResizeObserver is not already defined before assigning it to avoid potential conflicts:

+ if (!global.ResizeObserver) {
+     global.ResizeObserver = ResizeObserver;
+ }
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
global.ResizeObserver = ResizeObserver;
if (!global.ResizeObserver) {
global.ResizeObserver = ResizeObserver;
}

Copy link
Member

Choose a reason for hiding this comment

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

@niladrix719 Why are we always relying on polyfill even if the feature available on the browser ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

@@ -33,6 +33,7 @@
"interactjs": "^1.10.17",
"jquery": "^3.6.0",
"pinia": "^2.0.14",
"resize-observer-polyfill": "^1.5.1",
Copy link
Member

Choose a reason for hiding this comment

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

https://caniuse.com/resizeobserver It is already available on 95% of the browsers, I don't think we should be using this polyfill unless necessary.

Copy link
Member Author

@niladrix719 niladrix719 Sep 12, 2024

Choose a reason for hiding this comment

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

It was working fine locally without any polyfill, but it was failing in the GitHub workflow

https://github.com/CircuitVerse/cv-frontend-vue/actions/runs/10736591287/job/29776330239

@Arnabdaz
Copy link
Member

Arnabdaz commented Sep 23, 2024

@niladrix719 resolve the unresolved conversations

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.

3 participants