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

ci(test): migrate test cmd #8138

Merged
merged 82 commits into from
Aug 23, 2022
Merged

ci(test): migrate test cmd #8138

merged 82 commits into from
Aug 23, 2022

Conversation

ShaMan123
Copy link
Contributor

@ShaMan123 ShaMan123 commented Aug 9, 2022

This PR changes the test cmd to use testem.
This is done so we can stop using fabricjs.com for local browser testing and discontinue any associations between the repos.

I decided to keep going with testem for now.
We can always migrate to karma if we want to.

Later on we can remove the commands of the website... or should I do that here and now?
Should we move all testem files to tests? I think it's better order. Their location is used only by scripts/index DONE

Files

  • workflows - semantic cmd change
  • scripts/index - refactor to support testem + put all local cache files in .fabric folder
  • test/GoldensServer.js - extract from scripts/index, now runs when testem start visual tests
  • testem* - adapted config/test page, moved under test and refactored from json to js
  • test/lib/* - adapted methods
  • rollup.test.config.js - need help here, can't get the tests to build properly

Logging has become silly because the program spawns tests in parallel (node, chrome, firefox) so it logs a mess when --verbose option is set. Well actually it is not that bad because ci runs only one context at a time so there will be no parallel logging there. Only locally, so I think it is fine. The -c,--context option can be used to run a single context. So I can't care less about this. And the test results are dumped to separate files under .fabric so the dev can view it there nice and orderly

Changes

  • tests log only errors (exposed --verbose flag)
    image

  • renamed dev cmd to fabric

What about the rest of the interactive tests on fabricjs.com?

Started another effort migrating benchmarks, will PR in the near future

@ShaMan123 ShaMan123 requested a review from asturur August 9, 2022 16:25
@github-actions
Copy link
Contributor

github-actions bot commented Aug 9, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.06 |     74.5 |   84.49 |   80.64 |                                               
 fabric.js |   82.06 |     74.5 |   84.49 |   80.64 | ...,27517,27527-27571,27679,27766,27970,28111 
-----------|---------|----------|---------|---------|-----------------------------------------------

1 similar comment
@github-actions
Copy link
Contributor

github-actions bot commented Aug 9, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.06 |     74.5 |   84.49 |   80.64 |                                               
 fabric.js |   82.06 |     74.5 |   84.49 |   80.64 | ...,27517,27527-27571,27679,27766,27970,28111 
-----------|---------|----------|---------|---------|-----------------------------------------------

@@ -77,10 +75,12 @@
"commander": "^9.1.0",
"deep-object-diff": "^1.1.7",
"eslint": "^8.21.0",
"fireworm": "^0.7.2",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixes testem ci error

Copy link
Member

Choose a reason for hiding this comment

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

but what is it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the error?
or the package?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I forgot what was the error...

Copy link
Member

Choose a reason for hiding this comment

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

no this package. How does it fix n error?

@github-actions
Copy link
Contributor

github-actions bot commented Aug 9, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |    82.1 |     74.5 |   84.49 |   80.68 |                                               
 fabric.js |    82.1 |     74.5 |   84.49 |   80.68 | ...,27517,27527-27571,27679,27766,27970,28111 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Aug 9, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.06 |     74.5 |   84.49 |   80.64 |                                               
 fabric.js |   82.06 |     74.5 |   84.49 |   80.64 | ...,27517,27527-27571,27679,27766,27970,28111 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Aug 9, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.11 |    74.53 |   84.49 |   80.69 |                                               
 fabric.js |   82.11 |    74.53 |   84.49 |   80.69 | ...,27517,27527-27571,27679,27766,27970,28111 
-----------|---------|----------|---------|---------|-----------------------------------------------

@ShaMan123 ShaMan123 added the CI/CD label Aug 9, 2022
Copy link
Contributor Author

@ShaMan123 ShaMan123 left a comment

Choose a reason for hiding this comment

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

should I remove old-travis-reference.yml?

@github-actions
Copy link
Contributor

github-actions bot commented Aug 9, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.06 |     74.5 |   84.49 |   80.64 |                                               
 fabric.js |   82.06 |     74.5 |   84.49 |   80.64 | ...,27517,27527-27571,27679,27766,27970,28111 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Aug 9, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.06 |     74.5 |   84.49 |   80.64 |                                               
 fabric.js |   82.06 |     74.5 |   84.49 |   80.64 | ...,27517,27527-27571,27679,27766,27970,28111 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Aug 9, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.06 |     74.5 |   84.49 |   80.64 |                                               
 fabric.js |   82.06 |     74.5 |   84.49 |   80.64 | ...,27517,27527-27571,27679,27766,27970,28111 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Aug 19, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.09 |    74.55 |    84.4 |   80.69 |                                               
 fabric.js |   82.09 |    74.55 |    84.4 |   80.69 | ...,27456,27514,27524-27568,27676,27763,27967 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Aug 19, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.04 |    74.52 |    84.4 |   80.63 |                                               
 fabric.js |   82.04 |    74.52 |    84.4 |   80.63 | ...,27456,27514,27524-27568,27676,27763,27967 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Aug 19, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.05 |    74.55 |    84.4 |   80.64 |                                               
 fabric.js |   82.05 |    74.55 |    84.4 |   80.64 | ...,27456,27514,27524-27568,27676,27763,27967 
-----------|---------|----------|---------|---------|-----------------------------------------------

1 similar comment
@github-actions
Copy link
Contributor

github-actions bot commented Aug 19, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.05 |    74.55 |    84.4 |   80.64 |                                               
 fabric.js |   82.05 |    74.55 |    84.4 |   80.64 | ...,27456,27514,27524-27568,27676,27763,27967 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Aug 22, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.09 |    74.56 |   84.41 |   80.68 |                                               
 fabric.js |   82.09 |    74.56 |   84.41 |   80.68 | ...,27458,27516,27526-27570,27678,27765,27969 
-----------|---------|----------|---------|---------|-----------------------------------------------

@asturur
Copy link
Member

asturur commented Aug 22, 2022

I would like the .fabric folder with test_results to be only test_results.
Accessing the hidden folders with the . in front is a pain on a mac, as long as is git ignored we don't care for it to be hidden.

I'm also trying to move the coverage report under the same command but it doesn't seem to work

@@ -53,6 +53,8 @@
"export": "node ./scripts website export",
"build-tests": "rollup -c ./rollup.test.config.js",
"test": "node ./scripts test",
"test:unit-browser": "npm run test -- -s unit -p 8080 -l -c ",
"test:visual-browser": "npm run test -- -s visual -p 8080 -l -c ",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

-c flag is already taken

Copy link
Contributor Author

Choose a reason for hiding this comment

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

make it --coverage

Copy link
Member

Choose a reason for hiding this comment

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

this is the -c flag to append chrome/firefox is not the coverage flag

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so -c chrome,firefox

@ShaMan123
Copy link
Contributor Author

I tried that and didn't get it to work

.addOption(new commander.Option('-c, --context <context...>', 'context to test in').choices(['chrome', 'firefox', 'node']).default(['chrome', 'node']))
.option('-p, --port')
.option('-o, --out <out>', 'path to report test results to')
.option('--clear-cache', 'clear CLI test cache', false)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

You should add the option --coverage here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image
I managed to get it to work only on node
is that enough?

Copy link
Member

Choose a reason for hiding this comment

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

yes coverage needs only node, but results are weird in this screenshot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's only for activeselection

@asturur
Copy link
Member

asturur commented Aug 22, 2022

i wasn't able to move the coverage command, i always get a command that hangs

1 similar comment
@asturur
Copy link
Member

asturur commented Aug 22, 2022

i wasn't able to move the coverage command, i always get a command that hangs

@asturur
Copy link
Member

asturur commented Aug 22, 2022

show you what i did

diff --git a/scripts/index.js b/scripts/index.js
index 546e5ec7..e9802a20 100644
--- a/scripts/index.js
+++ b/scripts/index.js
@@ -148,7 +148,7 @@ function startWebsite() {
     const args = ['run', 'start:dev'];
 
     //  WSL ubuntu
-    // https://github.com/microsoft/WSL/issues/216 
+    // https://github.com/microsoft/WSL/issues/216
     // os.platform() === 'win32' && args.push('--', '--force_polling', '--livereload');
     if (os.platform() === 'win32') {
         console.log(chalk.green('Consider using ubuntu on WSL to run jekyll with the following options:'));
@@ -272,7 +272,7 @@ async function test(suite, tests, options = {}) {
         env: {
             ...process.env,
             TEST_FILES: (tests || []).join(','),
-            NODE_CMD: ['qunit', 'test/node_test_setup.js', 'test/lib'].concat(tests || `test/${suite}`).join(' '),
+            NODE_CMD: [...(options.coverage ? ['nyc --silent']: []), 'qunit', 'test/node_test_setup.js', 'test/lib'].concat(tests || `test/${suite}`).join(' '),
             VERBOSE: Number(options.verbose),
             QUNIT_DEBUG_VISUAL_TESTS: Number(options.debug),
             QUNIT_RECREATE_VISUAL_REFS: Number(options.recreate),
@@ -469,6 +469,7 @@ program
     .option('-p, --port')
     .option('-o, --out <out>', 'path to report test results to')
     .option('--clear-cache', 'clear CLI test cache', false)
+    .option('-cov --coverage', 'Add coverage report with nyc', false)
     .action((options) => {
         if (options.clearCache) {
             fs.removeSync(CLI_CACHE);
@@ -538,4 +539,4 @@ program
         });
     });
 
-program.parse(process.argv);
\ No newline at end of file
+program.parse(process.argv);

i get a twst command that run super slow and make tests fail

@ShaMan123
Copy link
Contributor Author

I did something pretty much the same.
Nothing lags on my machine

@ShaMan123
Copy link
Contributor Author

ShaMan123 commented Aug 22, 2022

- .option('-cov --coverage', 'Add coverage report with nyc', false)
+ .option('-cov, --coverage', 'Add coverage report with nyc', false)

- ...(options.coverage ? ['nyc --silent']: [])
+ ...options.coverage ? 'nyc --silent': ''

@github-actions
Copy link
Contributor

github-actions bot commented Aug 22, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.08 |    74.52 |   84.41 |   80.67 |                                               
 fabric.js |   82.08 |    74.52 |   84.41 |   80.67 | ...,27458,27516,27526-27570,27678,27765,27969 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Aug 22, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.09 |    74.56 |   84.41 |   80.68 |                                               
 fabric.js |   82.09 |    74.56 |   84.41 |   80.68 | ...,27458,27516,27526-27570,27678,27765,27969 
-----------|---------|----------|---------|---------|-----------------------------------------------

@@ -77,10 +75,12 @@
"commander": "^9.1.0",
"deep-object-diff": "^1.1.7",
"eslint": "^8.21.0",
"fireworm": "^0.7.2",
Copy link
Member

Choose a reason for hiding this comment

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

no this package. How does it fix n error?

@asturur asturur merged commit be4c6cf into master Aug 23, 2022
frankrousseau pushed a commit to cgwire/fabric.js that referenced this pull request Jan 6, 2023
Co-authored-by: Andrea Bogazzi <andreabogazzi79@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants