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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/simulator-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Runs All Simulator tests

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Execute Simulator tests
run: npm run test
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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

"vue": "^3.2.25",
"vue-i18n": "^9.1.10",
"vue-router": "^4.0.15",
Expand Down
3 changes: 3 additions & 0 deletions src/simulator/spec/bitConvertor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import i18n from '#/locales/i18n';
import { routes } from '#/router';
import vuetify from '#/plugins/vuetify';
import simulator from '#/pages/simulator.vue';
import ResizeObserver from 'resize-observer-polyfill';

global.ResizeObserver = ResizeObserver;

vi.mock('codemirror', async (importOriginal) => {
const actual = await importOriginal();
Expand Down
3 changes: 3 additions & 0 deletions src/simulator/spec/combinationalAnalysis.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import i18n from '#/locales/i18n';
import { routes } from '#/router';
import vuetify from '#/plugins/vuetify';
import simulator from '#/pages/simulator.vue';
import ResizeObserver from 'resize-observer-polyfill';

global.ResizeObserver = ResizeObserver;

vi.mock('codemirror', async (importOriginal) => {
const actual = await importOriginal();
Expand Down
3 changes: 3 additions & 0 deletions src/simulator/spec/complexCircuit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import i18n from '#/locales/i18n';
import { routes } from '#/router';
import vuetify from '#/plugins/vuetify';
import simulator from '#/pages/simulator.vue';
import ResizeObserver from 'resize-observer-polyfill';

global.ResizeObserver = ResizeObserver;

vi.mock('codemirror', async (importOriginal) => {
const actual = await importOriginal();
Expand Down
3 changes: 3 additions & 0 deletions src/simulator/spec/data.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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!


vi.mock('codemirror', async (importOriginal) => {
const actual = await importOriginal();
Expand Down
3 changes: 3 additions & 0 deletions src/simulator/spec/decoders-plexers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import i18n from '#/locales/i18n';
import { routes } from '#/router';
import vuetify from '#/plugins/vuetify';
import simulator from '#/pages/simulator.vue';
import ResizeObserver from 'resize-observer-polyfill';

global.ResizeObserver = ResizeObserver;

vi.mock('codemirror', async (importOriginal) => {
const actual = await importOriginal();
Expand Down
3 changes: 3 additions & 0 deletions src/simulator/spec/gates.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import i18n from '#/locales/i18n';
import { routes } from '#/router';
import vuetify from '#/plugins/vuetify';
import simulator from '#/pages/simulator.vue';
import ResizeObserver from 'resize-observer-polyfill';

global.ResizeObserver = ResizeObserver;

vi.mock('codemirror', async (importOriginal) => {
const actual = await importOriginal();
Expand Down
3 changes: 3 additions & 0 deletions src/simulator/spec/misc.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import i18n from '#/locales/i18n';
import { routes } from '#/router';
import vuetify from '#/plugins/vuetify';
import simulator from '#/pages/simulator.vue';
import ResizeObserver from 'resize-observer-polyfill';

global.ResizeObserver = ResizeObserver;

vi.mock('codemirror', async (importOriginal) => {
const actual = await importOriginal();
Expand Down
3 changes: 3 additions & 0 deletions src/simulator/spec/sequential.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import i18n from '#/locales/i18n';
import { routes } from '#/router';
import vuetify from '#/plugins/vuetify';
import simulator from '#/pages/simulator.vue';
import ResizeObserver from 'resize-observer-polyfill';

global.ResizeObserver = ResizeObserver;

vi.mock('codemirror', async (importOriginal) => {
const actual = await importOriginal();
Expand Down
3 changes: 3 additions & 0 deletions src/simulator/spec/subCircuit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import i18n from '#/locales/i18n';
import { routes } from '#/router';
import vuetify from '#/plugins/vuetify';
import simulator from '#/pages/simulator.vue';
import ResizeObserver from 'resize-observer-polyfill';

global.ResizeObserver = ResizeObserver;

vi.mock('codemirror', async (importOriginal) => {
const actual = await importOriginal();
Expand Down
Loading