buefy / nuxt-buefy

Nuxt Buefy
MIT License
221 stars 33 forks source link

Fix: GitHub Workflow Fails to Publish to `NPM` #139

Closed wesdevpro closed 11 months ago

wesdevpro commented 11 months ago

The Problem: The NPM publish workflow failed to run because no package-lock.json was present in the root directory. This should have been easily generated by running npm install. However, there were some dependency issues involving eslint and some in house dependencies used for configuring eslint in the nuxt-buefy project.

The Presented Solution (in this PR):

  1. Bump our in house eslint-config-buefy to the latest version (v0.0.3)
  2. Roll back eslint in the nuxt-buefy project to v4.18.2 to solve the conflict to allow npm install to generate the package-lock.json file
  3. Add a step to the GitHub Publish Workflow to generate the package-lock.json in the event it is not pushed to GitHub.
wesdevpro commented 11 months ago

@kikuomax @gmercey Circle CI Build Error

Now our Circle Ci tests are failing when the following command is run NODE_OPTIONS=--openssl-legacy-provider yarn test

The Logs

yarn run v1.22.19
$ npm run lint && jest

> nuxt-buefy@0.4.26 lint
> eslint lib test

 FAIL  test/module.test.js
  ● Test suite failed to run

    Vue packages version mismatch:

    - vue@2.7.14
    - vue-server-renderer@2.7.10

    This may cause things to work incorrectly. Make sure to use the same version for both.

      at Object.<anonymous> (node_modules/vue-server-renderer/index.js:8:9)
      at Object.<anonymous> (node_modules/@nuxt/vue-renderer/dist/vue-renderer.js:19:27)
      at Object.<anonymous> (node_modules/@nuxt/server/dist/server.js:19:21)

----------|----------|----------|----------|----------|-------------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files |  Unknown |  Unknown |  Unknown |  Unknown |                   |
----------|----------|----------|----------|----------|-------------------|
Handlebars: Access has been denied to resolve the property "statements" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
Handlebars: Access has been denied to resolve the property "branches" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
Handlebars: Access has been denied to resolve the property "functions" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
Handlebars: Access has been denied to resolve the property "lines" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.827s
Ran all test suites.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Exited with code exit status 1

Note: When I run npm test --openssl-legacy-provider on my local machine (Windows 10), I get the exact same error

Some Questions

  1. Why are we using yarn for testing/development when Buefy/Buefy is using NPM?
  2. Why are the test now failing?
kikuomax commented 11 months ago

@wesdevpro I have investigated the issue, the following error was solved by upgrading nuxt:

Vue packages version mismatch:

    - vue@2.7.14
    - vue-server-renderer@2.7.10

The latest nuxt compatible with Vue 2.x was v2.17.1. After upgrading nuxt, the test failed with another error:

 FAIL  test/module.test.js
  ● Test suite failed to run

    Cannot find module 'node:util' from 'consola.deac7d5a.cjs'

      at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:221:17)
      at Object.<anonymous> (node_modules/consola/dist/shared/consola.deac7d5a.cjs:3:19)

This error suggested that consola package was using a prefixed Node package (node:*) that was introduced since Node v14.18 and v16, but jest-resolve did not understand it. So I also bumped jest to v29.7.0, which I felt too new though, and the test passed.

Bonus: we no longer need NODE_OPTIONS=--openssl-legacy-provider workaround.

codecov-commenter commented 11 months ago

Codecov Report

Merging #139 (02a3507) into master (f4cc5fd) will decrease coverage by 10.00%. The diff coverage is n/a.

@@             Coverage Diff              @@
##            master     #139       +/-   ##
============================================
- Coverage   100.00%   90.00%   -10.00%     
============================================
  Files            1        2        +1     
  Lines            2       20       +18     
  Branches         0        5        +5     
============================================
+ Hits             2       18       +16     
- Misses           0        2        +2     

see 1 file with indirect coverage changes

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

wesdevpro commented 11 months ago

Codecov Report

Merging #139 (f4ad6f0) into master (f4cc5fd) will decrease coverage by 10.00%. The diff coverage is n/a.

@@             Coverage Diff              @@
##            master     #139       +/-   ##
============================================
- Coverage   100.00%   90.00%   -10.00%     
============================================
  Files            1        2        +1     
  Lines            2       20       +18     
  Branches         0        5        +5     
============================================
+ Hits             2       18       +16     
- Misses           0        2        +2     

see 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@kikuomax what is this?

kikuomax commented 11 months ago

Codecov Report

Merging #139 (f4ad6f0) into master (f4cc5fd) will decrease coverage by 10.00%. The diff coverage is n/a.

@@             Coverage Diff              @@
##            master     #139       +/-   ##
============================================
- Coverage   100.00%   90.00%   -10.00%     
============================================
  Files            1        2        +1     
  Lines            2       20       +18     
  Branches         0        5        +5     
============================================
+ Hits             2       18       +16     
- Misses           0        2        +2     

see 1 file with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@kikuomax what is this?

@wesdevpro I don't know. I followed the link "see 1 file ...", and it did not look a big deal.