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

[VTAdmin] Migrate to Vite #12831

Merged

Conversation

notfelineit
Copy link
Contributor

@notfelineit notfelineit commented Apr 4, 2023

Description

This PR addresses this issue and migrates VTAdmin web from create-react-app to vite. Some of the larger changes include:

  • Switching to vitest for all tests
    • Removes jest since vitest replaces it
    • Removes repetitive beforeAll/afterEach/afterAll since vitest has a global config file
  • Renaming REACT_APP_* env variables to VITE_
  • Changing process.env to import.meta.env
  • Changing protobuf output from commonjs to es6 to better work with vite's defaults
  • Configures eslint with vite and fixes some lint errors
  • Fixes some prettier errors

Manual validations

  • Ran ./101_initial_cluster.sh and VTAdmin web loads fine 👍
  • Ran npm run build locally and verified build runs locally
  • Ran npm run local and verified env vars passed are respected

Related Issue(s)

Checklist

  • "Backport to:" labels have been added if this change should be back-ported No need for backport
  • Tests were added or are not required Tests have been modified to use vitest
  • Did the new or modified tests pass consistently locally and on the CI Yes
  • Documentation was added or is not required Docs are here

Deployment Notes

N/A

@vitess-bot vitess-bot bot added NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says labels Apr 4, 2023
@vitess-bot
Copy link
Contributor

vitess-bot bot commented Apr 4, 2023

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • If this is a change that users need to know about, please apply the release notes (needs details) label so that merging is blocked unless the summary release notes document is included.
  • If a test is added or modified, there should be a documentation on top of the test to explain what the expected behavior is what the test does.

If a new flag is being introduced:

  • Is it really necessary to add this flag?
  • Flag names should be clear and intuitive (as far as possible)
  • Help text should be descriptive.
  • Flag names should use dashes (-) as word separators rather than underscores (_).

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow should be required, the maintainer team should be notified.

Bug fixes

  • There should be at least one unit or end-to-end test.
  • The Pull Request description should include a link to an issue that describes the bug.

Non-trivial changes

  • There should be some code comments as to why things are implemented the way they are.

New/Existing features

  • Should be documented, either by modifying the existing documentation or creating new documentation.
  • New features should have a link to a feature request issue or an RFC that documents the use cases, corner cases and test cases.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • vtctl command output order should be stable and awk-able.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from VTop, if used there.

@github-actions github-actions bot added this to the v17.0.0 milestone Apr 4, 2023
@notfelineit notfelineit changed the title Frances/migrate from create react app [VTAdmin] Migrate to Vite Apr 4, 2023
@notfelineit notfelineit added Type: Internal Cleanup Type: Enhancement Logical improvement (somewhere between a bug and feature) Component: VTAdmin VTadmin interface release notes (needs details) This PR needs to be listed in the release notes in a dedicated section (deprecation notice, etc...) Component: web UI javascript Pull requests that update Javascript code labels Apr 4, 2023
@notfelineit notfelineit marked this pull request as ready for review April 4, 2023 22:49
Co-authored-by: Florent Poinsard <[email protected]>
Signed-off-by: Frances Thai <[email protected]>
web/vtadmin/tests/setup.js Outdated Show resolved Hide resolved
@frouioui
Copy link
Member

frouioui commented Apr 5, 2023

Left several comments about license header missing, but there are a few other places where the headers are missing

Copy link
Member

@frouioui frouioui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not an expert in VTAdmin so I'll let @ajm188 stamp this. But everything outside of VTAdmin and the few comments I left looks good to me 🙏🏻

notfelineit and others added 2 commits April 5, 2023 11:03
Co-authored-by: Florent Poinsard <[email protected]>
Signed-off-by: Frances Thai <[email protected]>
Signed-off-by: notfelineit <[email protected]>
Copy link
Contributor

@ajm188 ajm188 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just a couple small things, feel free to fix-and-merge!

@@ -14,32 +14,33 @@ Scripts for common and not-so-common tasks. These are always run from the `vites
|---|---|
| `npm local` | Start vtadmin-web in development mode on [http://localhost:3000](http://localhost:3000), pointed at a vtadmin-api server running on [http://localhost:14200](http://localhost:14200). This is most useful when running against a [local Vitess cluster](https://vitess.io/docs/get-started/local/). |
| `npm start` | Start vtadmin-web in development mode on [http://localhost:3000](http://localhost:3000). Additional environment variables can be specified on the command line or in a .env file; see [Environment Variables](#environment-variables). |
| `npm run test` | Launches the test runner in the interactive watch mode. See the create-react-app documentation about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. |
| `npm run test` | Launches the test runner in the interactive watch mode. See the vitest documentation about [running tests](https://vitest.dev/guide/cli.html#vitest-run) for more information. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh noooo lol

i completely get the name but boy that's gonna be confusing hahaha

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😅 yeah it will be, we could add (NOT VITEST!!) afterwards lol

web/vtadmin/bin/generate-proto-types.sh Outdated Show resolved Hide resolved
web/vtadmin/src/api/http.ts Outdated Show resolved Hide resolved
web/vtadmin/tests/handlers.ts Outdated Show resolved Hide resolved
web/vtadmin/tests/server.ts Outdated Show resolved Hide resolved
web/vtadmin/tsconfig.node.json Outdated Show resolved Hide resolved
web/vtadmin/vite.config.ts Outdated Show resolved Hide resolved
@dbussink
Copy link
Contributor

dbussink commented Apr 5, 2023

I think we'll have to disable this workflow for this PR: https://github.com/vitessio/vitess/actions/runs/4620726123/workflow?pr=12831 since the PR itself modifies the make vtadmin_web_proto_types script.

That shouldn't be needed if what the new version creates is also committed?

Signed-off-by: notfelineit <[email protected]>
…anetscale/vitess into frances/migrate-from-create-react-app

Signed-off-by: notfelineit <[email protected]>
Signed-off-by: notfelineit <[email protected]>
@notfelineit
Copy link
Contributor Author

notfelineit commented Apr 5, 2023

@dbussink we wouldn't need to disable it if the workflow uses this branch's generate-proto-types.sh file 🤔 wasn't sure if that was the case or not.

The CI step is still failing. The protos generated are still the latest though:

➜  vitess git:(frances/migrate-from-create-react-app) make vtadmin_web_proto_types

added 245 packages, removed 1112 packages, changed 518 packages, and audited 1375 packages in 17s

269 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
➜  vitess git:(frances/migrate-from-create-react-app) git status
On branch frances/migrate-from-create-react-app
nothing to commit, working tree clean
➜  vitess git:(frances/migrate-from-create-react-app) git pull origin main
From github.com:planetscale/vitess
 * branch                  main       -> FETCH_HEAD
Already up to date.

@dbussink
Copy link
Contributor

dbussink commented Apr 6, 2023

@dbussink we wouldn't need to disable it if the workflow uses this branch's generate-proto-types.sh file 🤔 wasn't sure if that was the case or not.

It would be, afaik all jobs run against the current branch including this one so it would generate the same code.

@notfelineit
Copy link
Contributor Author

notfelineit commented Apr 6, 2023

@dbussink not sure why the CI is failing then 🤔 even after pulling latest from main + running make vtadmin_web_proto_types the proto files don't change - I think they're already up-to-date. CI is saying they are not.

Running locally:

➜  vitess git:(frances/single-component) ✗ ./tools/check_make_vtadmin_web_proto.sh

up to date, audited 1375 packages in 2s

269 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
VTAdmin Web Protos are up to date

@dbussink
Copy link
Contributor

dbussink commented Apr 6, 2023

@dbussink not sure why the CI is failing then 🤔 even after pulling latest from main + running make vtadmin_web_proto_types the proto files don't change - I think they're already up-to-date. CI is saying they are not.

Hmm, the reason it's not showing a diff is that the files are marked as generated / binary, so if you modify .gitattributes and remove the following entries:

web/vtadmin/src/proto/** linguist-generated=true
web/vtadmin/src/proto/*.js -diff
web/vtadmin/src/proto/*.ts -diff

Then it should show what the difference is that CI sees so we can find out what's up here.

@notfelineit
Copy link
Contributor Author

@dbussink thank you! Updating now and checking the diff. Hoping it shows!

.gitattributes Outdated
@@ -1,6 +1,3 @@
web/vtadmin/src/proto/** linguist-generated=true
web/vtadmin/src/proto/*.js -diff
web/vtadmin/src/proto/*.ts -diff
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@notfelineit Should we revert this now that the issue was found?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! 😄

@@ -33,23 +31,22 @@
"react-toastify": "^8.1.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@notfelineit I'm seeing also a following message:

npm WARN deprecated [email protected]: react-flow-renderer has been renamed to reactflow, please use this package from now on https://reactflow.dev/docs/guides/migrate-to-v11/

Should we also update all dependencies here in general? Or do that in a separate PR then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking we can do that in a separate PR! Should be easy to upgrade now we're on Vite 😄

.gitattributes Outdated Show resolved Hide resolved
Signed-off-by: Frances Thai <[email protected]>
@notfelineit notfelineit merged commit 5104d58 into vitessio:main Apr 10, 2023
@notfelineit notfelineit deleted the frances/migrate-from-create-react-app branch April 10, 2023 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: VTAdmin VTadmin interface Component: web UI javascript Pull requests that update Javascript code Type: Enhancement Logical improvement (somewhere between a bug and feature) Type: Internal Cleanup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants