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

front: import osrd-ui #10711

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from
Open

front: import osrd-ui #10711

wants to merge 12 commits into from

Conversation

emersion
Copy link
Member

@emersion emersion commented Feb 6, 2025

See individual commits.

TODO:

  • Basic NPM workspace setup
  • Build system
  • Docker integration
    • Base flavor
    • Front flavor
  • Storybook publishing
  • Releases
  • Adjust docs

Closes: OpenRailAssociation/osrd-ui#451

Design decisions

Why move front/ui/package.json to front/ui/base/package.json?

NPM doesn't correctly handle nested sub-packages (front/ui/ and front/ui/storybook/, for instance). It doesn't install dev dependencies of nested sub-packages (storybook dependencies are missing).

Why keep front/ui/base/package.json?

front/ui/ contains config files for rollup, ESLint, postcss used by all ui-* sub-packages. We need to specify dependencies for these somewhere.

We could specify them in front/package.json, but that would mix up osrd and osrd-ui deps. Keeping shared osrd-ui deps inside front/ui/base/package.json makes it clearer what's required by osrd itself and what's required by osrd-ui.

Should we build osrd-ui when running npm run build?

Another possible solution would've been to only build osrd when running npm run build, and require users to run npm run build --workspaces to build osrd-ui. The upside would be that less work is performed when only touching osrd.

However, this would make it so npm run build would fail if osrd-ui hasn't been built before, or has an outdated build. Also, building osrd-ui requires less changes to the CI and tooling.

There are ESLint errors when I start the front flavor of the Compose setup

This is due to osrd-ui and osrd being built in parallel when the container starts, and ESLint doesn't notice when osrd-ui has been built. Indeed, ESLint doesn't install a watcher on files in node_modules/, which osrd-ui deps point to.

To fix, run npm run build --workspaces before starting the container, or restart the container (either should work).

How will we merge this?

We will need to coordinate a bit to not loose anything in osrd-ui. Easiest would be to get this reviewed and ready to merge, freeze osrd-ui, release a new osrd-ui version and bump osrd to use that new version (if there are breaking API changes), adjust the "import osrd-ui" commit to import that version, and merge this PR.

Once that's done, all opened osrd-ui PRs will need to be manually migrated to the osrd repository.

Why front/ui/ instead of front/osrd-ui/?

Because "osrd" is already in the name of this repo ¯\_(ツ)_/¯

@github-actions github-actions bot added the area:front Work on Standard OSRD Interface modules label Feb 6, 2025
@emersion emersion force-pushed the emr/monorepo branch 5 times, most recently from 98352b2 to baf5d24 Compare February 18, 2025 15:14
@github-actions github-actions bot added area:ci Work on Continous Integration Pipeline Service area:gateway and removed area:gateway labels Feb 18, 2025
@emersion emersion force-pushed the emr/monorepo branch 4 times, most recently from 808b7bd to 04562bb Compare February 24, 2025 16:31
@emersion emersion force-pushed the emr/monorepo branch 4 times, most recently from f951b2c to 0fca49a Compare February 28, 2025 09:49
@emersion emersion force-pushed the emr/monorepo branch 4 times, most recently from a3f7fc5 to 5e3eba0 Compare March 14, 2025 16:16
emersion and others added 3 commits March 17, 2025 11:53
Otherwise these will blow up with out-of-memory errors when a new
ui/ directory is imported in the next commit.

Signed-off-by: Simon Ser <[email protected]>
This is the osrd-ui tree imported from tag 0.0.68, without any
change:

    git clone --branch 0.0.68 https://github.com/OpenRailAssociation/osrd-ui.git ui
    rm -rf ui/.git

Git history up to this state is available at:
https://github.com/OpenRailAssociation/osrd-ui/

The author list has been generated with:

    git log --format='%aN <%aE>' | sort | uniq

With the following .mailmap file:
https://paste.sr.ht/~emersion/6cedd39f2935f6fcd3854eff1ce759c037965003

Signed-off-by: Simon Ser <[email protected]>
Co-authored-by: Achraf Mohyeddine <[email protected]>
Co-authored-by: Alexis Jacomy <[email protected]>
Co-authored-by: Alice Khoudli <[email protected]>
Co-authored-by: Benoit Simard <[email protected]>
Co-authored-by: Chaka NGAMENI NJINEH <[email protected]>
Co-authored-by: Clara Ni <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Egor Berezovskiy <[email protected]>
Co-authored-by: Élyse Viard <[email protected]>
Co-authored-by: Ethan Perruzza <[email protected]>
Co-authored-by: Florian Amsallem <[email protected]>
Co-authored-by: Gaël Haméon <[email protected]>
Co-authored-by: Ian Turner <[email protected]>
Co-authored-by: Mathieu <[email protected]>
Co-authored-by: Math_R_ <[email protected]>
Co-authored-by: Nicolas Wurtz <[email protected]>
Co-authored-by: romainvalls <[email protected]>
Co-authored-by: rostom boudi <[email protected]>
Co-authored-by: SarahBellaha <[email protected]>
Co-authored-by: Serge Croisé <[email protected]>
Co-authored-by: SharglutDev <[email protected]>
Co-authored-by: Simon Ser <[email protected]>
Co-authored-by: theocrsb <[email protected]>
Co-authored-by: Theo Macron <[email protected]>
Co-authored-by: thibautsailly <[email protected]>
Co-authored-by: Uriel-Sautron <[email protected]>
Co-authored-by: Valentin Chanas <[email protected]>
Co-authored-by: Victor "multun" Collod <[email protected]>
Co-authored-by: Yohh <[email protected]>
Co-authored-by: Younes Khoudli <[email protected]>
osrd-ui's root package.json is moved to ui/base/ because nested
workspaces don't work with NPM:
npm/cli#4774

rollup-base.config.js needs to be adjusted because node_modules
now lives one directory higher and dist directories live one
directory deeper.

The build, test and lint scripts are adjusted to execute tasks for
both osrd and osrd-ui.

The full front source code is copied over in the Dockerfile before
installing dependencies, because NPM needs to look at all workspace's
package.json files to install dependencies.

eslint-plugin-storybook's TypeScript version needs to be overridden
because osrd uses 5.8 an the plugin asks for <5.8:
storybookjs/eslint-plugin-storybook#193

Signed-off-by: Simon Ser <[email protected]>
Since front includes osrd-ui via NPM workspaces, dependabot will
upgrade osrd-ui dependencies. We only need to slightly adjust
group patterns to include everything missing from osrd-ui's
configuration file.

Signed-off-by: Simon Ser <[email protected]>
File paths need to be slightly adjusted.

requirements.txt is moved to the root of ui-icons so that it can
more easily be run locally.

Signed-off-by: Simon Ser <[email protected]>
We need to strip the "v" prefix from Git tag names, and adjust file
paths a bit.

Signed-off-by: Simon Ser <[email protected]>
The build script is run for all workspaces, but not the root
workspace.

The deployment repository now needs to be explicitly specified.

Signed-off-by: Simon Ser <[email protected]>
All of these are already covered by the osrd monorepo.

Signed-off-by: Simon Ser <[email protected]>
When starting the front dev container, osrd-ui may not have been
built yet, or might be outdated. Start a build of osrd-ui
components which are used in osrd in parallel with vite.

Avoid building osrd-ui's storybook, because it takes quite a while
and it's unnecessary.

Signed-off-by: Simon Ser <[email protected]>
osrd-ui needs to be built before starting the frontend.

The "storybook" script is no more, instead users can cd into the
storybook directory (just like all other sub-packages).

Signed-off-by: Simon Ser <[email protected]>
There was no hint to indicate how one would start Docker Compose
to work on the frontend.

Signed-off-by: Simon Ser <[email protected]>
@emersion emersion marked this pull request as ready for review March 17, 2025 16:33
@emersion emersion requested review from a team as code owners March 17, 2025 16:33
@emersion emersion requested review from Synar, kmer2016 and clarani March 17, 2025 16:34
Unfortunately, ESLint's cache is pretty bare-bones and doesn't
invalidate dependent files. For example, if a warning appears in
foo.ts but is caused by a mistake in bar.ts, fixing bar.ts will not
cause ESLint to re-check foo.ts and the warning will linger.

I've seen multiple occurences of this happening. Deleting the
ESLint cache directory and restarting ESLint helps, but it pretty
cumbersome.

Slow checks are better than invalid/stale warnings, so let's switch
back to no cache.

See the typescript-eslint docs, which also recommend to disable
the cache:
https://typescript-eslint.io/troubleshooting/faqs/eslint/#can-i-use-eslints---cache-with-typescript-eslint

Signed-off-by: Simon Ser <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:ci Work on Continous Integration Pipeline Service area:front Work on Standard OSRD Interface modules area:gateway
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move osrd-ui into main osrd repository
1 participant