diff --git a/.deepsource.toml b/.deepsource.toml new file mode 100644 index 0000000..883e614 --- /dev/null +++ b/.deepsource.toml @@ -0,0 +1,17 @@ +version = 1 + +[[analyzers]] +name = "javascript" +enabled = true + + [analyzers.meta] + environment = ["nodejs"] + style_guide = "airbnb" + +[[analyzers]] +name = "test-coverage" +enabled = true + +[[transformers]] +name = "prettier" +enabled = true diff --git a/.github/workflows/deepsource.yml b/.github/workflows/deepsource.yml new file mode 100644 index 0000000..ebe79fa --- /dev/null +++ b/.github/workflows/deepsource.yml @@ -0,0 +1,40 @@ +name: DeepSource Code Review + +on: + pull_request: + types: [opened, synchronize] + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: '18' + + - name: Install dependencies + run: npm ci + + - name: Run linter + run: npm run lint + + - 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..442e605 100644 --- a/.gitignore +++ b/.gitignore @@ -36,4 +36,7 @@ yarn-error.log* *.tsbuildinfo next-env.d.ts -*storybook.log \ No newline at end of file +*storybook.log + +# testing +/coverage \ No newline at end of file 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",