Backup: 2025-06-07 19:48 - Script test

[Restore from backup: vip-coordinator-backup-2025-06-07-19-48-script-test]
This commit is contained in:
2025-06-07 19:48:00 +02:00
parent 8fb00ec041
commit dc4655cef4
103 changed files with 16396 additions and 6143 deletions

239
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,239 @@
name: CI/CD Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
env:
REGISTRY: docker.io
IMAGE_NAME: t72chevy/vip-coordinator
jobs:
# Backend tests
backend-tests:
name: Backend Tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_password
POSTGRES_DB: vip_coordinator_test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
redis:
image: redis:7
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: backend/package-lock.json
- name: Install dependencies
working-directory: ./backend
run: npm ci
- name: Run linter
working-directory: ./backend
run: npm run lint || true
- name: Run type check
working-directory: ./backend
run: npx tsc --noEmit
- name: Run tests
working-directory: ./backend
env:
DATABASE_URL: postgresql://test_user:test_password@localhost:5432/vip_coordinator_test
REDIS_URL: redis://localhost:6379
GOOGLE_CLIENT_ID: test_client_id
GOOGLE_CLIENT_SECRET: test_client_secret
GOOGLE_REDIRECT_URI: http://localhost:3000/auth/google/callback
FRONTEND_URL: http://localhost:5173
JWT_SECRET: test_jwt_secret_minimum_32_characters_long
NODE_ENV: test
run: npm test
- name: Upload coverage
uses: actions/upload-artifact@v4
if: always()
with:
name: backend-coverage
path: backend/coverage/
# Frontend tests
frontend-tests:
name: Frontend Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
working-directory: ./frontend
run: npm ci
- name: Run linter
working-directory: ./frontend
run: npm run lint
- name: Run type check
working-directory: ./frontend
run: npx tsc --noEmit
- name: Run tests
working-directory: ./frontend
run: npm test -- --run
- name: Build frontend
working-directory: ./frontend
run: npm run build
- name: Upload coverage
uses: actions/upload-artifact@v4
if: always()
with:
name: frontend-coverage
path: frontend/coverage/
# Build Docker images
build-images:
name: Build Docker Images
runs-on: ubuntu-latest
needs: [backend-tests, frontend-tests]
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha,prefix={{branch}}-
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Backend
uses: docker/build-push-action@v5
with:
context: ./backend
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:backend-${{ github.sha }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:backend-latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push Frontend
uses: docker/build-push-action@v5
with:
context: ./frontend
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:frontend-${{ github.sha }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:frontend-latest
cache-from: type=gha
cache-to: type=gha,mode=max
# Security scan
security-scan:
name: Security Scan
runs-on: ubuntu-latest
needs: [backend-tests, frontend-tests]
steps:
- uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
format: 'sarif'
output: 'trivy-results.sarif'
- name: Upload Trivy scan results
uses: github/codeql-action/upload-sarif@v2
if: always()
with:
sarif_file: 'trivy-results.sarif'
# Deploy to staging (example)
deploy-staging:
name: Deploy to Staging
runs-on: ubuntu-latest
needs: [build-images]
if: github.ref == 'refs/heads/develop'
environment:
name: staging
url: https://staging.bsa.madeamess.online
steps:
- uses: actions/checkout@v4
- name: Deploy to staging
run: |
echo "Deploying to staging environment..."
# Add your deployment script here
# Example: ssh to server and docker-compose pull && up
# Deploy to production
deploy-production:
name: Deploy to Production
runs-on: ubuntu-latest
needs: [build-images, security-scan]
if: github.ref == 'refs/heads/main'
environment:
name: production
url: https://bsa.madeamess.online
steps:
- uses: actions/checkout@v4
- name: Deploy to production
run: |
echo "Deploying to production environment..."
# Add your deployment script here
# Example: ssh to server and docker-compose pull && up

69
.github/workflows/dependency-update.yml vendored Normal file
View File

@@ -0,0 +1,69 @@
name: Dependency Updates
on:
schedule:
# Run weekly on Mondays at 3 AM UTC
- cron: '0 3 * * 1'
workflow_dispatch:
jobs:
update-dependencies:
name: Update Dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Update Backend Dependencies
working-directory: ./backend
run: |
npm update
npm audit fix || true
- name: Update Frontend Dependencies
working-directory: ./frontend
run: |
npm update
npm audit fix || true
- name: Check for changes
id: check_changes
run: |
if [[ -n $(git status -s) ]]; then
echo "changes=true" >> $GITHUB_OUTPUT
else
echo "changes=false" >> $GITHUB_OUTPUT
fi
- name: Create Pull Request
if: steps.check_changes.outputs.changes == 'true'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'chore: update dependencies'
title: 'Automated Dependency Updates'
body: |
## Automated Dependency Updates
This PR contains automated dependency updates for both frontend and backend packages.
### What's included:
- Updated npm dependencies to latest compatible versions
- Applied security fixes from `npm audit`
### Checklist:
- [ ] Review dependency changes
- [ ] Run tests locally
- [ ] Check for breaking changes in updated packages
- [ ] Update any affected code if needed
*This PR was automatically generated by the dependency update workflow.*
branch: deps/automated-update-${{ github.run_number }}
delete-branch: true

119
.github/workflows/e2e-tests.yml vendored Normal file
View File

@@ -0,0 +1,119 @@
name: E2E Tests
on:
schedule:
# Run E2E tests daily at 2 AM UTC
- cron: '0 2 * * *'
workflow_dispatch:
inputs:
environment:
description: 'Environment to test'
required: true
default: 'staging'
type: choice
options:
- staging
- production
jobs:
e2e-tests:
name: E2E Tests - ${{ github.event.inputs.environment || 'staging' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Playwright
run: |
npm init -y
npm install -D @playwright/test
npx playwright install --with-deps
- name: Create E2E test structure
run: |
mkdir -p e2e/tests
cat > e2e/playwright.config.ts << 'EOF'
import { defineConfig, devices } from '@playwright/test';
export default defineConfig({
testDir: './tests',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: 'html',
use: {
baseURL: process.env.BASE_URL || 'https://staging.bsa.madeamess.online',
trace: 'on-first-retry',
screenshot: 'only-on-failure',
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
],
});
EOF
- name: Create sample E2E test
run: |
cat > e2e/tests/auth.spec.ts << 'EOF'
import { test, expect } from '@playwright/test';
test.describe('Authentication Flow', () => {
test('should display login page', async ({ page }) => {
await page.goto('/');
await expect(page).toHaveTitle(/VIP Coordinator/);
await expect(page.locator('text=Sign in with Google')).toBeVisible();
});
test('should redirect to dashboard after login', async ({ page }) => {
// This would require mocking Google OAuth or using test credentials
// For now, just check that the login button exists
await page.goto('/');
const loginButton = page.locator('button:has-text("Sign in with Google")');
await expect(loginButton).toBeVisible();
});
});
EOF
- name: Run E2E tests
env:
BASE_URL: ${{ github.event.inputs.environment == 'production' && 'https://bsa.madeamess.online' || 'https://staging.bsa.madeamess.online' }}
run: |
cd e2e
npx playwright test
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: e2e/playwright-report/
retention-days: 30
notify-results:
name: Notify Results
runs-on: ubuntu-latest
needs: [e2e-tests]
if: always()
steps:
- name: Send notification
run: |
echo "E2E tests completed with status: ${{ needs.e2e-tests.result }}"
# Add notification logic here (Slack, email, etc.)