diff --git a/.drone.yml b/.drone.yml index 1af2bb1..6cd8ac5 100644 --- a/.drone.yml +++ b/.drone.yml @@ -11,14 +11,15 @@ steps: image: php:8.1-cli commands: - echo "Checking PHP syntax in all files..." + - set -e - find . -type f -name '*.php' -exec php -l {} \; || echo "PHP syntax errors found!" # Check HTML syntax - name: check_html_syntax image: ubuntu:20.04 commands: - - apt-get update - - apt-get install -y tidy + - set -e + - apt-get update && apt-get install -y tidy - echo "Checking HTML syntax in all files..." - find . -type f -name '*.html' -exec tidy -q -e {} \; || echo "HTML syntax errors found!" @@ -26,41 +27,42 @@ steps: - name: client_test image: node:18-alpine commands: + - set -e - echo "Running tests for React client..." - - cd services/client || echo "services/client directory not found!" - - if [ -f package.json ]; then - yarn install --frozen-lockfile; - CI=true yarn test --coverage; + - if [ -d services/client ]; then + cd services/client; + if [ -f package.json ]; then + yarn install --frozen-lockfile; + CI=true yarn test --coverage; + else + echo "package.json not found! Skipping client tests."; + fi else - echo "package.json not found! Skipping client tests."; + echo "services/client directory not found!"; fi # Run tests for Python backend - name: engine_test image: python:3.9-alpine commands: + - set -e - echo "Running tests for Python backend..." - - cd services/game || echo "services/game directory not found!" - - if [ -f requirements.txt ]; then - pip install -r requirements.txt; - python manage.py recreate_db; - pytest --cov=project --cov-report=term-missing; + - if [ -d services/game ]; then + cd services/game; + if [ -f requirements.txt ]; then + pip install -r requirements.txt; + pytest --cov=app --cov-report=term-missing; + else + echo "requirements.txt not found! Skipping backend tests."; + fi else - echo "requirements.txt not found! Skipping backend tests."; + echo "services/game directory not found!"; fi environment: FLASK_ENV: production APP_SETTINGS: project.config.TestingConfig DATABASE_TEST_URL: postgres://postgres:postgres@gamedb:5432/game_test - # Cleanup step - - name: cleanup - image: alpine:latest - commands: - - echo "Cleaning up after tests..." - - rm -rf /tmp/* - - echo "Cleanup complete!" - services: - name: gamedb image: postgres:15-alpine diff --git a/services/client/package.json b/services/client/package.json new file mode 100644 index 0000000..a59a39d --- /dev/null +++ b/services/client/package.json @@ -0,0 +1,20 @@ +{ + "name": "client", + "version": "1.0.0", + "private": true, + "scripts": { + "start": "react-scripts start", + "build": "react-scripts build", + "test": "react-scripts test --watchAll=false", + "eject": "react-scripts eject" + }, + "dependencies": { + "react": "^18.0.0", + "react-dom": "^18.0.0", + "react-scripts": "5.0.1" + }, + "devDependencies": { + "@testing-library/react": "^13.0.0", + "jest": "^29.0.0" + } +} diff --git a/services/client/src/App.js b/services/client/src/App.js new file mode 100644 index 0000000..0553168 --- /dev/null +++ b/services/client/src/App.js @@ -0,0 +1,11 @@ +import React from 'react'; + +function App() { + return ( +
+

Hello, World!

+
+ ); +} + +export default App; diff --git a/services/client/src/App.test.js b/services/client/src/App.test.js new file mode 100644 index 0000000..f822374 --- /dev/null +++ b/services/client/src/App.test.js @@ -0,0 +1,8 @@ +import { render, screen } from '@testing-library/react'; +import App from './App'; + +test('renders Hello, World!', () => { + render(); + const headingElement = screen.getByText(/Hello, World!/i); + expect(headingElement).toBeInTheDocument(); +}); diff --git a/services/game/app/__init__.py b/services/game/app/__init__.py new file mode 100644 index 0000000..e5bc12f --- /dev/null +++ b/services/game/app/__init__.py @@ -0,0 +1,10 @@ +from flask import Flask + +def create_app(): + app = Flask(__name__) + + @app.route("/") + def hello_world(): + return "Hello, World!" + + return app diff --git a/services/game/app/config.py b/services/game/app/config.py new file mode 100644 index 0000000..8570fb6 --- /dev/null +++ b/services/game/app/config.py @@ -0,0 +1,4 @@ +import os + +class Config: + SECRET_KEY = os.environ.get("SECRET_KEY", "default_secret_key") diff --git a/services/game/app/main.py b/services/game/app/main.py new file mode 100644 index 0000000..183c186 --- /dev/null +++ b/services/game/app/main.py @@ -0,0 +1,3 @@ +from . import create_app + +app = create_app() diff --git a/services/game/manage.py b/services/game/manage.py new file mode 100644 index 0000000..fe05d46 --- /dev/null +++ b/services/game/manage.py @@ -0,0 +1,6 @@ +from app import create_app + +app = create_app() + +if __name__ == "__main__": + app.run() diff --git a/services/game/requirements.txt b/services/game/requirements.txt new file mode 100644 index 0000000..2929d9d --- /dev/null +++ b/services/game/requirements.txt @@ -0,0 +1,4 @@ +Flask==2.2.2 +pytest==7.2.0 +gunicorn==20.1.0 +psycopg2-binary==2.9.6 diff --git a/services/game/tests/test_app.py b/services/game/tests/test_app.py new file mode 100644 index 0000000..ece94a0 --- /dev/null +++ b/services/game/tests/test_app.py @@ -0,0 +1,19 @@ +import pytest +from app import create_app + +@pytest.fixture +def app(): + app = create_app() + app.config.update({ + "TESTING": True, + }) + return app + +@pytest.fixture +def client(app): + return app.test_client() + +def test_hello_world(client): + response = client.get("/") + assert response.status_code == 200 + assert response.data == b"Hello, World!"