ember-fastboot / ember-cli-fastboot

Server-side rendering for Ember.js apps
http://ember-fastboot.com/
MIT License
852 stars 160 forks source link

Setup Monorepo #805

Closed xg-wang closed 3 years ago

xg-wang commented 3 years ago

What it does

This PR sets up the monorepo for several repositories under ember-fastboot org, and internal test packages for easier testing across several repos:

All packages to be published are bumped to 3.1.2, which is the largest among the packages' versions.

Also converting several fastboot repo tests that rely on ember-cli-fastboot for building ember app into test-packages/integration-tests/test/basic-test.js.

ember-cli-fastboot is already using release-it-yarn-workspace to release ember-cli-fastboot; we can continue to use the release flow to release others.

Context

ember-fastboot org has multiple packages useful for server-side rendered ember apps. Although these packages can be used together with different versions combination (e.g., https://github.com/ember-fastboot/fastboot/blob/v3.1.2/src/fastboot-schema.js is explicitly designed for compatibility), it is usually desired to keep them in sync from maintainers' perspective and use a combination of versions known good from users'.

Currently, when bumping one package, several PRs need to cascade for other packages; it becomes even trickier when a fastboot contributor needs to make a change or write a test that interacts with different packages.

To merge these related packages into a monorepo, we can make maintaining and contributing to fastboot much easier.

The cons for doing monorepo is losing the flexibility to release different versions for each package and increasing the coupling, but they are not necessarily bad IMO.

Checklist

The monorepo setup needs to ensure a couple of things:

Next steps

xg-wang commented 3 years ago

I squashed the commits, this commit contains the new test setup 5451050 (#805)

xg-wang commented 3 years ago

@rwjblue (friendly ping) can I get a review on this PR?

kiwiupover commented 3 years ago

@xg-wang the first few of your commits show a blank diff any idea why?

https://github.com/ember-fastboot/ember-cli-fastboot/pull/805/commits/0f5b00b8442bcc6c08fc2f69d4cfdb710e11eb3a

xg-wang commented 3 years ago

@kiwiupover

this test could be added to the basic-app test-package. Thanks for pointing out! I assume you are saying the tests I moved from fastboot/test/fastboot-test.js to test-packages/integration-tests/test/basic-test.js, where fixture basic-app is used. Sorry I forgot to mention explicitly the migration path, which I'm thinking about to move basic-app/test/*.js to test-packages/integration-tests/test. The thought here is we use test-packages/basic-app purely as a fixture app, and write tests under test-packages/test/*.js. I think the advantages are:

  • we can test against multiple dists
  • we shift the mental model about integration test boundaries. In basic-app/test we serve the app and test HTML response, in new setup we use fastboot.visit directly, and test middleware (currently packages/fastboot-express-middleware/test/middleware-test.js in another file (I haven't created yet). In new middleware integration test we don't need to test each test app, we just need to use some test app (basic-app should be enough most time) to cover middleware behavior
  • Not starting a server for every test file should execute faster

I prefer to move test-packages/basic-app/test/*-test.js to test-packages/integration-tests/test/<maybe-new-name>-test.js. It would be a simple move change at first, and change starting server to use fastboot.visit when we have time (hope we will clean up the TODO 😄), as we migrate more old tests in ember-cli-fastboot we don't need to start the server. I couldn't think of cons for doing so, except the churn of moving them.

Any thoughts?


For the PR description TODO item

Identify and document remaining duplicated tests from packages, then move them to test-packages

It's my miss I have not written more ideas, and I think this is important for deciding where to have the tests in this PR.

If you look at existing tests in each packages, all fastboot, fastboot-express-middleware, fastboot-app-server use fixtures and implicitly rely on each other packages to build/serve the app. I think we need to move these integration pieces into test-packages/integration-tests/test/*-test.js, or figure out the boundary and test the unit behaviors in package's own test folder. There need to be more thoughts go into each PR when doing so.

xg-wang commented 3 years ago

@xg-wang the first few of your commits show a blank diff any idea why?

0f5b00b

@kiwiupover that's in the repo moved into the monorepo (for example fastboot), I committed a pre-merge commit to move everything to packages/ so the later merge has no conflicts. GitHub may have some issue displaying the diff. I used the following script:

cd fastboot
mkdir -p ../packages/fastboot; mv .* * $_
mv ../packages .
mv packages/fastboot/.git .
git commit -m 'Monorepo setup: move to packages/fastboot'
# repeat for other repos
git remote add local/fastboot file://$HOME/Code/ember-fastboot/fastboot
git fetch local/fastboot
git merge local/fastboot/master --allow-unrelated-histories

GitHub may have some issue displaying them, you can see it's the file move by doing git show 0f5b00b8442bcc6c08fc2f69d4cfdb710e11eb3a

xg-wang commented 3 years ago

Paired with @kiwiupover, we walked through the PR and listed out the things needed:

Must:

After merge:

In follow-up PRs:

kiwiupover commented 3 years ago

@rwjblue this is ready to be merged!