name: end-to-end-test on: pull_request: paths: - "django/aiservice/**" workflow_dispatch: permissions: contents: read pull-requests: read jobs: check-changes: runs-on: ubuntu-latest outputs: should_run: ${{ steps.filter.outputs.relevant == 'true' || github.event_name == 'workflow_dispatch' }} steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Check which projects changed uses: dorny/paths-filter@v2 id: filter with: filters: | relevant: - 'django/aiservice/**' - '.github/workflows/end-to-end-test-bubblesort-pytest-no-git.yaml' skip: needs: check-changes if: ${{ needs.check-changes.outputs.should_run != 'true' }} runs-on: ubuntu-latest steps: - name: Skip test run: echo "No relevant changes detected, skipping end-to-end test" - name: Mark as success run: exit 0 bubble-sort-optimization-pytest-no-git: needs: check-changes if: ${{ needs.check-changes.outputs.should_run == 'true' }} runs-on: ubuntu-latest env: CODEFLASH_AIS_SERVER: local AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }} OPENAI_API_TYPE: ${{ secrets.OPENAI_API_TYPE }} OPENAI_API_BASE: ${{ secrets.OPENAI_API_BASE }} ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} DATABASE_URL: ${{ secrets.DATABASE_URL }} POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }} CODEFLASH_API_KEY: ${{ secrets.CODEFLASH_API_KEY }} COLUMNS: 110 MAX_RETRIES: 3 RETRY_DELAY: 5 EXPECTED_IMPROVEMENT_PCT: 70 CODEFLASH_END_TO_END: 1 steps: - name: Check out codeflash-internal repo uses: actions/checkout@v4 with: fetch-depth: 0 token: ${{ secrets.GITHUB_TOKEN }} - name: Set up Python 3.12 for AI Server uses: astral-sh/setup-uv@v7 with: python-version: "3.12" - name: Install dependencies for Django server run: | cd ./django/aiservice uv sync - name: Start Django server run: | cd ./django/aiservice uv run python manage.py runserver localhost:8000 >> server.log 2>&1 & - name: Remove .git run: | if [ -d ".git" ]; then echo ".git directory exists!" sudo rm -rf .git if [ -d ".git" ]; then echo ".git directory still exists after removal attempt!" exit 1 else echo ".git directory successfully removed." fi else echo ".git directory does not exist. Nothing to remove." exit 1 fi - name: Clone codeflash repo run: | cd .. git clone https://github.com/codeflash-ai/codeflash.git env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Set up Python 3.11 for CLI uses: actions/setup-python@v5 with: python-version: "3.11.6" - name: Install dependencies (CLI) run: | cd ../codeflash uv sync uv add sqlalchemy - name: Run Codeflash to optimize code id: optimize_code run: | cd ../codeflash uv run python tests/scripts/end_to_end_test_bubblesort_pytest.py - name: Display AI Server logs if: always() run: | cd ./django/aiservice cat server.log