sfbrigade / bats-server

Routed is an app to help ambulances direct non-critical patients to hospital emergency rooms with the most availability.
https://routedapp.org/
GNU Affero General Public License v3.0
18 stars 12 forks source link

Use `yarn workspaces` in `package.json` #256

Closed fwextensions closed 1 year ago

fwextensions commented 1 year ago

This is based on #257, so that should be merged first.

fwextensions commented 1 year ago

@francisli the e2e tests are failing on CircleCI for some reason, but I'm not sure why. They run okay locally in docker.

$ yarn workspace e2e test
$ playwright test

Running 4 tests using 1 worker

[WebServer] The prop value with an expression type of ChainExpression could not be resolved. Please file issue to get this fixed immediately.
[WebServer] The prop value with an expression type of ChainExpression could not be resolved. Please file issue to get this fixed immediately.
[WebServer] error Command failed with exit code 1.
Error: Process from config.webServer was not able to start. Exit code: 1

  4 skipped
  1 error was not a part of any test, see above for details
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed.
Exit code: 1
Command: /usr/local/bin/node
Arguments: /opt/yarn-v1.22.18/lib/cli.js test
Directory: /home/circleci/project/e2e
Output:

info Visit https://yarnpkg.com/en/docs/cli/workspace for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
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
CircleCI received exit code 1
francisli commented 1 year ago

@fwextensions hmm, I get the following error/output when trying to rebuild the Docker image in this branch:

% docker compose build --no-cache server                  
[+] Building 43.9s (12/12) FINISHED                                                                                                                                                                                                                  
 => [internal] load build definition from Dockerfile                                                                                                                                                                                            0.0s
 => => transferring dockerfile: 1.02kB                                                                                                                                                                                                          0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                               0.0s
 => => transferring context: 34B                                                                                                                                                                                                                0.0s
 => [internal] load metadata for docker.io/library/node:18.10.0-bullseye                                                                                                                                                                        1.2s
 => [auth] library/node:pull token for registry-1.docker.io                                                                                                                                                                                     0.0s
 => CACHED [1/7] FROM docker.io/library/node:18.10.0-bullseye@sha256:9d8a6466c6385e05f62f8ccf173e80209efb0ff4438f321f09ddf552b05af3ba                                                                                                           0.0s
 => [internal] load build context                                                                                                                                                                                                               0.0s
 => => transferring context: 884.63kB                                                                                                                                                                                                           0.0s
 => [2/7] RUN wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | apt-key add - &&     echo "deb http://apt.postgresql.org/pub/repos/apt/ bullseye-pgdg main" >> /etc/apt/sources.list.d/pgdg.list &&     apt-get update -y &&    8.2s
 => [3/7] RUN echo "export PATH=./node_modules/.bin:$PATH\n" >> /root/.bashrc                                                                                                                                                                   0.3s 
 => [4/7] RUN mkdir -p /opt/node/app                                                                                                                                                                                                            0.2s 
 => [5/7] ADD . /opt/node/app                                                                                                                                                                                                                   0.1s 
 => [6/7] WORKDIR /opt/node/app                                                                                                                                                                                                                 0.0s 
 => ERROR [7/7] RUN yarn install && yarn workspace client build                                                                                                                                                                                33.7s 
------                                                                                                                                                                                                                                               
 > [7/7] RUN yarn install && yarn workspace client build:                                                                                                                                                                                            
#0 0.251 yarn install v1.22.19                                                                                                                                                                                                                       
#0 0.319 [1/5] Validating package.json...                                                                                                                                                                                                            
#0 0.325 [2/5] Resolving packages...                                                                                                                                                                                                                 
#0 0.645 [3/5] Fetching packages...                                                                                                                                                                                                                  
#0 21.44 [4/5] Linking dependencies...
#0 21.45 warning " > eslint-config-react-app@5.2.1" has unmet peer dependency "@typescript-eslint/eslint-plugin@2.x".
#0 21.45 warning " > eslint-config-react-app@5.2.1" has unmet peer dependency "@typescript-eslint/parser@2.x".
#0 21.45 warning "workspace-aggregator-3442f7e4-26f8-4888-91d6-756c0b2c1649 > client > @testing-library/user-event@7.2.1" has unmet peer dependency "@testing-library/dom@>=5".
#0 21.45 warning "workspace-aggregator-3442f7e4-26f8-4888-91d6-756c0b2c1649 > client > sass-loader@10.4.1" has unmet peer dependency "webpack@^4.36.0 || ^5.0.0".
#0 21.45 warning "workspace-aggregator-3442f7e4-26f8-4888-91d6-756c0b2c1649 > client > react-scripts > @typescript-eslint/eslint-plugin > tsutils@3.21.0" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
#0 29.34 [5/5] Building fresh packages...
#0 32.91 error /opt/node/app/node_modules/e2e: Command failed.
#0 32.91 Exit code: 1
#0 32.91 Command: playwright install-deps && playwright install chromium
#0 32.91 Arguments: 
#0 32.91 Directory: /opt/node/app/node_modules/e2e
#0 32.91 Output:
#0 32.91 BEWARE: your OS is not officially supported by Playwright; installing dependencies for Ubuntu as a fallback.
#0 32.91 Installing dependencies...
#0 32.91 Hit:1 http://deb.debian.org/debian bullseye InRelease
#0 32.91 Hit:2 http://deb.debian.org/debian-security bullseye-security InRelease
#0 32.91 Hit:3 http://deb.debian.org/debian bullseye-updates InRelease
#0 32.91 Hit:4 http://apt.postgresql.org/pub/repos/apt bullseye-pgdg InRelease
#0 32.91 Reading package lists...
#0 32.91 Reading package lists...
#0 32.91 Building dependency tree...
#0 32.91 Reading state information...
#0 32.91 Package ttf-ubuntu-font-family is not available, but is referred to by another package.
#0 32.91 This may mean that the package is missing, has been obsoleted, or
#0 32.91 is only available from another source
#0 32.91 
#0 32.91 Package libjpeg-turbo8 is not available, but is referred to by another package.
#0 32.91 This may mean that the package is missing, has been obsoleted, or
#0 32.91 is only available from another source
#0 32.91 
#0 32.91 E: Package 'ttf-ubuntu-font-family' has no installation candidate
#0 32.91 E: Unable to locate package libenchant1c2a
#0 32.91 E: Unable to locate package libicu66
#0 32.91 E: Package 'libjpeg-turbo8' has no installation candidate
#0 32.91 Failed to install browser dependencies
#0 32.91 Error: Installation process exited with code: 100
#0 32.92 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
------
failed to solve: executor failed running [/bin/sh -c yarn install && yarn workspace client build]: exit code: 1
francisli commented 1 year ago

@fwextensions hmm, I've renamed the "install" script in e2e/package.json so it doesn't get called and now I'm getting this:

% docker compose build --no-cache server
[+] Building 49.3s (12/12) FINISHED                                                                                                                                                                                                                  
 => [internal] load build definition from Dockerfile                                                                                                                                                                                            0.0s
 => => transferring dockerfile: 1.02kB                                                                                                                                                                                                          0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                               0.0s
 => => transferring context: 34B                                                                                                                                                                                                                0.0s
 => [internal] load metadata for docker.io/library/node:18.10.0-bullseye                                                                                                                                                                        1.0s
 => [auth] library/node:pull token for registry-1.docker.io                                                                                                                                                                                     0.0s
 => [internal] load build context                                                                                                                                                                                                               0.0s
 => => transferring context: 646.42kB                                                                                                                                                                                                           0.0s
 => CACHED [1/7] FROM docker.io/library/node:18.10.0-bullseye@sha256:9d8a6466c6385e05f62f8ccf173e80209efb0ff4438f321f09ddf552b05af3ba                                                                                                           0.0s
 => [2/7] RUN wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | apt-key add - &&     echo "deb http://apt.postgresql.org/pub/repos/apt/ bullseye-pgdg main" >> /etc/apt/sources.list.d/pgdg.list &&     apt-get update -y &&    7.9s
 => [3/7] RUN echo "export PATH=./node_modules/.bin:$PATH\n" >> /root/.bashrc                                                                                                                                                                   0.2s
 => [4/7] RUN mkdir -p /opt/node/app                                                                                                                                                                                                            0.3s 
 => [5/7] ADD . /opt/node/app                                                                                                                                                                                                                   0.0s 
 => [6/7] WORKDIR /opt/node/app                                                                                                                                                                                                                 0.0s 
 => ERROR [7/7] RUN yarn install && yarn workspace client build                                                                                                                                                                                39.7s 
------                                                                                                                                                                                                                                               
 > [7/7] RUN yarn install && yarn workspace client build:                                                                                                                                                                                            
#0 0.247 yarn install v1.22.19                                                                                                                                                                                                                       
#0 0.313 [1/5] Validating package.json...                                                                                                                                                                                                            
#0 0.319 [2/5] Resolving packages...                                                                                                                                                                                                                 
#0 0.633 [3/5] Fetching packages...                                                                                                                                                                                                                  
#0 20.92 [4/5] Linking dependencies...
#0 20.93 warning " > eslint-config-react-app@5.2.1" has unmet peer dependency "@typescript-eslint/eslint-plugin@2.x".
#0 20.93 warning " > eslint-config-react-app@5.2.1" has unmet peer dependency "@typescript-eslint/parser@2.x".
#0 20.93 warning "workspace-aggregator-6e8b22f7-8970-4727-a1b4-891eb85f0c57 > client > @testing-library/user-event@7.2.1" has unmet peer dependency "@testing-library/dom@>=5".
#0 20.93 warning "workspace-aggregator-6e8b22f7-8970-4727-a1b4-891eb85f0c57 > client > sass-loader@10.4.1" has unmet peer dependency "webpack@^4.36.0 || ^5.0.0".
#0 20.93 warning "workspace-aggregator-6e8b22f7-8970-4727-a1b4-891eb85f0c57 > client > react-scripts > @typescript-eslint/eslint-plugin > tsutils@3.21.0" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
#0 28.91 [5/5] Building fresh packages...
#0 33.52 Done in 33.27s.
#0 33.72 yarn workspace v1.22.19
#0 33.88 yarn run v1.22.19
#0 33.90 $ craco --openssl-legacy-provider build && yarn sass --no-source-map && yarn postcss --no-map
#0 34.49 Creating an optimized production build...
#0 36.58 The prop value with an expression type of ChainExpression could not be resolved. Please file issue to get this fixed immediately.
#0 36.58 The prop value with an expression type of ChainExpression could not be resolved. Please file issue to get this fixed immediately.
#0 39.19 Failed to compile.
#0 39.19 
#0 39.19 ./src/Components/FormComboBox.js
#0 39.19 You attempted to import ../../node_modules/uswds/src/js/components which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
#0 39.19 You can either move it inside src/, or add a symlink to it from project's node_modules/.
#0 39.19 
#0 39.19 
#0 39.28 error Command failed with exit code 1.
#0 39.28 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
#0 39.31 error Command failed.
#0 39.31 Exit code: 1
#0 39.31 Command: /usr/local/bin/node
#0 39.31 Arguments: /opt/yarn-v1.22.19/lib/cli.js build
#0 39.31 Directory: /opt/node/app/client
#0 39.31 Output:
#0 39.31 
#0 39.31 info Visit https://yarnpkg.com/en/docs/cli/workspace for documentation about this command.
------
failed to solve: executor failed running [/bin/sh -c yarn install && yarn workspace client build]: exit code: 1
francisli commented 1 year ago

@fwextensions this is now passing, but I'm still having trouble running the local development server. for some reason, I'm getting this error on startup:

bats-server-server-1  | 10:45:20 PM client.1 |  Failed to compile.
bats-server-server-1  | 10:45:20 PM client.1 |  ../shared/FieldMetadata.js 20:40
bats-server-server-1  | 10:45:20 PM client.1 |  Module parse failed: Unexpected token (20:40)
bats-server-server-1  | 10:45:20 PM client.1 |  File was processed with these loaders:
bats-server-server-1  | 10:45:20 PM client.1 |   * ../node_modules/react-scripts/node_modules/babel-loader/lib/index.js
bats-server-server-1  | 10:45:20 PM client.1 |  You may need an additional loader to handle the result of these loaders.
bats-server-server-1  | 10:45:20 PM client.1 |  |       colName: createColName(field),
bats-server-server-1  | 10:45:20 PM client.1 |  |       isParam: !NonParamTypes.includes(field.type),
bats-server-server-1  | 10:45:20 PM client.1 |  >       defaultValue: field.defaultValue ?? field.type === 'boolean' ? false : null
bats-server-server-1  | 10:45:20 PM client.1 |  |     }, field);
bats-server-server-1  | 10:45:20 PM client.1 |  |   }
fwextensions commented 1 year ago

It's not liking the nullish coalescing operator, which is weird, because that line hasn't changed in 4 months. I think this PR may need to be rebased on the update CRA branch, as there may be an issue with webpack 4 and an older version of babel, so I'm going to look at that.

fwextensions commented 1 year ago

This should be rebased on #259, which will hopefully fix the above issues.

francisli commented 1 year ago

Ok, I've merged in main which has the changes from 259 and am testing now...