diff --git a/.gitea/workflows/test-working-v4.yml b/.gitea/workflows/test-working-v4.yml deleted file mode 100644 index 4c8615f..0000000 --- a/.gitea/workflows/test-working-v4.yml +++ /dev/null @@ -1,177 +0,0 @@ -name: Working CI v4 - Skip Checkout - -on: - push: - branches: [ main, develop, feature/* ] - pull_request: - branches: [ main, develop ] - -jobs: - backend-tests: - name: Backend Tests (Python) - runs-on: ubuntu-latest - container: python:3.13-slim - - services: - postgres: - image: postgres:16-alpine - env: - POSTGRES_PASSWORD: test_password - POSTGRES_USER: test_user - POSTGRES_DB: test_db - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - - steps: - - name: Install git and basic tools - run: | - apt-get update - apt-get install -y git curl - - - name: Check workspace contents - run: | - echo "=== Checking Workspace Contents ===" - echo "Current working directory: $(pwd)" - echo "Current user: $(whoami)" - echo "Environment variables:" - env | grep GITHUB || echo "No GITHUB vars" - echo "Directory contents:" - ls -la - echo "Backend directory exists: $(test -d backend && echo 'yes' || echo 'no')" - if [ -d backend ]; then - echo "Backend contents:" - ls -la backend/ - echo "pyproject.toml exists: $(test -f backend/pyproject.toml && echo 'yes' || echo 'no')" - else - echo "Creating minimal backend structure for testing..." - mkdir -p backend/src/backend backend/tests - - # Create pyproject.toml using printf to avoid heredoc issues - printf '[build-system]\nrequires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.2"]\nbuild-backend = "setuptools.build_meta"\n\n[project]\nname = "backend"\nversion = "0.1.0"\ndescription = "Backend API"\nrequires-python = ">=3.12"\ndependencies = [\n "fastapi",\n "uvicorn",\n]\n\n[project.optional-dependencies]\ndev = [\n "pytest",\n "pytest-cov",\n "typeguard",\n "ruff",\n "pyright",\n]\n\n[tool.setuptools.packages.find]\nwhere = ["src"]\n\n[tool.setuptools.package-dir]\n"" = "src"\n' > backend/pyproject.toml - - # Create __init__.py files - printf '"""Backend package."""\n__version__ = "0.1.0"\n' > backend/src/backend/__init__.py - - # Create main.py - printf '"""Main FastAPI application."""\nfrom fastapi import FastAPI\n\napp = FastAPI()\n\n@app.get("/")\ndef read_root():\n return {"Hello": "World"}\n' > backend/src/backend/main.py - - # Create test files - printf '"""Tests package."""\n' > backend/tests/__init__.py - printf '"""Example tests."""\nimport pytest\n\ndef test_example():\n assert 1 + 1 == 2\n\ndef test_import():\n import backend\n assert backend.__version__ == "0.1.0"\n' > backend/tests/test_example.py - - echo "Minimal backend structure created" - fi - - - name: Install uv - run: | - curl -LsSf https://astral.sh/uv/install.sh | sh - export PATH="$HOME/.cargo/bin:$PATH" - uv --version - - - name: Setup backend environment - run: | - export PATH="$HOME/.cargo/bin:$PATH" - cd backend - echo "=== Setting up Python environment ===" - uv venv - source .venv/bin/activate - echo "Virtual environment activated" - echo "Installing dependencies..." - uv pip install -e .[dev] - echo "Dependencies installed" - echo "Verifying installation:" - python -c "import backend; print('Backend module imported successfully')" - - - name: Run backend tests with coverage and typeguard - run: | - export PATH="$HOME/.cargo/bin:$PATH" - cd backend - source .venv/bin/activate - echo "=== Running backend tests ===" - python -m pytest tests/ -v \ - --cov=src \ - --cov-report=html \ - --cov-report=term \ - --typeguard-packages=backend,src - env: - DATABASE_URL: postgresql://test_user:test_password@postgres:5432/test_db - - frontend-tests: - name: Frontend Tests (TypeScript/Vue) - runs-on: ubuntu-latest - container: node:20-slim - - steps: - - name: Install git and basic tools - run: | - apt-get update - apt-get install -y git curl - - - name: Check workspace contents - run: | - echo "=== Checking Workspace Contents ===" - echo "Current working directory: $(pwd)" - echo "Current user: $(whoami)" - echo "Environment variables:" - env | grep GITHUB || echo "No GITHUB vars" - echo "Directory contents:" - ls -la - echo "Frontend directory exists: $(test -d frontend && echo 'yes' || echo 'no')" - if [ -d frontend ]; then - echo "Frontend contents:" - ls -la frontend/ - echo "package.json exists: $(test -f frontend/package.json && echo 'yes' || echo 'no')" - else - echo "Creating minimal frontend structure for testing..." - mkdir -p frontend/src frontend/tests/unit - - # Create package.json using printf to avoid heredoc issues - printf '{\n "name": "frontend",\n "version": "0.1.0",\n "description": "Frontend Vue app",\n "scripts": {\n "dev": "vite",\n "build": "vue-tsc && vite build",\n "type-check": "vue-tsc --noEmit",\n "test:unit": "vitest",\n "lint": "eslint ."\n },\n "dependencies": {\n "vue": "^3.3.0"\n },\n "devDependencies": {\n "@vitejs/plugin-vue": "^4.3.0",\n "@vue/test-utils": "^2.4.0",\n "eslint": "^8.46.0",\n "typescript": "^5.1.0",\n "vite": "^4.4.0",\n "vitest": "^0.34.0",\n "vue-tsc": "^1.8.0"\n }\n}\n' > frontend/package.json - - # Create App.vue - printf '\n\n\n' > frontend/src/App.vue - - # Create test file - printf 'import { describe, it, expect } from "vitest"\nimport { mount } from "@vue/test-utils"\n\ndescribe("Basic Test", () => {\n it("should work", () => {\n expect(1 + 1).toBe(2)\n })\n})\n' > frontend/tests/unit/App.test.ts - - # Create tsconfig.json - printf '{\n "compilerOptions": {\n "target": "ES2020",\n "useDefineForClassFields": true,\n "lib": ["ES2020", "DOM", "DOM.Iterable"],\n "module": "ESNext",\n "skipLibCheck": true,\n "moduleResolution": "bundler",\n "allowImportingTsExtensions": true,\n "resolveJsonModule": true,\n "isolatedModules": true,\n "noEmit": true,\n "jsx": "preserve",\n "strict": true,\n "noUnusedLocals": true,\n "noUnusedParameters": true,\n "noFallthroughCasesInSwitch": true\n },\n "include": ["src/**/*.ts", "src/**/*.vue", "tests/**/*.ts"],\n "references": [{ "path": "./tsconfig.node.json" }]\n}\n' > frontend/tsconfig.json - - # Create tsconfig.node.json - printf '{\n "compilerOptions": {\n "composite": true,\n "skipLibCheck": true,\n "module": "ESNext",\n "moduleResolution": "bundler",\n "allowSyntheticDefaultImports": true\n },\n "include": ["vite.config.ts"]\n}\n' > frontend/tsconfig.node.json - - # Create vite.config.ts - printf 'import { defineConfig } from "vite"\nimport vue from "@vitejs/plugin-vue"\n\nexport default defineConfig({\n plugins: [vue()],\n})\n' > frontend/vite.config.ts - - # Create vitest.config.ts - printf 'import { defineConfig } from "vite"\nimport vue from "@vitejs/plugin-vue"\n\nexport default defineConfig({\n plugins: [vue()],\n test: {\n environment: "jsdom",\n },\n})\n' > frontend/vitest.config.ts - - echo "Minimal frontend structure created" - fi - - - name: Install yarn - run: | - npm install -g yarn - yarn --version - - - name: Setup frontend environment - run: | - cd frontend - echo "=== Installing frontend dependencies ===" - yarn install - echo "Dependencies installed" - - - name: Run frontend type checking - run: | - cd frontend - echo "=== Running type checking ===" - yarn type-check - - - name: Run frontend tests with coverage - run: | - cd frontend - echo "=== Running frontend tests ===" - yarn test:unit diff --git a/.gitea/workflows/tests.yml b/.gitea/workflows/tests.yml new file mode 100644 index 0000000..e53b6db --- /dev/null +++ b/.gitea/workflows/tests.yml @@ -0,0 +1,113 @@ +name: Tests + +on: + push: + branches: [ main, develop, feature/* ] + pull_request: + branches: [ main, develop ] + +jobs: + backend-tests: + name: Backend Tests (Python 3.13 + uv) + runs-on: ubuntu-latest + container: python:3.13-slim + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install system dependencies + run: | + apt-get update + apt-get install -y curl git + + - name: Install uv + run: | + curl -LsSf https://astral.sh/uv/install.sh | sh + echo "$HOME/.cargo/bin" >> $GITHUB_PATH + + - name: Verify uv installation + run: | + export PATH="$HOME/.cargo/bin:$PATH" + uv --version + + - name: Setup Python environment with uv + working-directory: ./backend + run: | + export PATH="$HOME/.cargo/bin:$PATH" + # Create virtual environment + uv venv .venv --python 3.13 + + # Activate environment and install dependencies + . .venv/bin/activate + uv pip install -e ".[dev]" + + # Verify installation + python --version + python -c "import backend; print(f'Backend version: {backend.__version__}')" + + # Show installed packages + uv pip list + + - name: Run tests with pytest + working-directory: ./backend + run: | + export PATH="$HOME/.cargo/bin:$PATH" + . .venv/bin/activate + + # Run tests with coverage and typeguard + python -m pytest tests/ -v --cov=backend --cov-report=term-missing + + frontend-tests: + name: Frontend Tests (TypeScript + Vue + Yarn Berry) + runs-on: ubuntu-latest + container: node:20-slim + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install system dependencies + run: | + apt-get update + apt-get install -y curl git + + - name: Setup Yarn Berry + run: | + corepack enable + corepack prepare yarn@stable --activate + + - name: Verify Node and Yarn + run: | + node --version + yarn --version + + - name: Install dependencies + working-directory: ./frontend + run: | + # Initialize yarn berry if not already done + yarn set version stable + + # Install dependencies + yarn install + + - name: Verify TypeScript and Vue installation + working-directory: ./frontend + run: | + # Check that key packages are available + yarn list typescript + yarn list vue + yarn list @vitejs/plugin-vue + + # Verify TypeScript compilation works + yarn type-check + + - name: Build frontend + working-directory: ./frontend + run: | + yarn build + + - name: Run frontend tests + working-directory: ./frontend + run: | + yarn test:unit