diff --git a/.github/workflows/vitest-action.yml b/.github/workflows/vitest-action.yml new file mode 100644 index 0000000..8a373b6 --- /dev/null +++ b/.github/workflows/vitest-action.yml @@ -0,0 +1,48 @@ +name: Run vitest tests + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +env: + NODE_ENV: development + JWT_SECRET_KEY: GITHUB_ACTIONS_DUMMY_SECRET_KEY + DEV_PG_NAME: postgres + +jobs: + build: + runs-on: ubuntu-latest + + services: + postgres: + image: postgres + + env: + POSTGRES_PASSWORD: postgres + POSTGRES_USER: postgres + POSTGRES_DB: postgres + + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + + strategy: + matrix: + node-version: [18.x] + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: "npm" + - run: yarn install + - run: yarn build + - run: yarn ci diff --git a/package.json b/package.json index 1cf1a1a..cbd247d 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,6 @@ "react-dom": "^16.8", "react-icons": "^5.0.1", "react-router-dom": "^6.21.1", - "start-server-and-test": "^2.0.1", "typescript": "^5.3.3", "ws": "^8.16.0" }, @@ -30,27 +29,30 @@ "build:server": "cd ./server && npx tsc", "build:client": "cd ./client && yarn && npx vite build", "start": "node server/dist/server/src/server.js", + "ci": "start-server-and-test start http://localhost:3000 ci:test ", "regen": "rm -rf ./client/node_modules && cd ./client && yarn && npx vite", "dev:client": "npx vite", "dev:server": "NODE_ENV=development TEST_PASSWORD=test nodemon --exec ts-node ./server/src/server.ts", - "test": "TEST_PASSWORD=test DEV_PG_NAME=dominion_pg_test vitest run" + "ci:test": "TEST_PASSWORD=test DEV_PG_NAME=postgres vitest --fileParallelism=false run", + "test": "TEST_PASSWORD=test DEV_PG_NAME=dominion_pg_test vitest --fileParallelism=false run" }, "author": "duckRabbitPy", "license": "ISC", "devDependencies": { "@effect/schema": "^0.64", - "@types/express": "^4.17.20", - "@types/node": "^20.10.6", - "@types/pg": "^8.10.2", - "@types/websocket": "^1.0.10", - "@typescript-eslint/eslint-plugin": "^6.18.0", - "@wll8/express-ws": "^1.0.5", "@total-typescript/ts-reset": "^0.5.1", "@types/bcrypt": "^5.0.2", "@types/cors": "^2.8.17", + "@types/express": "^4.17.20", "@types/jsonwebtoken": "^9.0.5", + "@types/node": "^20.10.6", "@types/nodemailer": "^6.4.14", + "@types/pg": "^8.10.2", + "@types/websocket": "^1.0.10", "@types/ws": "^8.5.10", + "@typescript-eslint/eslint-plugin": "^6.18.0", + "@wll8/express-ws": "^1.0.5", + "start-server-and-test": "^2.0.3", "ts-node": "^10.9.2", "typescript": "^5.3.3", "vitest": "^1.1.3" diff --git a/yarn.lock b/yarn.lock index 8ec059b..bd94f71 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2979,7 +2979,7 @@ stackback@0.0.2: resolved "https://registry.yarnpkg.com/stackback/-/stackback-0.0.2.tgz#1ac8a0d9483848d1695e418b6d031a3c3ce68e3b" integrity sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw== -start-server-and-test@^2.0.1: +start-server-and-test@^2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/start-server-and-test/-/start-server-and-test-2.0.3.tgz#15c53c85e23cba7698b498b8a2598cab95f3f802" integrity sha512-QsVObjfjFZKJE6CS6bSKNwWZCKBG6975/jKRPPGFfFh+yOQglSeGXiNWjzgQNXdphcBI9nXbyso9tPfX4YAUhg==