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

Add a CI testing workflow #40

Open
MikeMcC399 opened this issue Aug 19, 2024 · 2 comments
Open

Add a CI testing workflow #40

MikeMcC399 opened this issue Aug 19, 2024 · 2 comments

Comments

@MikeMcC399
Copy link
Contributor

What would you like?

Add a GitHub Actions Continuous Integration (CI) workflow to test commits to the repo.

The workflow should run available tests such as defined in package.json

"scripts": {
"lint": "eslint .",
"test": "nyc mocha tests --recursive",
"integration-test": "npx eslint examples/test.js --no-ignore"
},

Why is this needed?

There is no CI workflow in the repo so it is possible for problems to stay unnoticed.

Currently the following fail:

Other

Current results:

$ npm ci
npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error
npm error While resolving: @babel/[email protected]
npm error Found: [email protected]
npm error node_modules/eslint
npm error   dev eslint@"^9.3.0" from the root project
npm error   peer eslint@"^6.0.0 || ^7.0.0 || >=8.0.0" from @eslint-community/[email protected]
npm error   node_modules/@eslint-community/eslint-utils
npm error     @eslint-community/eslint-utils@"^4.2.0" from [email protected]
npm error
npm error Could not resolve dependency:
npm error peer eslint@"^7.5.0 || ^8.0.0" from @babel/[email protected]
npm error node_modules/@babel/eslint-parser
npm error   dev @babel/eslint-parser@"^7.23.3" from the root project
npm error
npm error Conflicting peer dependency: [email protected]
npm error node_modules/eslint
npm error   peer eslint@"^7.5.0 || ^8.0.0" from @babel/[email protected]
npm error   node_modules/@babel/eslint-parser
npm error     dev @babel/eslint-parser@"^7.23.3" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.

$ npm run lint

> [email protected] lint
> eslint .

$ npm run test

> [email protected] test
> nyc mocha tests --recursive

  no-unused-expressions
    valid
      √ function f(){}
      √ a = b
      √ new a
      √ {}
      √ f(); g()
      √ i++
      √ a()
      √ a && a()
      √ a() || (b = c)
      √ a ? b() : c()
      √ a ? b() || (c = d) : e()
      √ delete foo.bar
      √ void new C
      √ "use strict";
      √ "directive one"; "directive two"; f();
      √ function foo() {"use strict"; return true; }
      √ var foo = () => {"use strict"; return true; }
      √ function foo() {"directive one"; "directive two"; f(); }
      √ function foo() { var foo = "use strict"; return true; }
      √ function* foo(){ yield 0; }
      √ async function foo() { await 5; }
      √ async function foo() { await foo.bar; }
      √ async function foo() { bar && await baz; }
      √ async function foo() { foo ? await bar : await baz; }
      √ tag`tagged template literal`
      √ shouldNotBeAffectedByAllowTemplateTagsOption()
      √ import("foo")
      √ func?.("foo")
      √ obj?.foo("bar")
      √ <div />
      √ <></>
      √ var partial = <div />
      √ var partial = <div />
      √ var partial = <></>
      √ expect(foo).to.be.true;
      √ expect(foo).to.have.a.property('bar').which.is.true
      √ foo.should.be.true;
      √ foo.inner.nested.should.be.true
      √ foo.should.have.a.property('bar').which.is.true;
      √ foo?.should.be.true;
      √ foo?.bar?.should.be.true;
      √ expect(foo?.bar).should.be.true;
    invalid
      √ 0
      √ a
      √ f(), 0
      √ {0}
      √ []
      √ a && b();
      √ a() || false
      √ a || (b = c)
      √ a ? b() || (c = d) : e
      √ `untagged template literal`
      √ tag`tagged template literal`
      √ a && b()
      √ a ? b() : c()
      √ a || b
      √ a() && b
      √ a ? b : 0
      √ a ? b : c()
      √ foo.bar;
      √ !a
      √ +a
      √ "directive one"; f(); "directive two";
      √ function foo() {"directive one"; f(); "directive two"; }
      √ if (0) { "not a directive"; f(); }
      √ function foo() { var foo = true; "use strict"; }
      √ var foo = () => { var foo = true; "use strict"; }
      √ `untagged template literal`
      √ `untagged template literal`
      √ tag`tagged template literal`
      √ obj?.foo
      √ obj?.foo.bar
      √ obj?.foo().bar
      √ <div />
      √ <></>
      √ class C { static { 'use strict'; } }
      √ class C { static {
'foo'
'bar'
 } }
      √ foo.expect('bar').not.to.pass;
      √ should.not.pass;
      √ foo?.expect.to.be.true;
      √ foo?.bar?.expect.to.be.true;


  81 passing (131ms)

--------------------------|---------|----------|---------|---------|-------------------
File                      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
--------------------------|---------|----------|---------|---------|-------------------
All files                 |   96.88 |    94.03 |     100 |   96.83 |
 no-unused-expressions.js |   96.88 |    94.03 |     100 |   96.83 | 207,251
--------------------------|---------|----------|---------|---------|-------------------

$ npm run integration-test

> [email protected] integration-test
> npx eslint examples/test.js --no-ignore

  9:1  error  Expected an assignment or function call and instead saw an expression  chai-friendly/no-unused-expressions

✖ 1 problem (1 error, 0 warnings)
@ihordiachenko
Copy link
Owner

Hi @MikeMcC399. Just to clarify, the integration-test script works as expected. It runs eslint on a file that contains a valid expect/should usage examples and a basic case for the no-unused-expressions rule:

// this should cause unused expression error
const foo = {bar: 'baz'};
foo.bar;

@MikeMcC399
Copy link
Contributor Author

@ihordiachenko

Thanks for the explanation! integration-test should probably not be part of any new CI workflow in that case.

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

No branches or pull requests

2 participants