Skip to content
Merged
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
8 changes: 4 additions & 4 deletions .github/workflows/branch-name-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ jobs:
result-encoding: string
script: |
const enforceSemantic = (branchName) => {
const semanticFormat = /(feat\W|feature\/|fix\/|chore\/|refactor\/|dependabot\/|docs\/|style\/|test\/)/
if (!semanticFormat.test(currentBranch)) {
const semanticFormat = /^(feat|feature|fix|chore|refactor|dependabot|docs|style|test|ci)\//
if (!semanticFormat.test(branchName)) {
core.setFailed(
`Branch names in PRs should use semantic conventions, e.g. (feat, fix, chore, refactor). To fix. ` +
`perform: git branch -m <new_branch_name> && git push origin -u <:<old_branch_name> <new_branch_name>` +
`Branch names in PRs should use semantic conventions, e.g. (feat, fix, chore, refactor, ci). ` +
`To fix, run: git branch -m <old_branch_name> <new_branch_name> && git push origin -u <new_branch_name>. ` +
`For more details, please review https://www.conventionalcommits.org/ and https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716`)
}
}
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ jobs:
- name: Auto-merge patch and minor updates
if: >
steps.metadata.outputs.update-type == 'version-update:semver-patch' ||
steps.metadata.outputs.update-type == 'version-update:semver-minor' ||
steps.metadata.outputs.update-type == 'version-update:semver-major'
steps.metadata.outputs.update-type == 'version-update:semver-minor'
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/pr-validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ jobs:
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --show-source --exit-zero --max-complexity=10 \
--max-line-length=96 --statistics --per-file-ignore='specs/**/*:E9,F63,F7,F82'
- name: Type check with mypy
run: |
cd backend && find "$(pwd)/src" -type f -name "*.py" ! -name "*test_*" \
-exec python -m mypy {} +
- name: Run pytest tests
run: |
chmod +x ./backend/scripts/test-coverage.sh
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ npm run lint:backend
npm run format:frontend
npm run lint:frontend

git add .
git update-index --again
7 changes: 7 additions & 0 deletions backend/mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[mypy]

[mypy-jose.*]
ignore_missing_imports = True

[mypy-asyncpg.*]
ignore_missing_imports = True
2 changes: 1 addition & 1 deletion backend/scripts/lint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -e
flake8 src/ specs/
find "$(pwd)/src" -type f -name "\"*.py\"" ! -name "\"*test_*\"" \
find "$(pwd)/src" -type f -name "*.py" ! -name "*test_*" \
-exec python -m mypy {} +
2 changes: 1 addition & 1 deletion backend/src/api/resolvers/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ async def fetch_available_rooms(db, checkin_date, checkout_date) -> Dict[str, An
return {"success": True, "rooms": available_rooms}


async def fetch_room(db, room_id: str) -> Room:
async def fetch_room(db, room_id: str) -> Dict[str, Any]:
result = await fetch_by_id(db, Room, id=room_id)
if result["success"]:
return result
Expand Down
12 changes: 6 additions & 6 deletions backend/src/api/resolvers/mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ async def create_reservation_resolver(obj, info, input: dict) -> Dict[str, Any]:
utils.log_api_message(__name__, str(error))
return {"success": False, "errors": [str(error)]}
except Exception as e:
error = f"Unexpected error: {str(e)}"
utils.log_api_message(__name__, f"Unexpected error: {error}")
return {"success": False, "errors": [error]}
message = f"Unexpected error: {str(e)}"
utils.log_api_message(__name__, message)
return {"success": False, "errors": [message]}
finally:
await db.close()

Expand All @@ -41,8 +41,8 @@ async def delete_reservation_resolver(obj, info, reservationId: int) -> Dict[str
utils.log_api_message(__name__, str(error))
return {"success": False, "errors": [str(error)]}
except Exception as e:
error = f"Unexpected error: {str(e)}"
utils.log_api_message(__name__, f"Unexpected error: {error}")
return {"success": False, "errors": [error]}
message = f"Unexpected error: {str(e)}"
utils.log_api_message(__name__, message)
return {"success": False, "errors": [message]}
finally:
await db.close()
24 changes: 12 additions & 12 deletions backend/src/api/resolvers/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ async def get_reservation_resolver(obj, info, id) -> Dict[str, Any]:
"errors": [message],
}
except Exception as e:
error = f"Unexpected error: {str(e)}"
utils.log_api_message(__name__, f"Unexpected error: {error}")
return {"success": False, "errors": [error]}
message = f"Unexpected error: {str(e)}"
utils.log_api_message(__name__, message)
return {"success": False, "errors": [message]}
finally:
await db.close()

Expand All @@ -34,9 +34,9 @@ async def get_all_reservations_resolver(obj, info) -> Dict[str, Any]:
utils.log_api_message(__name__, str(error))
return {"success": False, "errors": [str(error)]}
except Exception as e:
error = f"Unexpected error: {str(e)}"
utils.log_api_message(__name__, f"Unexpected error: {error}")
return {"success": False, "errors": [error]}
message = f"Unexpected error: {str(e)}"
utils.log_api_message(__name__, message)
return {"success": False, "errors": [message]}
finally:
await db.close()

Expand All @@ -49,9 +49,9 @@ async def get_all_rooms_resolver(obj, info) -> Dict[str, Any]:
utils.log_api_message(__name__, str(error))
return {"success": False, "errors": [str(error)]}
except Exception as e:
error = f"Unexpected error: {str(e)}"
utils.log_api_message(__name__, f"Unexpected error: {error}")
return {"success": False, "errors": [error]}
message = f"Unexpected error: {str(e)}"
utils.log_api_message(__name__, message)
return {"success": False, "errors": [message]}
finally:
await db.close()

Expand All @@ -71,8 +71,8 @@ async def get_available_rooms_resolver(obj, info, input: dict) -> Dict[str, Any]
utils.log_api_message(__name__, str(error))
return {"success": False, "errors": [str(error)]}
except Exception as e:
error = f"Unexpected error: {str(e)}"
utils.log_api_message(__name__, f"Unexpected error: {error}")
return {"success": False, "errors": [error]}
message = f"Unexpected error: {str(e)}"
utils.log_api_message(__name__, message)
return {"success": False, "errors": [message]}
finally:
await db.close()
1 change: 1 addition & 0 deletions backend/src/requirements_docker.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ fastapi==0.139.0
flake8==7.3.0
httpx==0.28.1
isort==8.0.1
mypy==1.14.1
psycopg2-binary==2.9.12
pydantic==2.13.4
pytest==9.1.1
Expand Down
4 changes: 3 additions & 1 deletion backend/src/routes/about.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Any, Dict

from fastapi import APIRouter

import api.utils as utils
Expand All @@ -18,7 +20,7 @@ async def about_handler() -> ApiData:
desc = """This is a GraphQL API that allows you to create and
list reservations as well as the ability to list available rooms
for a given date range."""
data = {"name": f"{API_NAME}", "description": desc}
data: Dict[str, Any] = {"name": f"{API_NAME}", "description": desc}
response = ApiData(data=data, status=utils.StatusCode.OK)
except Exception as error:
messages = str(error)
Expand Down
4 changes: 2 additions & 2 deletions backend/src/routes/graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def _setup_routes(self):
async def graphql_handler(request: Request) -> ApiData:
try:
result = await graphql_app.handle_request(request)
result = result.body.decode()
inner_data = json.loads(result).get("data", {})
body = bytes(result.body).decode()
inner_data = json.loads(body).get("data", {})
response = ApiData(data=inner_data, status=utils.StatusCode.OK)
except Exception as error:
messages = str(error)
Expand Down
5 changes: 0 additions & 5 deletions frontend/.eslintignore

This file was deleted.

30 changes: 0 additions & 30 deletions frontend/.eslintrc

This file was deleted.

39 changes: 39 additions & 0 deletions frontend/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import js from '@eslint/js';
import react from 'eslint-plugin-react';
import comments from 'eslint-plugin-eslint-comments';
import globals from 'globals';

export default [
{
ignores: ['node_modules/**', 'public/**', 'build/**', 'dist/**', 'specs/**'],
},
js.configs.recommended,
react.configs.flat['jsx-runtime'],
{
files: ['src/**/*.{js,jsx}'],
plugins: {
'eslint-comments': comments,
},
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: {
...globals.browser,
},
},
settings: {
react: { version: '18.2' },
},
rules: {
...comments.configs.recommended.rules,
'react/jsx-uses-react': 'error',
'react/jsx-uses-vars': 'error',
'react/jsx-no-target-blank': 'off',
'no-unused-vars': ['warn', { argsIgnorePattern: '_' }],
'no-empty-function': ['error', { allow: ['methods', 'arrowFunctions'] }],
'no-case-declarations': 'off',
'no-console': 'error',
'no-debugger': 'error',
},
},
];
44 changes: 8 additions & 36 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ fastapi==0.136.3
flake8==6.1.0
httpx==0.26.0
isort==8.0.1
mypy==1.14.1
psycopg2-binary==2.9.12
pydantic==2.13.4
pytest==9.0.3
Expand Down
Loading