webcomponents / webcomponents.org

Home of the web components community
https://www.webcomponents.org
Apache License 2.0
359 stars 95 forks source link

Add catalog-server and catalog-api packages #1323

Closed justinfagnani closed 1 year ago

justinfagnani commented 1 year ago

catalog-api contains the GraphQL schema for the forthcoming GraphQL API to the catalog. It's useful here, before implementing the GraphQL endpoint, to define the schema interfaces that the catalog implementation will be dealing with.

catalog-server is a package that will implement the GraphQL endpoint. This PR add a Catalog class with a couple of basic operations: import package version, and get package version. A Catalog relies on two other interfaces Repository and PackageFiles.Repositoryrepresents the database, and there's currently only one implementation for Firestore.PackageFiles` is the interface for retrieving package metadata and files, usually from the npm registry and a CDN like unpkg.com. There is one implementation for production, and test implementations that load form memory or local files.

justinfagnani commented 1 year ago

Thanks @rictic ! I'll update the comment, and I have another PR I'm about to push that improves the schema types like we were talking about.

justinfagnani commented 1 year ago

@rictic

Let's configure CI to test with a real firestore instance.

I'm ok with this too, but have to figure out how to do it. The nice thing about the emulator is that you start with a fresh database each time it starts. If we test on real Firestore we'll have to figure out how to reliably wipe the database. Also, I have not deployed any version of this code to GCP yet. I'll have to create a new test-only GCP project too.

justinfagnani commented 1 year ago

Regarding real Firestore: there is a bit of work to do here, both on the testing side and on getting the GCP deployments setup for the first time.

I filed https://github.com/webcomponents/webcomponents.org/issues/1332 to track the testing setup and code changes required. I'd rather not block PRs that have emulated tests, which in theory should be accurate enough for unit testing - the Firestore docs say so - and work in parallel towards preview and test GCP deployments. @rictic

rictic commented 1 year ago

If we test on real Firestore we'll have to figure out how to reliably wipe the database.

I don't think that's a good idea, because it would mean multiple tests running at the same time would break each other. Better to lean into the namespaces work, but use random namespaces when in test.

rictic commented 1 year ago

I'm ok punting the use of a real firestore as long as we have agreement that we should be running all tests in CI with the real firestore before launch.

if we don't have agreement we should talk more :)

justinfagnani commented 1 year ago

If we test on real Firestore we'll have to figure out how to reliably wipe the database.

I don't think that's a good idea, because it would mean multiple tests running at the same time would break each other. Better to lean into the namespaces work, but use random namespaces when in test.

This is exactly what I mean. The clean up function would clean all collections tagged with the namespace used in that test run. The test setup would generate a namespace used by the test and cleanup script. This would be done specifically to isolate test runs and enable parallelism.

I'm ok punting the use of a real firestore as long as we have agreement that we should be running all tests in CI with the real firestore before launch.

if we don't have agreement we should talk more :)

Very much agreement. The namespacing, parallelism, and cleanup work can be developed against both local emulator or the GCP test project, and we can hit either from local dev or CI. As soon as we have the GCP infra ready used with the switch of a flag in a YAML file.