diff --git a/.github/workflows/pr-validate.yml b/.github/workflows/pr-validate.yml index a9e5e8a..acbe52c 100644 --- a/.github/workflows/pr-validate.yml +++ b/.github/workflows/pr-validate.yml @@ -37,8 +37,8 @@ jobs: --max-line-length=96 --statistics --per-file-ignore='specs/**/*:E9,F63,F7,F82' - name: Run pytest tests run: | - chmod +x ./backend/scripts/test.sh - cd backend && ./scripts/test.sh + chmod +x ./backend/scripts/test-coverage.sh + cd backend && ./scripts/test-coverage.sh unit-test-frontend: runs-on: ubuntu-latest diff --git a/backend/requirements-docker.txt b/backend/requirements-docker.txt index 5fd9cf2..e913c30 100644 --- a/backend/requirements-docker.txt +++ b/backend/requirements-docker.txt @@ -1,9 +1,8 @@ -ariadne==0.21 -asyncio==3.4.3 +ariadne==0.22 asyncpg==0.29.0 fastapi==0.109.2 httpx==0.26.0 -pydantic==2.5.3 -python-multipart==0.0.7 +pydantic==2.6.1 +python-multipart==0.0.9 python-jose==3.3.0 -uvicorn==0.25.0 +uvicorn==0.27.1 diff --git a/backend/run_tests.sh b/backend/run_tests.sh deleted file mode 100755 index 959bfef..0000000 --- a/backend/run_tests.sh +++ /dev/null @@ -1,12 +0,0 @@ -export ENV=test -export PYTHONDONTWRITEBYTECODE=1 - -PG_NAME=hotel_test ./../db/create_db.sh -cd ../db || exit -npm i -NODE_ENV=$ENV npm run refresh # hotels_test this will drop tables, re-create them -NODE_ENV=$ENV npm run seed - -cd ../backend || exit -find . -name "__pycache__" -exec rm -r {} + -python -m pytest --cov=src --cov-report term diff --git a/backend/scripts/test-converage.sh b/backend/scripts/test-coverage.sh similarity index 100% rename from backend/scripts/test-converage.sh rename to backend/scripts/test-coverage.sh diff --git a/frontend/.dockerignore b/frontend/.dockerignore new file mode 100644 index 0000000..f4b744a --- /dev/null +++ b/frontend/.dockerignore @@ -0,0 +1,3 @@ +coverage +node_modules +specs diff --git a/frontend/.eslintrc b/frontend/.eslintrc index 65a61fb..9c00769 100644 --- a/frontend/.eslintrc +++ b/frontend/.eslintrc @@ -6,13 +6,13 @@ ], "plugins": [ "eslint-comments", "react", "react-refresh" ], "root": true, - "env": { browser: true, es2020: true }, + "env": { "browser": true, "es2020": true }, "parserOptions": { "sourceType": "module", "ecmaVersion": "latest" }, "ignorePatterns": ["build","specs",".eslintrc"], - "settings": { "react": { version: "18.2" } }, + "settings": { "react": { "version": "18.2" } }, "rules": { "react/jsx-uses-react": "error", "react/jsx-uses-vars": "error", @@ -30,5 +30,5 @@ "no-case-declarations": "off", "no-console": "error", "no-debugger": "error" - }, + } } diff --git a/frontend/Dockerfile b/frontend/Dockerfile index de66adc..1518450 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,16 +1,18 @@ FROM node:20 as build-stage WORKDIR /app COPY . . -RUN npm i -g npm -RUN npm i --legacy-peer-deps +RUN npm ci +# Set default args. Override them at build time if needed +ARG FRONTEND_PORT="80" +ARG NODE_ENV="api" # 'api' is the default production url +ARG RESERVATION_API="http://localhost:8080/${NODE_ENV}" +# Set environment variables needed for the build +ENV FRONTEND_PORT=${FRONTEND_PORT} +ENV VITE_ENV=${NODE_ENV} +ENV VITE_RESERVATION_API=${RESERVATION_API} RUN npm run build FROM nginx:alpine -ARG FRONTEND_PORT="80" -ARG NODE_ENV="production" -ENV FRONTEND_PORT=${FRONTEND_PORT} -ENV NODE_ENV=${NODE_ENV} -ENV ENV=${NODE_ENV} COPY --from=build-stage /app/build/ /usr/share/nginx/html EXPOSE ${FRONTEND_PORT} CMD ["nginx", "-g", "daemon off;"] diff --git a/requirements.txt b/requirements.txt index c5246aa..f590a90 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,16 +1,15 @@ -ariadne==0.21 +ariadne==0.22 asyncpg==0.29.0 black==23.10.1 fastapi==0.109.2 flake8==6.1.0 httpx==0.26.0 isort==5.13.2 -pydantic==2.5.3 -python-multipart==0.0.7 +pydantic==2.6.1 +python-multipart==0.0.9 pytest==7.4.3 pytest-asyncio==0.23.3 pytest-cov==4.1.0 pytest-mock==3.12.0 python-jose==3.3.0 -uvicorn==0.25.0 - +uvicorn==0.27.1