This commit is contained in:
113
.drone.yml
113
.drone.yml
@@ -1,72 +1,71 @@
|
|||||||
################
|
---
|
||||||
# Build & Test #
|
|
||||||
################
|
|
||||||
|
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
name: run_tests
|
type: docker
|
||||||
|
name: default
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# Check PHP syntax
|
# Step 1: Install dependencies and run server tests
|
||||||
- name: check_php_syntax
|
- name: server_test
|
||||||
image: php:8.1-cli
|
image: node:18-alpine
|
||||||
commands:
|
commands:
|
||||||
- echo "Checking PHP syntax in all files..."
|
- echo "Running server tests..."
|
||||||
- set -e
|
- cd services/server || echo "services/server directory not found!"
|
||||||
- find . -type f -name '*.php' -exec php -l {} \; || echo "PHP syntax errors found!"
|
- if [ -f package.json ]; then
|
||||||
|
yarn install --frozen-lockfile;
|
||||||
|
yarn test;
|
||||||
|
else
|
||||||
|
echo "package.json not found! Skipping server tests.";
|
||||||
|
fi
|
||||||
|
|
||||||
# Check HTML syntax
|
# Step 2: Install dependencies and run client tests
|
||||||
- name: check_html_syntax
|
|
||||||
image: ubuntu:20.04
|
|
||||||
commands:
|
|
||||||
- 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!"
|
|
||||||
|
|
||||||
# Run tests for React client
|
|
||||||
- name: client_test
|
- name: client_test
|
||||||
image: node:18-alpine
|
image: node:18-alpine
|
||||||
commands:
|
commands:
|
||||||
- set -e
|
|
||||||
- echo "Running tests for React client..."
|
- echo "Running tests for React client..."
|
||||||
- if [ -d services/client ]; then
|
- cd services/client || echo "services/client directory not found!"
|
||||||
cd services/client;
|
- if [ -f package.json ]; then
|
||||||
if [ -f package.json ]; then
|
yarn install --frozen-lockfile;
|
||||||
yarn install --frozen-lockfile;
|
yarn add --dev @babel/plugin-proposal-private-property-in-object @testing-library/jest-dom;
|
||||||
CI=true yarn test --coverage;
|
yarn test --coverage --detectOpenHandles;
|
||||||
else
|
|
||||||
echo "package.json not found! Skipping client tests.";
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
echo "services/client directory not found!";
|
echo "package.json not found! Skipping client tests.";
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run tests for Python backend
|
# Step 3: Lint and static analysis (optional)
|
||||||
- name: engine_test
|
- name: lint
|
||||||
image: python:3.9-alpine
|
image: node:18-alpine
|
||||||
commands:
|
commands:
|
||||||
- set -e
|
- echo "Running linter..."
|
||||||
- echo "Running tests for Python backend..."
|
- cd services/client || echo "services/client directory not found!"
|
||||||
- if [ -d services/game ]; then
|
- yarn lint || echo "Linting failed! Please fix lint errors."
|
||||||
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 "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
|
|
||||||
|
|
||||||
services:
|
# Step 4: Build the React client
|
||||||
- name: gamedb
|
- name: client_build
|
||||||
image: postgres:15-alpine
|
image: node:18-alpine
|
||||||
|
commands:
|
||||||
|
- echo "Building React client..."
|
||||||
|
- cd services/client || echo "services/client directory not found!"
|
||||||
|
- if [ -f package.json ]; then
|
||||||
|
yarn install --frozen-lockfile;
|
||||||
|
yarn build;
|
||||||
|
else
|
||||||
|
echo "package.json not found! Skipping build.";
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Step 5: Deploy (example step)
|
||||||
|
- name: deploy
|
||||||
|
image: alpine:latest
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_USER: postgres
|
DEPLOY_KEY:
|
||||||
POSTGRES_PASSWORD: postgres
|
from_secret: deploy_key
|
||||||
POSTGRES_DB: game_test
|
commands:
|
||||||
|
- echo "Deploying application..."
|
||||||
|
- # Add deployment commands here (e.g., SSH, Rsync, Kubernetes, etc.)
|
||||||
|
|
||||||
|
# Specify trigger conditions
|
||||||
|
trigger:
|
||||||
|
branch:
|
||||||
|
- main
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- pull_request
|
||||||
|
|||||||
Reference in New Issue
Block a user