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

fix: Do not exit in test environment #228

Merged
merged 1 commit into from
May 6, 2024

Conversation

chloe463
Copy link
Contributor

@chloe463 chloe463 commented May 3, 2024

Hi!

Thank you for creating this useful GitHub Action! I've found it to be incredibly helpful.

However, I encountered an issue while running the tests. Specifically, the test suite seems to exit prematurely, resulting in some tests not being executed.

This PR aims to address this issue and ensure that all tests are run to completion. I would appreciate your review and feedback. Thank you!

Test log - AsIs
$ npm run test

> npm-install@0.0.0-development pretest
> npm run build


> npm-install@0.0.0-development build
> ncc build -o dist index.js

ncc: Version 0.38.1
ncc: Compiling file index.js into CJS
   1kB  dist/thread.js
2369kB  dist/index.js
2370kB  [928ms] - ncc 0.38.1

> npm-install@0.0.0-development test
> npm run unit


> npm-install@0.0.0-development unit
> mocha test/helper 'test/*spec.js'



  action
    finds Yarn
::debug::usePackageLock? true
::debug::useRollingCache? false
::debug::cache prefix ""
::debug::iterating over working 1 folder(s)
::debug::usePackageLock? true
::debug::working directory /path/to/mock/cwd
::debug::yarn lock file "/path/to/mock/cwd/yarn.lock" exists? true
::debug::lock filename /path/to/mock/cwd/yarn.lock
::debug::file hash hash-from-yarn-lock-file
::debug::platform and arch platform-arch
trying to restore cached NPM modules
cache key yarn-platform-arch-hash-from-yarn-lock-file
restore keys [ 'yarn-platform-arch-hash-from-yarn-lock-file', [length]: 1 ]
input paths [ '/home/path/for/test/user/.cache/yarn', [length]: 1 ]
npm cache hit key false
installing NPM dependencies using Yarn
yarn at "/path/to/yarn"
::debug::yarn command: "/path/to/yarn" --frozen-lockfile {"cwd":"/path/to/mock/cwd"}
saving NPM modules under key yarn-platform-arch-hash-from-yarn-lock-file
input paths: [ '/home/path/for/test/user/.cache/yarn', [length]: 1 ]
npm cache saved for key yarn-platform-arch-hash-from-yarn-lock-file, took 0ms
::debug::installing in /path/to/mock/cwd took 2ms

Test log - ToBe
$ npm run test

> npm-install@0.0.0-development pretest
> npm run build


> npm-install@0.0.0-development build
> ncc build -o dist index.js

ncc: Version 0.38.1
ncc: Compiling file index.js into CJS
   1kB  dist/thread.js
2369kB  dist/index.js
2370kB  [944ms] - ncc 0.38.1

> npm-install@0.0.0-development test
> NODE_ENV=test npm run unit


> npm-install@0.0.0-development unit
> mocha test/helper 'test/*spec.js'



  action
    finds Yarn
::debug::usePackageLock? true
::debug::useRollingCache? false
::debug::cache prefix ""
::debug::iterating over working 1 folder(s)
::debug::usePackageLock? true
::debug::working directory /path/to/mock/cwd
::debug::yarn lock file "/path/to/mock/cwd/yarn.lock" exists? true
::debug::lock filename /path/to/mock/cwd/yarn.lock
::debug::file hash hash-from-yarn-lock-file
::debug::platform and arch platform-arch
trying to restore cached NPM modules
cache key yarn-platform-arch-hash-from-yarn-lock-file
restore keys [ 'yarn-platform-arch-hash-from-yarn-lock-file', [length]: 1 ]
input paths [ '/home/path/for/test/user/.cache/yarn', [length]: 1 ]
npm cache hit key false
installing NPM dependencies using Yarn
yarn at "/path/to/yarn"
::debug::yarn command: "/path/to/yarn" --frozen-lockfile {"cwd":"/path/to/mock/cwd"}
saving NPM modules under key yarn-platform-arch-hash-from-yarn-lock-file
input paths: [ '/home/path/for/test/user/.cache/yarn', [length]: 1 ]
npm cache saved for key yarn-platform-arch-hash-from-yarn-lock-file, took 0ms
::debug::installing in /path/to/mock/cwd took 2ms
      ✓ and uses lock file
    does not find Yarn and uses NPM
      finds npm-shrinkwrap.json
::debug::usePackageLock? true
::debug::useRollingCache? false
::debug::cache prefix ""
::debug::iterating over working 1 folder(s)
::debug::usePackageLock? true
::debug::working directory /path/to/mock/cwd
::debug::yarn lock file "/path/to/mock/cwd/yarn.lock" exists? false
::debug::lock filename /path/to/mock/cwd/npm-shrinkwrap.json
::debug::file hash hash-from-npm-shrinkwrap-file
::debug::platform and arch platform-arch
trying to restore cached NPM modules
cache key npm-platform-arch-hash-from-npm-shrinkwrap-file
restore keys [ 'npm-platform-arch-hash-from-npm-shrinkwrap-file', [length]: 1 ]
input paths [ '/home/path/for/test/user/.npm', [length]: 1 ]
npm cache hit key false
installing NPM dependencies
npm at "/path/to/npm"
::debug::npm command: "/path/to/npm" ci {"cwd":"/path/to/mock/cwd"}
saving NPM modules under key npm-platform-arch-hash-from-npm-shrinkwrap-file
input paths: [ '/home/path/for/test/user/.npm', [length]: 1 ]
npm cache saved for key npm-platform-arch-hash-from-npm-shrinkwrap-file, took 0ms
::debug::installing in /path/to/mock/cwd took 1ms
        ✓ uses npm-shrinkwrap.json and NPM
      finds package-lock.json
::debug::usePackageLock? true
::debug::useRollingCache? false
::debug::cache prefix ""
::debug::iterating over working 1 folder(s)
::debug::usePackageLock? true
::debug::working directory /path/to/mock/cwd
::debug::yarn lock file "/path/to/mock/cwd/yarn.lock" exists? false
::debug::lock filename /path/to/mock/cwd/package-lock.json
::debug::file hash hash-from-package-lock-file
::debug::platform and arch platform-arch
trying to restore cached NPM modules
cache key npm-platform-arch-hash-from-package-lock-file
restore keys [ 'npm-platform-arch-hash-from-package-lock-file', [length]: 1 ]
input paths [ '/home/path/for/test/user/.npm', [length]: 1 ]
npm cache hit key false
installing NPM dependencies
npm at "/path/to/npm"
::debug::npm command: "/path/to/npm" ci {"cwd":"/path/to/mock/cwd"}
saving NPM modules under key npm-platform-arch-hash-from-package-lock-file
input paths: [ '/home/path/for/test/user/.npm', [length]: 1 ]
npm cache saved for key npm-platform-arch-hash-from-package-lock-file, took 0ms
::debug::installing in /path/to/mock/cwd took 0ms
        ✓ uses package-lock.json and NPM
    useLockFile:0
::debug::usePackageLock? false
::debug::useRollingCache? false
::debug::cache prefix ""
::debug::iterating over working 1 folder(s)
::debug::usePackageLock? false
::debug::working directory /path/to/mock/cwd
::debug::lock filename /path/to/mock/cwd/package.json
::debug::file hash hash-from-package-json
::debug::platform and arch platform-arch
installing NPM dependencies
npm at "/path/to/npm"
::debug::npm command: "/path/to/npm" install {"cwd":"/path/to/mock/cwd"}
::debug::installing in /path/to/mock/cwd took 0ms
      ✓ hits the cache
::debug::usePackageLock? false
::debug::useRollingCache? false
::debug::cache prefix ""
::debug::iterating over working 1 folder(s)
::debug::usePackageLock? false
::debug::working directory /path/to/mock/cwd
::debug::lock filename /path/to/mock/cwd/package.json
::debug::file hash hash-from-package-json
::debug::platform and arch platform-arch
installing NPM dependencies
npm at "/path/to/npm"
::debug::npm command: "/path/to/npm" install {"cwd":"/path/to/mock/cwd"}
::debug::installing in /path/to/mock/cwd took 0ms
      ✓ saves new cache
    multiple working directories
::debug::usePackageLock? true
::debug::useRollingCache? false
::debug::cache prefix ""
::debug::iterating over working 3 folder(s)
::debug::installing in subfolder/foo took 0ms
::debug::installing in subfolder/bar took 0ms
::debug::installing in subfolder/baz took 0ms
      ✓ iterates over each working directory
    with useRollingCache option enabled
::debug::usePackageLock? true
::debug::useRollingCache? true
::debug::cache prefix ""
::debug::iterating over working 1 folder(s)
::debug::usePackageLock? true
::debug::working directory /path/to/mock/cwd
::debug::yarn lock file "/path/to/mock/cwd/yarn.lock" exists? true
::debug::lock filename /path/to/mock/cwd/yarn.lock
::debug::file hash hash-from-yarn-lock-file
::debug::platform and arch platform-arch
trying to restore cached NPM modules
cache key yarn-platform-arch-2020-1-hash-from-yarn-lock-file
restore keys [
  'yarn-platform-arch-2020-1-hash-from-yarn-lock-file',
  'yarn-platform-arch-2020-1',
  [length]: 2
]
input paths [ '/home/path/for/test/user/.cache/yarn', [length]: 1 ]
npm cache hit key false
installing NPM dependencies using Yarn
yarn at "/path/to/yarn"
::debug::yarn command: "/path/to/yarn" --frozen-lockfile {"cwd":"/path/to/mock/cwd"}
saving NPM modules under key yarn-platform-arch-2020-1-hash-from-yarn-lock-file
input paths: [ '/home/path/for/test/user/.cache/yarn', [length]: 1 ]
npm cache saved for key yarn-platform-arch-2020-1-hash-from-yarn-lock-file, took 0ms
::debug::installing in /path/to/mock/cwd took 0ms
      ✓ finds yarn and uses lock file
    cache failure
::debug::usePackageLock? false
::debug::useRollingCache? false
::debug::cache prefix ""
::debug::iterating over working 1 folder(s)
::debug::usePackageLock? false
::debug::working directory /path/to/mock/cwd
::debug::lock filename /path/to/mock/cwd/package.json
::debug::file hash hash-from-package-json
::debug::platform and arch platform-arch
trying to restore cached NPM modules
cache key npm-platform-arch-hash-from-package-json
restore keys [ 'npm-platform-arch-hash-from-package-json', [length]: 1 ]
input paths [ '/home/path/for/test/user/.npm', [length]: 1 ]
installing NPM dependencies
npm at "/path/to/npm"
::debug::npm command: "/path/to/npm" install {"cwd":"/path/to/mock/cwd"}
::debug::installing in /path/to/mock/cwd took 0ms
      ✓ handles restoreCache failure
::debug::usePackageLock? false
::debug::useRollingCache? false
::debug::cache prefix ""
::debug::iterating over working 1 folder(s)
::debug::usePackageLock? false
::debug::working directory /path/to/mock/cwd
::debug::lock filename /path/to/mock/cwd/package.json
::debug::file hash hash-from-package-json
::debug::platform and arch platform-arch
trying to restore cached NPM modules
cache key npm-platform-arch-hash-from-package-json
restore keys [ 'npm-platform-arch-hash-from-package-json', [length]: 1 ]
input paths [ '/home/path/for/test/user/.npm', [length]: 1 ]
npm cache hit key false
installing NPM dependencies
npm at "/path/to/npm"
::debug::npm command: "/path/to/npm" install {"cwd":"/path/to/mock/cwd"}
saving NPM modules under key npm-platform-arch-hash-from-package-json
input paths: [ '/home/path/for/test/user/.npm', [length]: 1 ]
::debug::installing in /path/to/mock/cwd took 1ms
      ✓ handles saveCache failure
    with cachePrefix
::debug::usePackageLock? true
::debug::useRollingCache? true
::debug::cache prefix "my-cache-prefix"
::debug::iterating over working 1 folder(s)
::debug::usePackageLock? true
::debug::working directory /path/to/mock/cwd
::debug::yarn lock file "/path/to/mock/cwd/yarn.lock" exists? true
::debug::lock filename /path/to/mock/cwd/yarn.lock
::debug::file hash hash-from-yarn-lock-file
::debug::platform and arch platform-arch
trying to restore cached NPM modules
cache key yarn-my-cache-prefix-platform-arch-2020-1-hash-from-yarn-lock-file
restore keys [
  'yarn-my-cache-prefix-platform-arch-2020-1-hash-from-yarn-lock-file',
  'yarn-my-cache-prefix-platform-arch-2020-1',
  [length]: 2
]
input paths [ '/home/path/for/test/user/.cache/yarn', [length]: 1 ]
npm cache hit key false
installing NPM dependencies using Yarn
yarn at "/path/to/yarn"
::debug::yarn command: "/path/to/yarn" --frozen-lockfile {"cwd":"/path/to/mock/cwd"}
saving NPM modules under key yarn-my-cache-prefix-platform-arch-2020-1-hash-from-yarn-lock-file
input paths: [ '/home/path/for/test/user/.cache/yarn', [length]: 1 ]
npm cache saved for key yarn-my-cache-prefix-platform-arch-2020-1-hash-from-yarn-lock-file, took 0ms
::debug::installing in /path/to/mock/cwd took 0ms
      ✓ finds yarn and uses lock file

  install command
    using Yarn
installing NPM dependencies using Yarn
yarn at "/path/to/yarn"
::debug::yarn command: "/path/to/yarn" --frozen-lockfile {"cwd":"/current/working/directory"}
      ✓ uses absolute working directory
::set-env name=npm_config_cache::/path/to/user/cache
installing NPM dependencies using Yarn
yarn at "/path/to/yarn"
::debug::yarn command: "/path/to/yarn" --frozen-lockfile {"cwd":"/current/working/directory"}
      ✓ and lock file
::set-env name=npm_config_cache::/path/to/user/cache
installing NPM dependencies using Yarn
yarn at "/path/to/yarn"
::debug::yarn command: "/path/to/yarn"  {"cwd":"/current/working/directory"}
      ✓ without lock file
    using NPM
installing NPM dependencies
npm at "/path/to/npm"
::debug::npm command: "/path/to/npm" ci {"cwd":"/current/working/directory"}
      ✓ uses absolute working directory
installing NPM dependencies
npm at "/path/to/npm"
::debug::npm command: "/path/to/npm" ci {"cwd":"/current/working/directory"}
      ✓ installs using lock file
installing NPM dependencies
npm at "/path/to/npm"
::debug::npm command: "/path/to/npm" install {"cwd":"/current/working/directory"}
      ✓ installs without a lock file
    using custom command
::debug::installing using custom command "my install command"
      ✓ calls exec directly

  misc
    ✓ exports a function
::debug::usePackageLock? true
::debug::useRollingCache? false
::debug::cache prefix ""
::debug::iterating over working 1 folder(s)
::debug::usePackageLock? true
::debug::working directory /Users/tsuyoshi/ghq/github.com/chloe463/npm-install
::debug::yarn lock file "/Users/tsuyoshi/ghq/github.com/chloe463/npm-install/yarn.lock" exists? false
::debug::lock filename /Users/tsuyoshi/ghq/github.com/chloe463/npm-install/package-lock.json
::debug::file hash d139f841b5837ba6641ca74b8e46ec851a1b4ed6ff944c085288c438181762d675a67ed82395b84b03da23a22cd80da2098ceea8e5ceb535cce5c0b20d044752
::debug::platform and arch darwin-arm64
::debug::installing in /Users/tsuyoshi/ghq/github.com/chloe463/npm-install took 1ms
    ✓ cache was not hit
::debug::usePackageLock? true
::debug::useRollingCache? false
::debug::cache prefix ""
::debug::iterating over working 1 folder(s)
::debug::usePackageLock? true
::debug::working directory /Users/tsuyoshi/ghq/github.com/chloe463/npm-install
::debug::yarn lock file "/Users/tsuyoshi/ghq/github.com/chloe463/npm-install/yarn.lock" exists? false
::debug::lock filename /Users/tsuyoshi/ghq/github.com/chloe463/npm-install/package-lock.json
::debug::file hash d139f841b5837ba6641ca74b8e46ec851a1b4ed6ff944c085288c438181762d675a67ed82395b84b03da23a22cd80da2098ceea8e5ceb535cce5c0b20d044752
::debug::platform and arch darwin-arm64
::debug::installing in /Users/tsuyoshi/ghq/github.com/chloe463/npm-install took 1ms
    ✓ cache was hit


  20 passing (27ms)

@chloe463
Copy link
Contributor Author

chloe463 commented May 6, 2024

@bahmutov
Could you review this please?

@bahmutov
Copy link
Owner

bahmutov commented May 6, 2024

Makes sense, let me try releasing it as a fix

@bahmutov bahmutov merged commit bd31b44 into bahmutov:master May 6, 2024
18 of 19 checks passed
Copy link

github-actions bot commented May 6, 2024

🎉 This PR is included in version 1.10.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

None yet

2 participants