✨ CodeSandbox CI 101 ✨

This document describes what CodeSandbox CI is, how it will benefit you
as a library maintainer, and how to set it up for your library!

What is CodeSandbox CI?

CodeSandbox CI is a GitHub App that you can install in your
repository. The app is responsible for building your library:
whenever a Pull Request is opened we will make sure to build a
version of the library from that PR. We will publish this version of
the library to our registry, so you can immediately test the library
in CodeSandbox or locally.

Why do I want this?

The goal of this app is to make it easier for you to test your
library without publishing to npm yet. Since CodeSandbox is already
used for bug reports we wanted to make it possible to also test the
PR version of your library with the existing bug reports.

In an ideal flow, it would work like this:

Someone opens an issue for a bug with a sandbox reproducible

Someone opens a fix PR mentioning the issue

We build the library from the PR, fork the sandbox repro and
install the new library in that sandbox

This way you will only have to open the generated sandbox to confirm
that the fix works. No need to clone, install or test locally.

How do I set this up?

For most libraries, the only thing you need to do is install this
GitHub App. In some cases you might need to do some configuration, an example
of this is for monorepos. You can configure your library by creating
a file called ci.json in a folder called
.codesandbox (.codesandbox/ci.json) in the
root of your repo, more info on that
in the documentation. An example PR can be
found
here.

What do you do on the server?

We run a couple of steps:

Run git clone on the repository

Run yarn install or npm install, based
on the lockfile and configuration options. You can give a custom
install command here.

Run yarn build or npm build, based on
the lockfile and configuration options. You can give a custom
build command here.

Run yarn pack to get the files we need to publish

Upload the files to our storage, which you can then use in a
sandbox or locally

Generate new sandboxes with the new dependencies. We take the
sandboxes mentioned in the config, in the pr body or in the issue
mentioned by the pr, and fork them.

Does this support monorepos?

Yes! You do need some custom configuration, an example can be found
here.

Is this public?

That's it!

We hope you're enthusiastic about this functionality. We've tried to
build this with the library maintainer workflow in mind. We think that
this will make it much easier for maintainers to review PRs and test
their library.

If you have any feedback, please contact us at
[email protected] or send
us a direct message. We'd appreciate it!