From d3babd5d854ffd0c404e18dcdf88112222d1aa52 Mon Sep 17 00:00:00 2001 From: rin-yato Date: Mon, 15 Apr 2024 13:44:47 +0700 Subject: [PATCH] fix: ci and test --- .github/workflows/check1.yaml | 19 +++++++----- gui/jest.config.cjs | 9 ++++++ gui/package.json | 8 ++++- gui/tsconfig.json | 9 +++++- pnpm-lock.yaml | 55 +++++++++++++++++++++++++++++++++++ studio/package.json | 4 +-- turbo.json | 8 ++++- 7 files changed, 100 insertions(+), 12 deletions(-) create mode 100644 gui/jest.config.cjs diff --git a/.github/workflows/check1.yaml b/.github/workflows/check1.yaml index 5a2d1bbf..bfb61a91 100644 --- a/.github/workflows/check1.yaml +++ b/.github/workflows/check1.yaml @@ -5,6 +5,7 @@ on: branches: - develop pull_request: + workflow_dispatch: jobs: quality-check: @@ -24,17 +25,21 @@ jobs: node-version: 20 cache: pnpm - - name: Cache deps - uses: actions/cache@v3 + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - name: Cache pnpm + uses: actions/cache@v4 with: - path: | - ${{ github.workspace }}/.deps - key: ${{ runner.os }}-deps-${{ hashFiles('**/pnpm-lock.yaml') }} + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | - ${{ runner.os }}-deps-${{ hashFiles('**/pnpm-lock.yaml') }} + ${{ runner.os }}-pnpm-store- - name: Cache turbo tasks - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: .turbo key: ${{ runner.os }}-turbo-${{ github.sha }} diff --git a/gui/jest.config.cjs b/gui/jest.config.cjs new file mode 100644 index 00000000..fe74d3f8 --- /dev/null +++ b/gui/jest.config.cjs @@ -0,0 +1,9 @@ +/** @type {import('ts-jest').JestConfigWithTsJest} */ +module.exports = { + preset: "ts-jest", + testEnvironment: "jsdom", + rootDir: "./", + moduleNameMapper: { + "^@gui/(.*)$": "/src/$1", + }, +}; diff --git a/gui/package.json b/gui/package.json index e16df681..90a478bd 100644 --- a/gui/package.json +++ b/gui/package.json @@ -14,7 +14,10 @@ "scripts": { "dev": "tsup --watch", "build": "tsup", + "staged": "pnpm run typecheck && pnpm run format && pnpm run lint && pnpm run test", "typecheck": "tsc --noEmit", + "test": "jest", + "test:watch": "jest --watch", "lint": "eslint .", "lint:fix": "eslint . --fix", "format": "prettier --check .", @@ -76,15 +79,18 @@ "devDependencies": { "@libsqlstudio/tailwind": "workspace:*", "@libsqlstudio/tsconfig": "workspace:*", - "eslint-config-libsqlstudio": "workspace:*", "@types/deep-equal": "^1.0.4", "@types/jest": "^29.5.11", "@types/react": "^18.2.66", "@types/react-dom": "^18.2.22", "@vitejs/plugin-react": "^4.2.1", "autoprefixer": "^10.4.19", + "eslint-config-libsqlstudio": "workspace:*", + "jest": "^29.7.0", + "jest-environment-jsdom": "^29.7.0", "postcss": "^8.4.38", "tailwindcss": "^3.4.3", + "ts-jest": "^29.1.2", "tsup": "^8.0.2", "vite": "^5.2.0", "vite-tsconfig-paths": "^4.3.2" diff --git a/gui/tsconfig.json b/gui/tsconfig.json index c3e9ad6f..7f9cb813 100644 --- a/gui/tsconfig.json +++ b/gui/tsconfig.json @@ -8,6 +8,13 @@ }, "noImplicitReturns": false }, - "include": ["**/*.ts", "**/*.tsx", ".eslintrc.cjs", "*.js", "*.ts"], + "include": [ + "**/*.ts", + "**/*.tsx", + ".eslintrc.cjs", + "*.js", + "*.ts", + "jest.config.cjs" + ], "exclude": ["node_modules", "dist"] } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 17058fe4..6262fc45 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -239,12 +239,21 @@ importers: eslint-config-libsqlstudio: specifier: workspace:* version: link:../config/eslint + jest: + specifier: ^29.7.0 + version: 29.7.0(@types/node@20.12.7)(ts-node@10.9.2) + jest-environment-jsdom: + specifier: ^29.7.0 + version: 29.7.0 postcss: specifier: ^8.4.38 version: 8.4.38 tailwindcss: specifier: ^3.4.3 version: 3.4.3(ts-node@10.9.2) + ts-jest: + specifier: ^29.1.2 + version: 29.1.2(@babel/core@7.24.4)(esbuild@0.19.12)(jest@29.7.0)(typescript@5.4.5) tsup: specifier: ^8.0.2 version: 8.0.2(postcss@8.4.38)(typescript@5.4.5) @@ -7358,6 +7367,13 @@ packages: node-releases: 2.0.14 update-browserslist-db: 1.0.13(browserslist@4.23.0) + /bs-logger@0.2.6: + resolution: {integrity: sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==} + engines: {node: '>= 6'} + dependencies: + fast-json-stable-stringify: 2.1.0 + dev: true + /bser@2.1.1: resolution: {integrity: sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==} dependencies: @@ -10401,6 +10417,10 @@ packages: dependencies: p-locate: 5.0.0 + /lodash.memoize@4.1.2: + resolution: {integrity: sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==} + dev: true + /lodash.merge@4.6.2: resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} @@ -12550,6 +12570,41 @@ packages: /ts-interface-checker@0.1.13: resolution: {integrity: sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==} + /ts-jest@29.1.2(@babel/core@7.24.4)(esbuild@0.19.12)(jest@29.7.0)(typescript@5.4.5): + resolution: {integrity: sha512-br6GJoH/WUX4pu7FbZXuWGKGNDuU7b8Uj77g/Sp7puZV6EXzuByl6JrECvm0MzVzSTkSHWTihsXt+5XYER5b+g==} + engines: {node: ^16.10.0 || ^18.0.0 || >=20.0.0} + hasBin: true + peerDependencies: + '@babel/core': '>=7.0.0-beta.0 <8' + '@jest/types': ^29.0.0 + babel-jest: ^29.0.0 + esbuild: '*' + jest: ^29.0.0 + typescript: '>=4.3 <6' + peerDependenciesMeta: + '@babel/core': + optional: true + '@jest/types': + optional: true + babel-jest: + optional: true + esbuild: + optional: true + dependencies: + '@babel/core': 7.24.4 + bs-logger: 0.2.6 + esbuild: 0.19.12 + fast-json-stable-stringify: 2.1.0 + jest: 29.7.0(@types/node@20.12.7)(ts-node@10.9.2) + jest-util: 29.7.0 + json5: 2.2.3 + lodash.memoize: 4.1.2 + make-error: 1.3.6 + semver: 7.6.0 + typescript: 5.4.5 + yargs-parser: 21.1.1 + dev: true + /ts-node@10.9.2(@types/node@20.12.7)(typescript@5.4.5): resolution: {integrity: sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==} hasBin: true diff --git a/studio/package.json b/studio/package.json index 5a2aa044..1fe4c4da 100644 --- a/studio/package.json +++ b/studio/package.json @@ -4,7 +4,7 @@ "private": false, "scripts": { "dev": "next dev --turbo", - "build": "npm run db:migrate && next build", + "build": "pnpm run db:migrate && next build", "start": "next start", "tsc": "tsc --noEmit --skipLibCheck", "test": "jest", @@ -13,7 +13,7 @@ "db:generate": "drizzle-kit generate:sqlite", "db:migrate": "tsx src/db/migrate.ts", "generate-random-key": "tsx src/cli/generate-aes-key.ts", - "staged": "npm run tsc && npm run lint && jest", + "staged": "pnpm run typecheck && pnpm run lint && jest", "typecheck": "tsc --noEmit --skipLibCheck", "format": "prettier --check .", "format:fix": "prettier --write .", diff --git a/turbo.json b/turbo.json index 25836c30..81b429ba 100644 --- a/turbo.json +++ b/turbo.json @@ -19,7 +19,13 @@ "test": { "cache": true }, "test:watch": { "persistent": true, "cache": false }, "staged": { - "dependsOn": ["^format", "^lint", "^typecheck", "^test"] + "dependsOn": [ + "@libsqlstudio/gui#build", + "^format", + "^lint", + "^typecheck", + "^test" + ] } } }