-
Notifications
You must be signed in to change notification settings - Fork 0
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
Chromatic CI 파이프라인 구축 #25
Changes from all commits
a059401
db02c41
de5ac86
5214b6e
c3bf4ed
feb46d0
199d456
bce3101
dc96260
ca0e2b0
1d1bf89
3acb6b2
0bcae6a
dbb965d
64628ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# .github/workflows/chromatic.yml | ||
|
||
name: 'Chromatic' | ||
|
||
on: workflow_call | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }}-chromatic | ||
cancel-in-progress: true | ||
|
||
permissions: | ||
actions: write | ||
contents: read | ||
|
||
jobs: | ||
chromatic: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install dependencies | ||
# ⚠️ Pick one of these, matching the package manager for your project | ||
# run: npm ci | ||
# run: pnpm install | ||
run: yarn install --immutable --immutable-cache --check-cache | ||
Comment on lines
+25
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 추후에 패키지 매니저를 pnpm으로 변경할 경우 변경 필요 |
||
|
||
- name: Run Chromatic | ||
uses: chromaui/action@latest | ||
with: | ||
# ⚠️ Make sure to configure a `CHROMATIC_PROJECT_TOKEN` repository secret | ||
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} | ||
workingDir: apps/docs | ||
onlyChanged: true # 👈 Required option to enable TurboSnap / 터보스냅이 필요할지는 테스트 여부에 따라 상이할 예정 | ||
exitZeroOnChanges: true # 👈 Option to prevent the workflow from failing | ||
autoAcceptChanges: 'master' # 👈 Option to accept all changes on master | ||
# ignoreLastBuildOnBranch: 'my-branch' # 👈 Option to ignore the last build on target branch | ||
Comment on lines
+32
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 하나하나 꼼꼼하게 설명까지 ㄷ ㄷ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# .github/workflows/deploy.yml | ||
name: 🚀 Deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
- devlop | ||
- feature/** | ||
pull_request: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
permissions: | ||
actions: write | ||
contents: read | ||
|
||
jobs: | ||
changed-files: | ||
runs-on: ubuntu-latest | ||
name: changed-files | ||
outputs: | ||
all_changed_files: ${{ steps.changed-files.outputs.all_changed_files }} | ||
any_changed: ${{ steps.changed-files.outputs.any_changed }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Get changed files | ||
id: changed-files | ||
uses: tj-actions/changed-files@v44 | ||
with: | ||
files: | | ||
apps/docs/** | ||
|
||
chromatic: | ||
name: Run visual tests | ||
needs: [changed-files] | ||
if: ${{ needs.changed-files.outputs.any_changed == 'true' }} | ||
uses: ./.github/workflows/chromatic.yml | ||
secrets: inherit |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,4 +28,7 @@ out | |
coverage | ||
|
||
# Turbo | ||
.turbo | ||
.turbo | ||
|
||
# Env | ||
.env |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,48 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import path, { dirname, join } from 'path'; | ||
import type { StorybookConfig } from '@storybook/react-webpack5'; | ||
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin'; | ||
|
||
function findStories() { | ||
const filePattern = /^.*\.stories\.tsx$/; | ||
const pkgStoriesPath = `./stories`; | ||
const files = fs.readdirSync(`${pkgStoriesPath}`); | ||
const pkgStoriesPath = `../stories`; | ||
const files = fs.readdirSync(path.resolve(__dirname, pkgStoriesPath)); | ||
|
||
return files | ||
.filter((file) => filePattern.test(file)) | ||
.map((file) => `../${pkgStoriesPath}/${file}`); | ||
.map((file) => `${pkgStoriesPath}/${file}`); | ||
} | ||
|
||
const config: StorybookConfig = { | ||
stories: [...findStories()], | ||
|
||
addons: [ | ||
'@storybook/addon-links', | ||
'@chromatic-com/storybook', | ||
'@storybook/addon-essentials', | ||
'@storybook/addon-interactions', | ||
'@storybook/addon-links', | ||
'@storybook/addon-webpack5-compiler-swc', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. vite -> webpack 변경하면서 babel -> swc 교체해봤습니다! |
||
'storybook-dark-mode', | ||
], | ||
|
||
framework: { | ||
name: '@storybook/react-webpack5', | ||
options: {}, | ||
}, | ||
docs: { | ||
autodocs: 'tag', | ||
}, | ||
|
||
docs: {}, | ||
|
||
// NOTE: https://storybook.js.org/docs/configure/compilers#the-swc-compiler-doesnt-work-with-react | ||
swc: () => ({ | ||
jsc: { | ||
transform: { | ||
react: { | ||
runtime: 'automatic', | ||
}, | ||
}, | ||
}, | ||
}), | ||
|
||
webpackFinal: async (config) => { | ||
if (config.resolve) { | ||
config.resolve.plugins = [ | ||
|
@@ -37,7 +52,6 @@ const config: StorybookConfig = { | |
}), | ||
]; | ||
} | ||
|
||
return config; | ||
}, | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,6 @@ function CustomDjProvider(props: PropsWithChildren) { | |
|
||
const preview: Preview = { | ||
parameters: { | ||
actions: { argTypesRegex: '^on[A-Z].*' }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. v7 -> v8 업그레이드 하면서 deprecated 될 옵션 |
||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"projectId": "Project:664871fb3ef2a81e82b1f66f", | ||
"autoAcceptChanges": "master", | ||
"onlyChanged": true, | ||
"exitOnceUploaded": true, | ||
"storybookBaseDir": "apps/docs", | ||
"zip": true | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,30 +6,34 @@ | |
"homepage": "", | ||
"license": "ISC", | ||
"scripts": { | ||
"dev": "storybook dev -p 6006", | ||
"build": "storybook build --docs", | ||
"storybook": "storybook dev -p 6006", | ||
"build": "storybook build", | ||
"build-storybook": "storybook build", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Q: build 스크립트가 있는데 왜 build-storybook 스크립트가 또 있을까? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 조금 더 찾아봐야할 것 같아요,
|
||
"preview": "serve storybook-static", | ||
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf storybook-static" | ||
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf storybook-static", | ||
"chromatic": "dotenv -e apps/docs/.env chromatic --project-token=$CHROMATIC_PROJECT_TOKEN" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 해당 명령어를 사용하기 위해서는 .env 파일에 CHROMATIC_PROJECT_TOKEN 값이 필요합니다. |
||
}, | ||
"dependencies": { | ||
"@danji/components": "^0.0.0", | ||
"@danji/css": "^0.0.0", | ||
"@danji/styled": "^0.0.0", | ||
"@danji/css": "^0.0.0" | ||
"@storybook/test": "^8.0.9" | ||
}, | ||
"devDependencies": { | ||
"serve": "^14.2.1", | ||
"@storybook/addon-essentials": "^7.0.18", | ||
"@storybook/addon-interactions": "^7.0.18", | ||
"@storybook/addon-links": "^7.0.18", | ||
"@storybook/blocks": "^7.0.18", | ||
"@storybook/cli": "^7.0.18", | ||
"@storybook/react": "^7.0.18", | ||
"@storybook/react-webpack5": "^7.0.18", | ||
"@storybook/testing-library": "^0.0.14-next.2", | ||
"@chromatic-com/storybook": "^1.3.3", | ||
"@storybook/addon-essentials": "^8.1.1", | ||
"@storybook/addon-interactions": "^8.1.1", | ||
"@storybook/addon-links": "^8.1.1", | ||
"@storybook/addon-webpack5-compiler-swc": "^1.0.2", | ||
"@storybook/blocks": "^8.1.1", | ||
"@storybook/cli": "^8.1.1", | ||
"@storybook/react": "^8.1.1", | ||
"@storybook/react-webpack5": "^8.1.1", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"storybook": "^7.0.18", | ||
"storybook-dark-mode": "^3.0.3", | ||
"serve": "^14.2.1", | ||
"storybook": "^8.0.9", | ||
"storybook-dark-mode": "^4.0.1", | ||
"tsconfig-paths-webpack-plugin": "^4.1.0" | ||
}, | ||
"eslintConfig": { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
동시성 그룹을 설정할 수 있는 건 처음 알았네요! 이렇게 되면 pull request, push가 동시에 일어난다해도 하나만 작동해서 두번 chromatic에 게시될 일은 없게 됩니다:)