ipfs / aegir

AEgir - Automated JavaScript project building
https://ipfs.github.io/aegir
Other
97 stars 60 forks source link

`aegir test` is broken #975

Closed SgtPooki closed 2 years ago

SgtPooki commented 2 years ago

Describe the bug When running aegir test, it always attempts to build, but my project is set up to build prior to running test, so this results in duplicated builds.

Additionally, it is passing an invalid flag, --no-bundle to my build command for some reason

To Reproduce Steps to reproduce the behavior:

  1. Run these commands in a *nix type shell.
    git clone git@github.com:ipfs-shipyard/js-pinning-service-http-client.git --branch dependabot/npm_and_yarn/aegir-37.0.15
    cd js-pinning-service-http-client
    npm install && npm run test
  2. see that a build is requested via aegir build

Without passing --build flag

it should default to false, but it doesn't.

> aegir test --types false --progress true
build

> @ipfs-shipyard/pinning-service-client@0.0.1 build
> run-s build:main && run-s post-build "--no-bundle"

> @ipfs-shipyard/pinning-service-client@0.0.1 build:main
> aegir build

[10:43:18] tsc [started]
[10:43:19] tsc [completed]
[10:43:19] esbuild [started]
[10:43:19] esbuild [completed]
ERROR: Invalid Option: --no-bundle
Command failed with exit code 1: npm run build --if-present -- --no-bundle

With --build false

> aegir test --build false --types false --progress true
build

> @ipfs-shipyard/pinning-service-client@0.0.1 build
> run-s build:main && run-s post-build "--no-bundle"

> @ipfs-shipyard/pinning-service-client@0.0.1 build:main
> aegir build

[10:38:19] tsc [started]
[10:38:20] tsc [completed]
[10:38:20] esbuild [started]
[10:38:20] esbuild [completed]
ERROR: Invalid Option: --no-bundle
Command failed with exit code 1: npm run build --if-present -- --no-bundle

After updating build script to be "aegir build"

╰─ ✘ 1 ❯ npm run test                                                                                                            11.96   28.1G   19%   100%  ─╯

> @ipfs-shipyard/pinning-service-client@0.0.1 pretest
> tsc -p tsconfig.MockServerController.json

> @ipfs-shipyard/pinning-service-client@0.0.1 test
> run-s test:*

> @ipfs-shipyard/pinning-service-client@0.0.1 test:browser
> aegir test --target browser

.envrc not found
build

> @ipfs-shipyard/pinning-service-client@0.0.1 build
> aegir build "--no-bundle"

.envrc not found
[11:04:44] tsc [started]
[11:04:45] tsc [completed]

> @ipfs-shipyard/pinning-service-client@0.0.1 postbuild
> cp-cli dist.generated dist/dist.generated

test browser
⠋ Setting up chromium.envrc not found
✔ chromium set up

  Client
    ✅ Can be instantiated
    Operations
Failed to load resource: net::ERR_CONNECTION_REFUSED
http://localhost:3000/start
      1) "before each" hook for "GET: Can get failed Pins"
Failed to load resource: net::ERR_CONNECTION_REFUSED
http://localhost:3000/stop/3000
      2) "after each" hook for "GET: Can get failed Pins"
  1 passing (191ms)
  2 failing
  1) Client
       Operations
         "before each" hook for "GET: Can get failed Pins":
     TypeError: Network request failed
      at file:///fetch-ponyfill/build/fetch-browser.js:550:24

  2) Client
       Operations
         "after each" hook for "GET: Can get failed Pins":
     TypeError: Network request failed
      at file:///fetch-ponyfill/build/fetch-browser.js:550:24

Command failed with exit code 1: pw-test test/**/*.spec.{js,cjs,mjs} test/browser.{js,cjs,mjs} dist/test/**/*.spec.{js,cjs,mjs} dist/test/browser.{js,cjs,mjs} --mode main --config /private/var/folders/bl/_gl5_59s11v7qz5ysd6bfgb00000gn/T/tmp.LiAUXYuO/js-pinning-service-http-client/node_modules/aegir/src/config/pw-test.js --timeout=60000
ERROR: "test:browser" exited with 1.

Expected behavior

  1. Aegir should not try to build by default (the help output says that build defaults to false). So we should not call aegir build if we are not building...
  2. Aegir should respect --build false and -b false and not call aegir build if set to false.
  3. Aegir should not pass --if-present -- --no-bundle. If a build is requested, either:
    1. the user should be aware that a build script is necessary, because the user controls whether aegir is building or not (once this bug is fixed), so user is aware of whether they should have a build script or not.
    2. aegir should call aegir build directly, and not the npm run build version.
  4. Aegir should not assume that someone's npm build script starts and ends with aegir build.

Screenshots N/A

Desktop (please complete the following information):

Additional context This change of functionality is not called out in https://github.com/ipfs/aegir/blob/master/md/migration-to-v37.md

achingbrain commented 2 years ago

I guess we could remove the build step(s) from the test command and require all projects to have a "pretest" script if they need to build before testing?

SgtPooki commented 2 years ago

@achingbrain I think that makes more sense, but we could fix the --build flag too?

github-actions[bot] commented 2 years ago

:tada: This issue has been resolved in version 37.4.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: