From 24196605c7eed5f8e74136513806c07594c8a931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hrachovina?= Date: Thu, 28 Nov 2024 17:20:35 +0100 Subject: [PATCH] Update .drone.yml --- .drone.yml | 113 ++++++++++++++++++++++++++--------------------------- 1 file changed, 56 insertions(+), 57 deletions(-) diff --git a/.drone.yml b/.drone.yml index 6cd8ac5..bc908ce 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,72 +1,71 @@ -################ -# Build & Test # -################ - +--- kind: pipeline -name: run_tests +type: docker +name: default steps: - # Check PHP syntax - - name: check_php_syntax - image: php:8.1-cli + # Step 1: Install dependencies and run server tests + - name: server_test + image: node:18-alpine commands: - - echo "Checking PHP syntax in all files..." - - set -e - - find . -type f -name '*.php' -exec php -l {} \; || echo "PHP syntax errors found!" + - echo "Running server tests..." + - cd services/server || echo "services/server directory not 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 - - 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 + # Step 2: Install dependencies and run client tests - name: client_test image: node:18-alpine commands: - - set -e - echo "Running tests for React client..." - - 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 + - cd services/client || echo "services/client directory not found!" + - if [ -f package.json ]; then + yarn install --frozen-lockfile; + yarn add --dev @babel/plugin-proposal-private-property-in-object @testing-library/jest-dom; + yarn test --coverage --detectOpenHandles; else - echo "services/client directory not found!"; + echo "package.json not found! Skipping client tests."; fi - # Run tests for Python backend - - name: engine_test - image: python:3.9-alpine + # Step 3: Lint and static analysis (optional) + - name: lint + image: node:18-alpine commands: - - set -e - - echo "Running tests for Python backend..." - - 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 "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 + - echo "Running linter..." + - cd services/client || echo "services/client directory not found!" + - yarn lint || echo "Linting failed! Please fix lint errors." -services: - - name: gamedb - image: postgres:15-alpine + # Step 4: Build the React client + - name: client_build + 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: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: game_test + DEPLOY_KEY: + from_secret: deploy_key + commands: + - echo "Deploying application..." + - # Add deployment commands here (e.g., SSH, Rsync, Kubernetes, etc.) + +# Specify trigger conditions +trigger: + branch: + - main + event: + - push + - pull_request