Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

Deploy per-PR Storybooks on Chromatic (#519)

Mateusz Burzyński730b12b21bf7
diff --git a/.github/actions/ci-setup/action.yml b/.github/actions/ci-setup/action.yml
new file mode 100644
index 0000000000..07e261eac7
--- /dev/null
+++ b/.github/actions/ci-setup/action.yml
@@ -0,0 +1,15 @@
+name: CI setup
+
+runs:
+ using: "composite"
+
+ steps:
+ - name: Setup Node
+ uses: actions/setup-node@v3
+ with:
+ node-version: 16
+ cache: "yarn"
+
+ - name: Install Dependencies
+ run: yarn install --frozen-lockfile --ignore-scripts
+ shell: bash
diff --git a/.github/workflows/chromatic.yml b/.github/workflows/chromatic.yml
new file mode 100644
index 0000000000..52d8f560ff
--- /dev/null
+++ b/.github/workflows/chromatic.yml
@@ -0,0 +1,54 @@
+name: Chromatic
+
+on: [push]
+
+jobs:
+ chromatic:
+ timeout-minutes: 20
+
+ runs-on: ubuntu-latest
+
+ strategy:
+ matrix:
+ project:
+ [designer-app, css-engine, design-system, icons, image, react-sdk]
+ include:
+ - project: designer-app
+ chromaticSecretKey: CHROMATIC_DESIGNER_APP_TOKEN
+ workingDir: apps/designer
+
+ - project: css-engine
+ chromaticSecretKey: CHROMATIC_CSS_ENGINE_TOKEN
+ workingDir: packages/css-engine
+
+ - project: design-system
+ chromaticSecretKey: CHROMATIC_DESIGN_SYSTEM_TOKEN
+ workingDir: packages/design-system
+
+ - project: icons
+ chromaticSecretKey: CHROMATIC_ICONS_TOKEN
+ workingDir: packages/icons
+
+ - project: image
+ chromaticSecretKey: CHROMATIC_IMAGE_TOKEN
+ workingDir: packages/image
+
+ - project: react-sdk
+ chromaticSecretKey: CHROMATIC_REACT_SDK_TOKEN
+ workingDir: packages/react-sdk
+
+ steps:
+ - uses: actions/checkout@v3
+ with:
+ fetch-depth: 2 # we need to fetch at least parent commit to satisfy Chromatic
+
+ - uses: ./.github/actions/ci-setup
+
+ # only packages have to be built as they might be imported by Storybooks
+ - run: yarn build --filter='!./apps/*'
+
+ - name: Chromatic
+ uses: chromaui/action@v1
+ with:
+ projectToken: ${{ secrets[matrix.chromaticSecretKey] }}
+ workingDir: ${{ matrix.workingDir }}
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index f37e4cb4bf..44b55974fe 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -1,27 +1,22 @@
name: Main workflow
+
on: [push]
+
jobs:
checks:
+ timeout-minutes: 20
+
env:
NODE_ENV: test
DATABASE_URL: postgres://
AUTH_SECRET: test
- runs-on: ${{ matrix.os }}
- strategy:
- matrix:
- node: ["16.x"]
- os: [ubuntu-latest]
- steps:
- - name: Checkout repo
- uses: actions/checkout@v2
- - name: Setup Node.js ${{ matrix.node }}
- uses: actions/setup-node@v2
- with:
- node-version: ${{ matrix.node }}
- cache: "yarn"
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v3
+ - uses: ./.github/actions/ci-setup
- - run: yarn install --frozen-lockfile --ignore-scripts
- run: yarn prisma generate
- run: yarn build
- run: yarn checks
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index a349ac8f7d..619a04684b 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -1,24 +1,34 @@
name: Publish packages on NPM 📦
+
on:
push:
branches:
- main
+
jobs:
publish:
+ timeout-minutes: 20
+
runs-on: ubuntu-latest
+
env:
NODE_ENV: test
DATABASE_URL: postgres://
AUTH_SECRET: test
+
steps:
- uses: actions/checkout@v3
- - uses: actions/setup-node@v3
- with:
- node-version: 16
- registry-url: "https://registry.npmjs.org"
- cache: "yarn"
- env:
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
+ - uses: ./.github/actions/ci-setup
+
- run: yarn
- run: yarn turbo run build
+
+ - name: Creating .npmrc
+ run: |
+ cat << EOF > "$HOME/.npmrc"
+ //registry.npmjs.org/:_authToken=$NPM_TOKEN
+ EOF
+ env:
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
+
- run: yarn turbo run publish-to-npm
diff --git a/.github/workflows/vis-reg-tests.yml b/.github/workflows/vis-reg-tests.yml
index 4ff151a065..6c01258691 100644
--- a/.github/workflows/vis-reg-tests.yml
+++ b/.github/workflows/vis-reg-tests.yml
@@ -2,21 +2,13 @@ on: [push]
jobs:
build:
+ timeout-minutes: 20
runs-on: ubuntu-latest
steps:
- - name: Checkout
- uses: actions/checkout@v2
-
- - name: Setup Node
- uses: actions/setup-node@v2
- with:
- node-version: 16.x
- cache: 'npm'
-
- - name: Install dependencies
- run: yarn install --frozen-lockfile --ignore-scripts
+ - uses: actions/checkout@v3
+ - uses: ./.github/actions/ci-setup
- name: Build Storybook for Design System
run: yarn storybook:ds:build
diff --git a/bin/publish-to-npm.sh b/bin/publish-to-npm.sh
index 7d09ef37bc..5738c0d590 100644
--- a/bin/publish-to-npm.sh
+++ b/bin/publish-to-npm.sh
@@ -9,5 +9,5 @@ echo Current $npm_package_name $NPM_VERSION
if [[ $PKG_VERSION != $NPM_VERSION ]]; then
echo Publishing $npm_package_name $PKG_VERSION
- npm publish --access public --registry 'https://registry.npmjs.org/'
+ npm publish --access public
fi
diff --git a/package.json b/package.json
index 32f5bd1a9f..0a926d8e17 100644
--- a/package.json
+++ b/package.json
@@ -24,6 +24,8 @@
"@changesets/get-dependents-graph": "^1.3.4",
"@manypkg/get-packages": "^1.1.3",
"@webstudio-is/eslint-config-custom": "*",
+ "chromatic": "^6.11.4",
+ "golden-fleece": "^1.0.9",
"husky": ">=6",
"lint-staged": "^13.0.2",
"prettier": "latest",
@@ -34,9 +36,6 @@
"node": "16",
"yarn": "1.22"
},
- "dependencies": {
- "golden-fleece": "^1.0.9"
- },
"lint-staged": {
"*.{ts,tsx,js,json,css,md}": "prettier --write"
},
diff --git a/yarn.lock b/yarn.lock
index f5550a9911..c0863b660e 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2121,7 +2121,7 @@
"@devtools-ds/themes" "^1.2.0"
clsx "1.1.0"
-"@discoveryjs/json-ext@^0.5.3":
+"@discoveryjs/json-ext@^0.5.3", "@discoveryjs/json-ext@^0.5.7":
version "0.5.7"
resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70"
integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==
@@ -5637,6 +5637,11 @@
resolved "https://registry.yarnpkg.com/@types/webpack-env/-/webpack-env-1.17.0.tgz#f99ce359f1bfd87da90cc4a57cab0a18f34a48d0"
integrity sha512-eHSaNYEyxRA5IAG0Ym/yCyf86niZUIF/TpWKofQI/CVfh5HsMEUyfE2kwFxha4ow0s5g0LfISQxpDKjbRDrizw==
+"@types/webpack-env@^1.17.0":
+ version "1.18.0"
+ resolved "https://registry.yarnpkg.com/@types/webpack-env/-/webpack-env-1.18.0.tgz#ed6ecaa8e5ed5dfe8b2b3d00181702c9925f13fb"
+ integrity sha512-56/MAlX5WMsPVbOg7tAxnYvNYMMWr/QJiIp6BxVSW3JJXUVzzOn64qW8TzQyMSqSUFM2+PVI4aUHcHOzIz/1tg==
+
"@types/webpack-sources@*":
version "3.2.0"
resolved "https://registry.yarnpkg.com/@types/webpack-sources/-/webpack-sources-3.2.0.tgz#16d759ba096c289034b26553d2df1bf45248d38b"
@@ -7510,6 +7515,14 @@ chownr@^2.0.0:
resolved "https://registry.yarnpkg.com/chownr/-/chownr-2.0.0.tgz#15bfbe53d2eab4cf70f18a8cd68ebe5b3cb1dece"
integrity sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==
+chromatic@^6.11.4:
+ version "6.11.4"
+ resolved "https://registry.yarnpkg.com/chromatic/-/chromatic-6.11.4.tgz#1bb72bceb8f4455694e9e27db86c585e8b7cb7cd"
+ integrity sha512-f1TcuIXKjGUuOjPuwFF44kzbuEcESFcDxHzrzWPLmHuC90dV8HLxbufqYaTOBYMO/rJ32Zftb7S9pXuF/Rhfog==
+ dependencies:
+ "@discoveryjs/json-ext" "^0.5.7"
+ "@types/webpack-env" "^1.17.0"
+
chrome-trace-event@^1.0.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz#1015eced4741e15d06664a957dbbf50d041e26ac"