Skip to content
Draft
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
7 changes: 7 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
POSTGRES_DB=test-db
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_HOST=db
POSTGRES_PORT=5432
POSTGRES_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}
URL=http://localhost:3000
67 changes: 67 additions & 0 deletions .github/workflows/test-repository.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Test Repository

on:
push:
branches:
- "**"
pull_request:
branches:
- "**"
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: リポジトリのチェックアウト
uses: actions/checkout@v3

- name: Docker Compose のバージョン確認
run: |
docker compose --version

- name: テスト用DBを起動
run: |
docker compose -f compose.yml --env-file .env.test up -d

- name: Postgres の起動待機
run: |
for i in {1..10}; do
if docker exec digichat-db pg_isready -U postgres; then
echo "Postgres is ready!"
exit 0
fi
echo "Waiting for Postgres..."
sleep 2
done
echo "Postgres did not become ready in time." >&2
exit 1

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "20"

- name: Install pnpm
run: npm install -g pnpm

- name: Install dependencies
run: pnpm install

- name: Generate Prisma Client
run: pnpm prisma generate

- name: テスト用DBのマイグレーション
env:
POSTGRES_HOST: localhost
run: make migrate-test

- name: リポジトリテストの実行
env:
POSTGRES_HOST: localhost
run: make t-repo

- name: Docker Compose の停止
if: always()
run: docker compose -f compose.yml --env-file .env.test down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ yarn-error.log*
# env files (can opt-in for committing if needed)
.env*
!.env.example
!.env.test

# vercel
.vercel
Expand Down
30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# 開発用DBのマイグレーション
migrate:
pnpm prisma migrate dev

# 本番用DBのマイグレーション
migrate-prod:
pnpm prisma migrate deploy

# テスト用DBのマイグレーション
migrate-test:
pnpm migrate-test

# Prisma Studio
studio:
pnpm prisma studio

# リポジトリ層のテスト
t-repo: test-repository
test-repository:
pnpm jest-repository

# 開発用サーバーの起動
dev:
pnpm dev

# コミット前のチェック
pre-commit:
pnpm format
pnpm lint
pnpm stylelint
22 changes: 22 additions & 0 deletions jest.config.repo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const config = {
preset: "ts-jest",
testEnvironment: "@quramy/jest-prisma/environment",
testEnvironmentOptions: {
enableExperimentalRollbackInTransaction: true,
},
roots: ["<rootDir>/src/repositories"],
moduleNameMapper: {
"^@/(.*)$": "<rootDir>/src/$1",
},
transform: {
"^.+\\.(ts|tsx|js|jsx)$": [
"ts-jest",
{
useESM: true,
},
],
},
extensionsToTreatAsEsm: [".ts", ".tsx", ".mts"],
};

module.exports = config;
52 changes: 22 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"format": "prettier --write \"./src/**/*.{ts,tsx}\"",
"lint": "eslint",
"stylelint": "stylelint \"./src/**/*.css\" --fix",
"seed": "npx prisma migrate reset --force & npx tsx ./prisma/seed/init.ts"
"seed": "node prisma/seed/init.mjs"
},
"dependencies": {
"@auth/prisma-adapter": "^2.8.0",
Expand All @@ -22,17 +22,21 @@
"@mantine/spotlight": "^7.17.3",
"@mantine/tiptap": "^7.17.3",
"@prisma/client": "^6.5.0",
"@quramy/jest-prisma": "^1.8.1",
"@tabler/icons-react": "^3.31.0",
"@tiptap/extension-image": "^2.11.7",
"@tiptap/extension-link": "^2.11.7",
"@tiptap/pm": "^2.11.7",
"@tiptap/react": "^2.11.7",
"@tiptap/starter-kit": "^2.11.7",
"@types/jest": "^29.5.14",
"aws-sdk": "^2.1692.0",
"clsx": "^2.1.1",
"dayjs": "^1.11.13",
"dayjs-plugin-utc": "^0.1.2",
"dotenv-cli": "^8.0.0",
"emoji-mart": "^5.6.0",
"jest": "^29.7.0",
"next": "15.2.4",
"next-auth": "5.0.0-beta.25",
"react": "^19.1.0",
Expand All @@ -48,38 +52,26 @@
"remark-parse": "^11.0.0",
"remark-rehype": "^11.1.2",
"sharp": "^0.34.0",
"ts-jest": "^29.3.4",
"ts-node": "^10.9.2",
"unified": "^11.0.5",
"uuid": "^11.1.0"
},
"devDependencies": {
"@eslint/eslintrc": "^3.3.1",
"@next/eslint-plugin-next": "^15.2.4",
"@types/node": "^22.14.0",
"@types/react": "^19.1.0",
"@types/react-dom": "^19.1.1",
"@types/uuid": "^10.0.0",
"eslint": "^9.24.0",
"eslint-config-next": "15.2.4",
"eslint-config-prettier": "^10.1.1",
"@eslint/eslintrc": "^3",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"eslint": "^9.16.0",
"eslint-config-next": "15.1.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-react-hooks": "^5.2.0",
"prettier": "^3.5.3",
"prisma": "^6.5.0",
"prisma-markdown": "^1.0.9",
"stylelint": "^16.17.0",
"stylelint-config-recess-order": "^6.0.0",
"stylelint-config-standard": "^37.0.0",
"typescript": "^5.8.3",
"typescript-eslint": "^8.29.0"
},
"pnpm": {
"onlyBuiltDependencies": [
"@prisma/client",
"@prisma/engines",
"aws-sdk",
"esbuild",
"prisma",
"sharp"
]
"prettier": "^3.4.2",
"prisma": "^6.2.1",
"stylelint": "^16.11.0",
"stylelint-config-recess-order": "^5.1.1",
"stylelint-config-standard": "^36.0.1",
"typescript": "^5",
"typescript-eslint": "^8.19.0"
}
}
}
Loading
Loading