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

Refactor bootstrap+sandbox into "task" framework #19275

Merged
merged 85 commits into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
d24daef
Got task script mostly working
tmeasday Sep 27, 2022
08afa9b
Switch flag in CI scripts
tmeasday Sep 30, 2022
5dabf4e
Switch create task
tmeasday Sep 30, 2022
f003645
Ensure the sandboxes dir exist
tmeasday Sep 30, 2022
dbdf5ac
Need to reset back to create for the create-sandboxes step
tmeasday Sep 30, 2022
3211f87
Don't link in CI
tmeasday Sep 30, 2022
67677da
Show status of script
tmeasday Sep 30, 2022
46b67aa
Move `run-registry` before `create`
tmeasday Sep 30, 2022
3eada14
Always debug the final task
tmeasday Sep 30, 2022
a2ffd0f
Start earlier
tmeasday Sep 30, 2022
832de09
Only go to the end :shrug:
tmeasday Sep 30, 2022
1272940
Add the concept of a service task and step through tasks more carefully
tmeasday Oct 3, 2022
626fa54
Recombine sandbox task.
tmeasday Oct 3, 2022
364a299
Update circl
tmeasday Oct 3, 2022
c9c3de3
Clean up a lot of older code
tmeasday Oct 3, 2022
c391e7e
Smal lfix
tmeasday Oct 3, 2022
3f4b5c3
Merge remote-tracking branch 'origin/next' into tom/sb-628-properly-d…
tmeasday Oct 3, 2022
0b97078
Fixes
tmeasday Oct 3, 2022
c28134f
Fix merge conflict
tmeasday Oct 3, 2022
55d0a25
Cleanup
tmeasday Oct 3, 2022
3d3f6a9
More fix
tmeasday Oct 3, 2022
17b12ae
Another fix
tmeasday Oct 3, 2022
56b504b
Add top-level package.json and use for `yarn start/task`
tmeasday Oct 4, 2022
ecff39f
Bootstrap directly in the bootstrap task
tmeasday Oct 4, 2022
c3cf976
Update `--reset` to `--start-from`
tmeasday Oct 4, 2022
be23ced
Delete bootstrap!
tmeasday Oct 4, 2022
d45a6f3
Add a nice CI error to help repros
tmeasday Oct 4, 2022
c19b4b5
Merge remote-tracking branch 'origin/next' into tom/sb-628-properly-d…
tmeasday Oct 4, 2022
6d6a432
Replace some uses of bootstrap
tmeasday Oct 4, 2022
229a912
No need to mess with task controllers
tmeasday Oct 5, 2022
b25a326
Refactor sandbox to load async
tmeasday Oct 5, 2022
a396d3a
Updates to package.json to make things simpler
tmeasday Oct 5, 2022
5af3929
Fix bootstrap
tmeasday Oct 5, 2022
8a7328f
Deepscan
tmeasday Oct 5, 2022
f0ab6e6
Fix bootstrap
tmeasday Oct 5, 2022
b1f8c45
Keep fixing bootstrap until it works
tmeasday Oct 5, 2022
f3dd526
Commit top-level yarn.lock
tmeasday Oct 5, 2022
6c51c55
Merge remote-tracking branch 'origin/next' into tom/sb-628-properly-d…
tmeasday Oct 5, 2022
d5b05d2
Let's debug bootstrap
tmeasday Oct 5, 2022
e4e7344
Don't need to run `task` from `code/` anymore
tmeasday Oct 5, 2022
3f3f428
Rename tasks in a simpler way
tmeasday Oct 5, 2022
843811a
Slightly nicer prompt message
tmeasday Oct 5, 2022
431162b
Add basic contributing instructions and improve prompts
tmeasday Oct 5, 2022
ca2e2c8
Add `get-template` to root
tmeasday Oct 5, 2022
ee60b3a
Check in root node modules
tmeasday Oct 5, 2022
059798a
Merge remote-tracking branch 'origin/next' into tom/sb-628-properly-d…
tmeasday Oct 6, 2022
c67791a
Fix get-template
tmeasday Oct 6, 2022
03c7e17
Ensure we get workspaces from` code/`
tmeasday Oct 6, 2022
9373838
Fix start task
tmeasday Oct 6, 2022
fed5708
Fix `esbuild-loader` resolution
tmeasday Oct 6, 2022
8204a4c
Fix compile readiness
tmeasday Oct 6, 2022
443faaa
Final task should always run
tmeasday Oct 6, 2022
f527257
More fixes so things actually run
tmeasday Oct 6, 2022
aa0f826
Made changes to `code.md`
tmeasday Oct 6, 2022
6e7b08d
Get rid of references to bootstrap
tmeasday Oct 6, 2022
4154353
Fix tasks
tmeasday Oct 6, 2022
3991921
Fix up serve task
tmeasday Oct 6, 2022
a638acc
Add logging for a minute
tmeasday Oct 6, 2022
202feac
Revert "Add logging for a minute"
tmeasday Oct 6, 2022
f37897d
Switch CRA for vite-react in `start`
tmeasday Oct 7, 2022
44b1131
Allow starting from a service
tmeasday Oct 7, 2022
2c898fb
Update scripts/task.ts
tmeasday Oct 7, 2022
67d1ab1
Rename `before` => `dependsOn`
tmeasday Oct 9, 2022
da590c7
Remove spurious log
tmeasday Oct 9, 2022
0aa4be1
Remove `a11y` from default addons
tmeasday Oct 9, 2022
6adbd3e
Move text up
tmeasday Oct 9, 2022
d1ebd7e
Apply suggestions from code review
tmeasday Oct 9, 2022
f407585
Another @yannbf fix
tmeasday Oct 9, 2022
57c81e8
Rename file to `storybook-sandbox`
tmeasday Oct 9, 2022
0c9639b
Just specify a template for simplicity
tmeasday Oct 9, 2022
f67404b
Ensure that if you skip *one* option it doesn't prompt them all
tmeasday Oct 9, 2022
bf40f5c
Add a message while installing in `scripts`
tmeasday Oct 9, 2022
d5c9a9e
Add a nice cancel for `start-from` prompt
tmeasday Oct 10, 2022
e2d7c16
Fix publish script
tmeasday Oct 10, 2022
10ec6d7
Merge remote-tracking branch 'origin/next' into tom/sb-628-properly-d…
tmeasday Oct 10, 2022
c9d876c
Fix issue with global usage
tmeasday Oct 10, 2022
80e313d
Merge remote-tracking branch 'origin/next' into tom/sb-628-properly-d…
tmeasday Oct 10, 2022
7a53b32
Better resolution
tmeasday Oct 10, 2022
3a336b6
Serve the right directory (!)
tmeasday Oct 10, 2022
cbead1a
Update to yarn 3.2.3 everywhere
tmeasday Oct 10, 2022
52740da
Explain the compile `ready` cehck
tmeasday Oct 10, 2022
e42b5b6
Some updates
tmeasday Oct 10, 2022
3d73ef8
Bump cache version
tmeasday Oct 10, 2022
66f1aeb
Update yarn lock in code
tmeasday Oct 10, 2022
f56998e
Merge remote-tracking branch 'origin/next' into tom/sb-628-properly-d…
tmeasday Oct 10, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 16 additions & 33 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,26 +85,15 @@ jobs:
- restore_cache:
name: Restore Yarn cache
keys:
- build-yarn-2-cache-v3--{{ checksum "code/yarn.lock" }}
- build-yarn-2-cache-v4--{{ checksum "code/yarn.lock" }}--{{ checksum "scripts/yarn.lock" }}
- run:
name: Install dependencies
name: Compile
command: |
cd code
yarn install --immutable
- run:
name: Install script dependencies
command: |
cd scripts
yarn install --immutable
- run:
name: Bootstrap
command: |
cd code
yarn bootstrap --build
yarn task --task compile --start-from=auto --no-link --debug
git diff --exit-code
- save_cache:
name: Save Yarn cache
key: build-yarn-2-cache-v3--{{ checksum "code/yarn.lock" }}
key: build-yarn-2-cache-v4--{{ checksum "code/yarn.lock" }}--{{ checksum "scripts/yarn.lock" }}
paths:
- ~/.yarn/berry/cache
- persist_to_workspace:
Expand Down Expand Up @@ -324,14 +313,13 @@ jobs:
at: .
- run:
name: Creating Sandboxes
command: yarn task --task create --template $(yarn get-template ci create) --force --no-before --junit
working_directory: code
command: yarn task --task sandbox --template $(yarn get-template ci create) --no-link --start-from=never --junit
- persist_to_workspace:
root: .
paths:
- sandbox
- store_test_results:
path: code/test-results
path: test-results
smoke-test-sandboxes:
executor:
class: medium+
Expand All @@ -344,10 +332,9 @@ jobs:
at: .
- run:
name: Smoke Testing Sandboxes
command: yarn task --task smoke-test --template $(yarn get-template ci smoke-test) --force --no-before --junit
working_directory: code
command: yarn task --task smoke-test --template $(yarn get-template ci smoke-test) --no-link --start-from=never --junit
- store_test_results:
path: code/test-results
path: test-results
build-sandboxes:
executor:
class: medium+
Expand All @@ -360,10 +347,9 @@ jobs:
at: .
- run:
name: Building Sandboxes
command: yarn task --task build --template $(yarn get-template ci build) --force --no-before --junit
working_directory: code
command: yarn task --task build --template $(yarn get-template ci build) --no-link --start-from=never --junit
- store_test_results:
path: code/test-results
path: test-results
- persist_to_workspace:
root: .
paths:
Expand All @@ -380,10 +366,9 @@ jobs:
at: .
- run:
name: Running Test Runner
command: yarn task --task test-runner --template $(yarn get-template ci test-runner) --force --no-before --junit
working_directory: code
command: yarn task --task test-runner --template $(yarn get-template ci test-runner) --no-link --start-from=never --junit
- store_test_results:
path: code/test-results
path: test-results
chromatic-sandboxes:
executor:
class: medium+
Expand All @@ -396,10 +381,9 @@ jobs:
at: .
- run:
name: Running Chromatic
command: yarn task --task chromatic --template $(yarn get-template ci chromatic) --force --no-before --junit
working_directory: code
command: yarn task --task chromatic --template $(yarn get-template ci chromatic) --no-link --start-from=never --junit
- store_test_results:
path: code/test-results
path: test-results
e2e-sandboxes:
executor:
class: medium+
Expand All @@ -412,10 +396,9 @@ jobs:
at: .
- run:
name: Running E2E Tests
command: yarn task --task e2e-tests --template $(yarn get-template ci e2e-tests) --force --no-before --junit
working_directory: code
command: yarn task --task e2e-tests --template $(yarn get-template ci e2e-tests) --no-link --start-from=never --junit
- store_test_results:
path: code/test-results
path: test-results
- store_artifacts: # this is where playwright puts more complex stuff
path: code/playwright-results/
destination: playwright
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generate-repros-next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Install dependencies
run: node ./scripts/check-dependencies.js
- name: Bootstrap Storybook libraries
run: yarn bootstrap --prep
run: yarn task --task compile --start-from=auto --no-link
working-directory: ./code
- name: Generate repros
run: yarn generate-repros-next --local-registry
Expand Down
11 changes: 3 additions & 8 deletions .github/workflows/tests-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@ jobs:
with:
node-version: ${{ matrix.node_version }}
cache: yarn
- name: install, bootstrap
run: |
cd code
yarn install --immutable
yarn bootstrap --core
- name: install and compile
run: yarn task --task compile --start-from=auto
- name: test
run: |
cd code
yarn test --runInBand --ci
run: yarn test --runInBand --ci
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ junit.xml
!/**/.yarn/sdks
!/**/.yarn/versions
/**/.pnp.*
/yarn.lock
!/node_modules
783 changes: 783 additions & 0 deletions .yarn/releases/yarn-3.2.3.cjs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-3.2.3.cjs
tmeasday marked this conversation as resolved.
Show resolved Hide resolved
33 changes: 25 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,34 @@

- Ensure you have node version 14 installed (suggestion: v14.18.1).
- Ensure if you are using Windows to use the Windows Subsystem for Linux (WSL).
- Run `./bootstrap.sh` to install the dependencies, and get the repo ready to be developed on.
- Run `yarn start` inside of the `code` directory to start the development server.
- Run `yarn start` directory to run a basic test Storybook "sandbox".
tmeasday marked this conversation as resolved.
Show resolved Hide resolved

# Generating reproductions
The `yarn start` script will generate a React Vite TypeScript sandbox with a set of test stories inside it, as well as taking all steps required to get it running (building the various packages we need etc).

The monorepo has a script that generates Storybook reproductions based on configurations set in the `code/lib/cli/src/repro-templates.ts` file. This makes it possible to quickly bootstrap examples with and without Storybook, for given configurations (e.g. CRA, Angular, Vue, etc.)

To do so:
- Check the `code/lib/cli/src/repro-templates.ts` if you want to see what will be generated
- Run `./generate-repros.sh`
- Check the result in the `repros` directory
# Running against different sandbox templates

You can also pick a specific template to use as your sandbox by running `yarn task`, which will prompt you to make further choices about which template you want and which task you want to run.

# Making code changes

If you want to make code changes to Storybook packages while running a sandbox, you'll need to do the following:

1. In a second terminal run `yarn build --watch <package-1> <package-2>` in the `code/` directory. The package names is the bit after the `@storybook/` in the published package. For instance, to build the `@storybook/react @storybook/core-server @storybook/api @storybook/addon-docs` packages at the same time in watch mode:

```bash
cd code
yarn build --watch react core-server api addon-docs
```

2. If you are running the sandbox in "linked" mode (the default), you should see the changes reflected on a refresh (you may need to restart it if changing server packages)

3. If you are running the sandbox in "unlinked" mode you'll need to re-run the sandbox from the `publish` step to see the changes:

```
yarn task --task dev --template <your template> --start-from=publish
```


# Contributing to Storybook

Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,13 @@ Looking for a first issue to tackle?

Storybook is organized as a monorepo using [Lerna](https://lerna.js.org/). Useful scripts include:

#### `./bootstrap.sh`
#### `yarn start`

> Installs package dependencies and links packages together - using lerna
> Runs a sandbox template storybook with test stories

#### `yarn task`

> As above, but gives you options to customize the sandbox (e.g. selecting other frameworks)

#### `yarn lint`

Expand Down
3 changes: 0 additions & 3 deletions bootstrap.sh

This file was deleted.

Loading