From 3cbf733bc96260bb1244602a4fe2377f54c51b4e Mon Sep 17 00:00:00 2001 From: Ethen1264 Date: Mon, 16 Dec 2024 17:10:38 +0900 Subject: [PATCH 1/4] =?UTF-8?q?=E2=9C=A8Add:=20DeepSource?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .deepsource.toml | 54 +++++++++++++++++++++++ .github/workflows/deepsource-analysis.yml | 20 +++++++++ 2 files changed, 74 insertions(+) create mode 100644 .deepsource.toml create mode 100644 .github/workflows/deepsource-analysis.yml diff --git a/.deepsource.toml b/.deepsource.toml new file mode 100644 index 0000000..46e507b --- /dev/null +++ b/.deepsource.toml @@ -0,0 +1,54 @@ +version = 1 + +# 제외할 파일이나 디렉터리 설정 +exclude_patterns = [ + "node_modules/**", # Node.js 라이브러리 폴더 제외 + ".next/**", # Next.js 빌드 폴더 제외 + "storybook-static/**", # Storybook 빌드 폴더 제외 + "dist/**", # 빌드 결과물 제외 +] + +# 테스트 파일 패턴 설정 +test_patterns = [ + "**/__tests__/**", + "**/*.test.tsx", + "**/*.spec.tsx", +] + +[[analyzers]] +name = "javascript" # JavaScript/TypeScript 분석기 +enabled = true + + [analyzers.meta] + runtime = "nodejs" + extensions = ["jsx", "tsx", "ts", "js"] + + # ESLint 설정 파일 경로 추가 + eslint_config_path = "./.eslintrc.json" + + # 추가 분석 옵션 설정 + autofix = true # 가능한 자동 수정 적용 + check_formatting = true # 포맷팅 검사 활성화 + formatting_tools = ["prettier"] + + # DeepSource에서 사용할 JavaScript 및 TypeScript 관련 최적화 옵션 + javascript.variants = ["react", "typescript"] + javascript.enable_performance_optimizations = true + + # 추가된 분석 규칙들 + javascript.rules = [ + # 성능 최적화 관련 규칙들 + "react/no-array-index-key", + "react/jsx-no-target-blank", + "react/jsx-no-undef", + "react/prop-types", # prop-types 규칙 비활성화 + + # 코드 가독성 관련 규칙들 + "@typescript-eslint/no-unused-vars", + "@typescript-eslint/explicit-module-boundary-types", + + # 코드 품질 및 유지보수성 규칙들 + "import/order", + "import/no-extraneous-dependencies", + "react-hooks/exhaustive-deps", + ] diff --git a/.github/workflows/deepsource-analysis.yml b/.github/workflows/deepsource-analysis.yml new file mode 100644 index 0000000..0bedbae --- /dev/null +++ b/.github/workflows/deepsource-analysis.yml @@ -0,0 +1,20 @@ +name: DeepSource Analysis + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + analysis: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Install DeepSource CLI + run: curl https://deepsource.io/cli | sh + + - name: Run DeepSource analysis + run: ./bin/deepsource analyze + env: + DEEPSOURCE_DSN: ${{ secrets.DEEPSOURCE_DSN }} From daad904fd1d80e904c9cbefb0c49a41d4bf3b604 Mon Sep 17 00:00:00 2001 From: Ethen1264 Date: Mon, 16 Dec 2024 17:28:10 +0900 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=90=9BFix:=20deepsource-analysis.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deepsource-analysis.yml | 26 +++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deepsource-analysis.yml b/.github/workflows/deepsource-analysis.yml index 0bedbae..9a26341 100644 --- a/.github/workflows/deepsource-analysis.yml +++ b/.github/workflows/deepsource-analysis.yml @@ -2,19 +2,33 @@ name: DeepSource Analysis on: pull_request: - types: [opened, synchronize, reopened] + branches: + - main + push: + branches: + - main jobs: - analysis: + deepsource: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '16' + + - name: Install dependencies + run: | + npm install - name: Install DeepSource CLI - run: curl https://deepsource.io/cli | sh + run: | + curl -sSL https://deepsource.io/cli/install | bash - - name: Run DeepSource analysis - run: ./bin/deepsource analyze + - name: Run DeepSource Analysis env: DEEPSOURCE_DSN: ${{ secrets.DEEPSOURCE_DSN }} + run: deepsource analyze From dad7de9e315713d5f71355452816ae1ed55aab10 Mon Sep 17 00:00:00 2001 From: Ethen1264 Date: Mon, 16 Dec 2024 17:53:15 +0900 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=90=9BFix:=20depsource=20cicd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .deepsource.toml | 54 +++-------------------- .github/workflows/deepsource-analysis.yml | 34 -------------- .github/workflows/deepsource.yml | 44 ++++++++++++++++++ 3 files changed, 50 insertions(+), 82 deletions(-) delete mode 100644 .github/workflows/deepsource-analysis.yml create mode 100644 .github/workflows/deepsource.yml diff --git a/.deepsource.toml b/.deepsource.toml index 46e507b..6b046d6 100644 --- a/.deepsource.toml +++ b/.deepsource.toml @@ -1,54 +1,12 @@ version = 1 -# 제외할 파일이나 디렉터리 설정 -exclude_patterns = [ - "node_modules/**", # Node.js 라이브러리 폴더 제외 - ".next/**", # Next.js 빌드 폴더 제외 - "storybook-static/**", # Storybook 빌드 폴더 제외 - "dist/**", # 빌드 결과물 제외 -] - -# 테스트 파일 패턴 설정 -test_patterns = [ - "**/__tests__/**", - "**/*.test.tsx", - "**/*.spec.tsx", -] - [[analyzers]] -name = "javascript" # JavaScript/TypeScript 분석기 +name = "typescript" enabled = true - [analyzers.meta] - runtime = "nodejs" - extensions = ["jsx", "tsx", "ts", "js"] - - # ESLint 설정 파일 경로 추가 - eslint_config_path = "./.eslintrc.json" - - # 추가 분석 옵션 설정 - autofix = true # 가능한 자동 수정 적용 - check_formatting = true # 포맷팅 검사 활성화 - formatting_tools = ["prettier"] - - # DeepSource에서 사용할 JavaScript 및 TypeScript 관련 최적화 옵션 - javascript.variants = ["react", "typescript"] - javascript.enable_performance_optimizations = true - - # 추가된 분석 규칙들 - javascript.rules = [ - # 성능 최적화 관련 규칙들 - "react/no-array-index-key", - "react/jsx-no-target-blank", - "react/jsx-no-undef", - "react/prop-types", # prop-types 규칙 비활성화 - - # 코드 가독성 관련 규칙들 - "@typescript-eslint/no-unused-vars", - "@typescript-eslint/explicit-module-boundary-types", +[[analyzers]] +name = "javascript" +enabled = true - # 코드 품질 및 유지보수성 규칙들 - "import/order", - "import/no-extraneous-dependencies", - "react-hooks/exhaustive-deps", - ] +[analyzers.meta] +env = ["nodejs"] \ No newline at end of file diff --git a/.github/workflows/deepsource-analysis.yml b/.github/workflows/deepsource-analysis.yml deleted file mode 100644 index 9a26341..0000000 --- a/.github/workflows/deepsource-analysis.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: DeepSource Analysis - -on: - pull_request: - branches: - - main - push: - branches: - - main - -jobs: - deepsource: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up Node.js - uses: actions/setup-node@v2 - with: - node-version: '16' - - - name: Install dependencies - run: | - npm install - - - name: Install DeepSource CLI - run: | - curl -sSL https://deepsource.io/cli/install | bash - - - name: Run DeepSource Analysis - env: - DEEPSOURCE_DSN: ${{ secrets.DEEPSOURCE_DSN }} - run: deepsource analyze diff --git a/.github/workflows/deepsource.yml b/.github/workflows/deepsource.yml new file mode 100644 index 0000000..344e77a --- /dev/null +++ b/.github/workflows/deepsource.yml @@ -0,0 +1,44 @@ +name: Deepsource Code Review + +on: + pull_request: + branches: + - main + - develop + +jobs: + deepsource-review: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Run Lint + run: npm run lint + + - name: Run Deepsource CLI + env: + DEEPSOURCE_TOKEN: ${{ secrets.DEEPSOURCE_TOKEN }} + run: | + # Deepsource CLI 설치 + curl https://deepsource.io/cli | sh + + # Lint 분석 실행 + ./bin/deepsource report --analyzer lint \ + --key typescript \ + --value "$(cat lint-report.json)" + + # 필요한 경우 테스트 커버리지 추가 + # - name: Run Tests with Coverage + # run: npm run test:coverage From 81be3e36530efded705a3381f0ada90c45a9a44c Mon Sep 17 00:00:00 2001 From: Ethen1264 Date: Mon, 16 Dec 2024 18:21:37 +0900 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=90=9BFix:=20depsource=20cicd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .deepsource.toml | 13 +++++--- .github/workflows/deepsource.yml | 52 +++++++++++++++----------------- .gitignore | 3 +- jest.config.js | 10 ++++++ package.json | 3 +- 5 files changed, 47 insertions(+), 34 deletions(-) create mode 100644 jest.config.js diff --git a/.deepsource.toml b/.deepsource.toml index 6b046d6..883e614 100644 --- a/.deepsource.toml +++ b/.deepsource.toml @@ -1,12 +1,17 @@ version = 1 [[analyzers]] -name = "typescript" +name = "javascript" enabled = true + [analyzers.meta] + environment = ["nodejs"] + style_guide = "airbnb" + [[analyzers]] -name = "javascript" +name = "test-coverage" enabled = true -[analyzers.meta] -env = ["nodejs"] \ No newline at end of file +[[transformers]] +name = "prettier" +enabled = true diff --git a/.github/workflows/deepsource.yml b/.github/workflows/deepsource.yml index 344e77a..ebe79fa 100644 --- a/.github/workflows/deepsource.yml +++ b/.github/workflows/deepsource.yml @@ -1,44 +1,40 @@ -name: Deepsource Code Review +name: DeepSource Code Review on: pull_request: - branches: - - main - - develop + types: [opened, synchronize] jobs: - deepsource-review: + analyze: + name: Analyze runs-on: ubuntu-latest + steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 + - name: Checkout repository + uses: actions/checkout@v2 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v2 with: - node-version: '20' - cache: 'npm' + node-version: '18' - name: Install dependencies run: npm ci - - name: Run Lint + - name: Run linter run: npm run lint - - name: Run Deepsource CLI - env: - DEEPSOURCE_TOKEN: ${{ secrets.DEEPSOURCE_TOKEN }} - run: | - # Deepsource CLI 설치 - curl https://deepsource.io/cli | sh - - # Lint 분석 실행 - ./bin/deepsource report --analyzer lint \ - --key typescript \ - --value "$(cat lint-report.json)" - - # 필요한 경우 테스트 커버리지 추가 - # - name: Run Tests with Coverage - # run: npm run test:coverage + - name: Run tests and generate coverage + run: npm test -- --coverage + + - name: Upload coverage to DeepSource + uses: deepsourcelabs/test-coverage-action@master + with: + key: javascript + coverage-file: ./coverage/lcov.info + dsn: ${{ secrets.DEEPSOURCE_DSN }} + + - name: DeepSource Analyze + uses: deepsourcelabs/analyze-action@v1 + with: + dsn: ${{ secrets.DEEPSOURCE_DSN }} diff --git a/.gitignore b/.gitignore index caaf1be..97c5073 100644 --- a/.gitignore +++ b/.gitignore @@ -36,4 +36,5 @@ yarn-error.log* *.tsbuildinfo next-env.d.ts -*storybook.log \ No newline at end of file +# storybook +*storybook.log diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 0000000..c0b6250 --- /dev/null +++ b/jest.config.js @@ -0,0 +1,10 @@ +module.exports = { + collectCoverage: true, + coverageReporters: ['lcov', 'text'], + coverageDirectory: 'coverage', + testEnvironment: 'jsdom', + setupFilesAfterEnv: ['/jest.setup.js'], + moduleNameMapper: { + '^@/(.*)$': '/src/$1', + }, +}; diff --git a/package.json b/package.json index 4da267b..87ac8cf 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ "prepare": "husky", "postinstall": "husky install", "storybook": "storybook dev -p 6006", - "build-storybook": "storybook build" + "build-storybook": "storybook build", + "test": "jest --coverage" }, "dependencies": { "@tanstack/react-query": "^5.59.14",