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

Build: Update React versions and resolutions in sandbox templates #28612

Draft
wants to merge 3 commits into
base: next
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
120 changes: 60 additions & 60 deletions .github/workflows/generate-sandboxes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ on:
workflow_dispatch:
# To test fixes on push rather than wait for the scheduling, do the following:
# 1. Uncomment the lines below and add your branch.
# push:
# branches:
# - <your-branch-name>
push:
branches:
- yann/update-prerelease-react-sandboxes
# 2. Change the "ref" value to <your-branch-name> in the actions/checkout step below.
# 3. Comment out the whole "generate-main" job starting at line 77
# 4. 👉 DON'T FORGET TO UNDO THE STEPS BEFORE YOU MERGE YOUR CHANGES!
Expand All @@ -28,12 +28,12 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
ref: next
ref: yann/update-prerelease-react-sandboxes
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We must not merge with this change. It's here for testing purposes.


- uses: oven-sh/setup-bun@v1
with:
bun-version: 1.1.1

- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
Expand Down Expand Up @@ -78,58 +78,58 @@ jobs:
The generation of some or all sandboxes on the **next** branch has failed.
[See the job summary for details](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})

generate-main:
name: Generate to main
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: main

- uses: oven-sh/setup-bun@v1
with:
bun-version: 1.1.1

- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"

- name: Setup git user
run: |
git config --global user.name "storybook-bot"
git config --global user.email "32066757+storybook-bot@users.noreply.github.com"

- name: Install dependencies
working-directory: ./scripts
run: node --experimental-modules ./check-dependencies.js

- name: Compile Storybook libraries
run: yarn task --task compile --start-from=auto --no-link

- name: Publish to local registry
run: yarn local-registry --publish

- name: Run local registry
run: yarn local-registry --open &

- name: Wait for registry
run: yarn wait-on tcp:127.0.0.1:6001

- name: Generate
id: generate
run: yarn generate-sandboxes --local-registry

- name: Publish
# publish sandboxes even if the generation fails, as some sandboxes might have been generated successfully
if: ${{ !cancelled() }}
run: yarn publish-sandboxes --remote=https://storybook-bot:${{ secrets.PAT_STORYBOOK_BOT }}@github.com/storybookjs/sandboxes.git --push --branch=main

- name: Report failure to Discord
if: failure()
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_MONITORING_URL }}
uses: Ilshidur/action-discord@master
with:
args: |
The generation of some or all sandboxes on the **main** branch has failed.
[See the job summary for details](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
# generate-main:
# name: Generate to main
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# with:
# ref: main

# - uses: oven-sh/setup-bun@v1
# with:
# bun-version: 1.1.1

# - uses: actions/setup-node@v4
# with:
# node-version-file: ".nvmrc"

# - name: Setup git user
# run: |
# git config --global user.name "storybook-bot"
# git config --global user.email "32066757+storybook-bot@users.noreply.github.com"

# - name: Install dependencies
# working-directory: ./scripts
# run: node --experimental-modules ./check-dependencies.js

# - name: Compile Storybook libraries
# run: yarn task --task compile --start-from=auto --no-link

# - name: Publish to local registry
# run: yarn local-registry --publish

# - name: Run local registry
# run: yarn local-registry --open &

# - name: Wait for registry
# run: yarn wait-on tcp:127.0.0.1:6001

# - name: Generate
# id: generate
# run: yarn generate-sandboxes --local-registry

# - name: Publish
# # publish sandboxes even if the generation fails, as some sandboxes might have been generated successfully
# if: ${{ !cancelled() }}
# run: yarn publish-sandboxes --remote=https://storybook-bot:${{ secrets.PAT_STORYBOOK_BOT }}@github.com/storybookjs/sandboxes.git --push --branch=main

# - name: Report failure to Discord
# if: failure()
# env:
# DISCORD_WEBHOOK: ${{ secrets.DISCORD_MONITORING_URL }}
# uses: Ilshidur/action-discord@master
# with:
# args: |
# The generation of some or all sandboxes on the **main** branch has failed.
# [See the job summary for details](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
10 changes: 5 additions & 5 deletions code/lib/cli/src/sandbox-templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,16 @@ const baseTemplates = {
name: 'React Prerelease (Vite | TypeScript)',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: 'React Prerelease (Vite | TypeScript)',
name: 'React Release Candidate (Vite | TypeScript)',

/**
* 1. Create a Vite project with the React template
* 2. Add React beta versions
* 2. Add React RC versions
* 3. Add resolutions for @types/react and @types/react-dom, see https://react.dev/blog/2024/04/25/react-19-upgrade-guide#installing
* 4. Add @types/react and @types/react-dom pointing to the beta packages
* 4. Add @types/react and @types/react-dom pointing to the RC packages
*/
script: `
npm create vite --yes {{beforeDir}} -- --template react-ts && \
cd {{beforeDir}} && \
yarn add react@beta react-dom@beta && \
jq '.resolutions += {"@types/react": "npm:types-react@beta", "@types/react-dom": "npm:types-react-dom@beta"}' package.json > tmp.json && mv tmp.json package.json && \
yarn add --dev @types/react@npm:types-react@beta @types/react-dom@npm:types-react-dom@beta
yarn add react@rc react-dom@rc && \
jq '.resolutions += {"@types/react": "npm:types-react@rc", "@types/react-dom": "npm:types-react-dom@rc"}' package.json > tmp.json && mv tmp.json package.json && \
yarn add --dev @types/react@npm:types-react@rc @types/react-dom@npm:types-react-dom@rc
`,
expected: {
framework: '@storybook/react-vite',
Expand Down