Merge pull request #61 from Bentlybro/fix/e2e-tests-rewrite #75
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Core Platform Testing | |
| on: | |
| push: | |
| branches: [ main, master ] | |
| pull_request: | |
| branches: [ main, master ] | |
| workflow_dispatch: # Allow manual trigger | |
| permissions: | |
| contents: read | |
| jobs: | |
| e2e-test: | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:15-alpine | |
| env: | |
| POSTGRES_PASSWORD: test_password | |
| POSTGRES_USER: test_user | |
| POSTGRES_DB: automoderate_test | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.12' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install requests pytest pytest-asyncio | |
| - name: Wait for PostgreSQL | |
| run: | | |
| until pg_isready -h localhost -p 5432; do | |
| echo "Waiting for PostgreSQL..." | |
| sleep 2 | |
| done | |
| - name: Start AutoModerate application | |
| env: | |
| FLASK_ENV: testing | |
| CI: true | |
| SECRET_KEY: test-secret-key-for-ci | |
| DATABASE_URL: postgresql://test_user:test_password@localhost:5432/automoderate_test | |
| ADMIN_EMAIL: admin@example.com | |
| ADMIN_PASSWORD: admin123 | |
| # OpenAI not required for core platform testing | |
| OPENAI_API_KEY: "test-key" | |
| run: | | |
| # Start the application in background | |
| python run.py & | |
| APP_PID=$! | |
| echo "APP_PID=$APP_PID" >> $GITHUB_ENV | |
| # Wait for application to start | |
| echo "Waiting for application to start..." | |
| for i in {1..30}; do | |
| if curl -s http://localhost:6217/api/health > /dev/null; then | |
| echo "Application is ready!" | |
| break | |
| fi | |
| echo "Attempt $i/30: Application not ready yet..." | |
| sleep 2 | |
| done | |
| # Final health check | |
| if ! curl -s http://localhost:6217/api/health > /dev/null; then | |
| echo "Application failed to start properly" | |
| exit 1 | |
| fi | |
| - name: Run core platform tests | |
| env: | |
| BASE_URL: http://localhost:6217 | |
| OPENAI_API_KEY: "test-key" # Signals to skip moderation tests | |
| run: | | |
| python tests/e2e_test.py | |
| - name: Cleanup | |
| if: always() | |
| run: | | |
| if [ ! -z "$APP_PID" ]; then | |
| echo "Killing application process $APP_PID" | |
| kill $APP_PID || true | |
| fi | |
| # Kill any remaining processes on port 6217 | |
| lsof -ti:6217 | xargs kill -9 || true |