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

스토리북 및 크로마틱 자동 배포 워크플로우 추가 셋업 #11

Merged
merged 11 commits into from
Jul 31, 2024
Merged
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
1 change: 1 addition & 0 deletions .github/CODEOWNER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @froggy1014
8 changes: 3 additions & 5 deletions .github/workflows/_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ jobs:
with:
node-version: ${{ inputs.NODE_VERSION }}
cache: "pnpm"
cache-dependency-path: '**/pnpm-lock.yaml'
cache-dependency-path: "**/pnpm-lock.yaml"

- name: Install dependencies
run: |
pnpm install
run: pnpm install
- name: build
run: |
pnpm run build
run: pnpm run build
57 changes: 57 additions & 0 deletions .github/workflows/chromatic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# .github/workflows/chromatic.yml
name: "Chromatic Deployment"
run-name: Storybook deployment by ${{ github.actor }}

on:
pull_request:
branches:
- develop
paths:
- "**.stories.tsx"

jobs:
chromatic:
name: Run Chromatic Deployment
# Operating System
runs-on: ubuntu-latest
outputs:
status: ${{ job.status }}

# Job steps
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 9
run_install: false

- name: Set up Node.js version
uses: actions/setup-node@v3
with:
node-version: 20.x
cache: "pnpm"
cache-dependency-path: "**/pnpm-lock.yaml"

- name: Install dependencies
run: pnpm install

- name: Run Chromatic
id: chromatic
uses: chromaui/action@latest
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
buildScriptName: build-storybook
onlyChanged: true

- name: comment PR
uses: thollander/actions-comment-pull-request@v1
if: ${{ github.event_name == 'pull_request' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
message: "💅 ## storybook-URL - ${{ steps.chromatic.outputs.storybookUrl }}"
22 changes: 22 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { StorybookConfig } from "@storybook/nextjs";

const config: StorybookConfig = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [
"@storybook/addon-onboarding",
"@storybook/addon-links",
"@storybook/addon-essentials",
"@chromatic-com/storybook",
"@storybook/addon-interactions",
],
Comment on lines +5 to +11
Copy link
Member

Choose a reason for hiding this comment

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

필수 애드온은 잘 정의되어 있네요!
이외 config 코드도 이견 없습니다~

framework: {
name: "@storybook/nextjs",
options: {},
},
staticDirs: ["../public"],

typescript: {
reactDocgen: "react-docgen-typescript",
},
};
export default config;
15 changes: 15 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { Preview } from "@storybook/react";
import "../src/styles/globals.css";

const preview: Preview = {
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
};
Comment on lines +4 to +13
Copy link
Member

Choose a reason for hiding this comment

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

제가 emotion으로만 스토리북을 구상 해봤어서 그런데
global이 잘 동작한다면 문제 없어요!
추후 wrapper 컴포넌트가 추가 된다면 renderStory() 메서드를 기반으로 이 부분에서 구현 하시면 돼요~

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@seokzin

Wrapper Component가 추가된다면 어떤 경우인지 혹시 알려주실 수 있나요?

Copy link
Member

@seokzin seokzin Aug 1, 2024

Choose a reason for hiding this comment

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

@froggy1014

Root.tsx 생각하시면 이해하기 편해요~

const ThemeWrapper = ({ children }) => (
  <ThemeProvider theme={theme}>
    <Global styles={global} />
    {children}
  </ThemeProvider>
)

export const decorators = [(renderStory) => <ThemeWrapper>{renderStory()}</ThemeWrapper>]

스토리북에서도 Root 단에 필요한 로직이나 스타일링이 있다면 preview를 JSX 문법으로 활용할 수 있다는 의미였어요!


export default preview;
17 changes: 16 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
"lint": "next lint",
"prepare": "husky",
"cz": "cz",
"formatting": "prettier --write '**/*.{ts,tsx}' && eslint --fix ."
"formatting": "prettier --write '**/*.{ts,tsx}' && eslint --fix .",
Copy link
Member

Choose a reason for hiding this comment

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

P3

사소하지만 prettier를 format, lint를 lint 스크립트로 분리하는 것도 추천드려요!
디버깅 목적으로 둘이 독립적으로 사용되는 경우도 자주 있을 뿐더러, 조금 더 보편적인 방식이라 생각해요 (저의 과거 리서치에 의하면)

추가로 next lint 스크립트도 사용하지 않는다면 제거하거나 eslint로 오버라이딩 하면 좋겠네요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@seokzin

호오...! 반영하겠습니다 감사합니다.

"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
},
"dependencies": {
"@radix-ui/react-navigation-menu": "^1.2.0",
"@radix-ui/themes": "^3.1.1",
"@tanstack/react-query": "^5.50.1",
"@tanstack/react-query-devtools": "^5.50.1",
"clsx": "^2.1.1",
Expand All @@ -26,6 +29,15 @@
"zustand": "^4.5.4"
},
"devDependencies": {
"@chromatic-com/storybook": "^1.6.1",
"@storybook/addon-essentials": "^8.2.6",
"@storybook/addon-interactions": "^8.2.6",
"@storybook/addon-links": "^8.2.6",
"@storybook/addon-onboarding": "^8.2.6",
"@storybook/blocks": "^8.2.6",
"@storybook/nextjs": "^8.2.6",
"@storybook/react": "^8.2.6",
"@storybook/test": "^8.2.6",
"@t3-oss/env-nextjs": "^0.10.1",
"@tanstack/eslint-plugin-query": "^5.50.1",
"@types/node": "^20",
Expand All @@ -35,6 +47,7 @@
"@typescript-eslint/eslint-plugin": "^7.16.0",
"@typescript-eslint/parser": "^7.16.0",
"autoprefixer": "^10.4.19",
"chromatic": "^11.5.6",
"cz-conventional-changelog": "^3.3.0",
"cz-customizable": "^7.1.0",
"eslint": "^8.57.0",
Expand All @@ -44,12 +57,14 @@
"eslint-plugin-react": "^7.34.3",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-simple-import-sort": "^12.1.1",
"eslint-plugin-storybook": "^0.8.0",
"eslint-plugin-tailwindcss": "^3.17.4",
"eslint-plugin-unused-imports": "^3.2.0",
"husky": "^9.0.11",
"jiti": "^1.21.6",
"postcss": "^8",
"prettier": "^3.3.2",
"storybook": "^8.2.6",
"tailwindcss": "^3.4.6",
"typescript": "^5"
},
Expand Down
Loading
Loading