|
| 1 | +name: E2E - Bubble Sort Pytest (No Git) |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - '**' # Trigger for all paths |
| 7 | + |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +jobs: |
| 11 | + bubble-sort-optimization-pytest-no-git: |
| 12 | + # Dynamically determine if environment is needed only when workflow files change and contributor is external |
| 13 | + environment: ${{ (github.event_name == 'workflow_dispatch' || (contains(toJSON(github.event.pull_request.files.*.filename), '.github/workflows/') && github.event.pull_request.user.login != 'misrasaurabh1' && github.event.pull_request.user.login != 'KRRT7')) && 'external-trusted-contributors' || '' }} |
| 14 | + |
| 15 | + runs-on: ubuntu-latest |
| 16 | + env: |
| 17 | + CODEFLASH_AIS_SERVER: prod |
| 18 | + POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }} |
| 19 | + CODEFLASH_API_KEY: ${{ secrets.CODEFLASH_API_KEY }} |
| 20 | + COLUMNS: 110 |
| 21 | + MAX_RETRIES: 3 |
| 22 | + RETRY_DELAY: 5 |
| 23 | + EXPECTED_IMPROVEMENT_PCT: 300 |
| 24 | + CODEFLASH_END_TO_END: 1 |
| 25 | + steps: |
| 26 | + - name: 🛎️ Checkout |
| 27 | + uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + ref: ${{ github.event.pull_request.head.ref }} |
| 30 | + repository: ${{ github.event.pull_request.head.repo.full_name }} |
| 31 | + fetch-depth: 0 |
| 32 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 33 | + - name: Validate PR |
| 34 | + run: | |
| 35 | + # Check for any workflow changes |
| 36 | + if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" | grep -q "^.github/workflows/"; then |
| 37 | + echo "⚠️ Workflow changes detected." |
| 38 | +
|
| 39 | + # Get the PR author |
| 40 | + AUTHOR="${{ github.event.pull_request.user.login }}" |
| 41 | + echo "PR Author: $AUTHOR" |
| 42 | +
|
| 43 | + # Allowlist check |
| 44 | + if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then |
| 45 | + echo "✅ Authorized user ($AUTHOR). Proceeding." |
| 46 | + elif [[ "${{ github.event.pull_request.state }}" == "open" ]]; then |
| 47 | + echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding." |
| 48 | + else |
| 49 | + echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting." |
| 50 | + exit 1 |
| 51 | + fi |
| 52 | + else |
| 53 | + echo "✅ No workflow file changes detected. Proceeding." |
| 54 | + fi |
| 55 | +
|
| 56 | + - name: Set up Python 3.11 for CLI |
| 57 | + uses: astral-sh/setup-uv@v5 |
| 58 | + with: |
| 59 | + python-version: 3.11.6 |
| 60 | + |
| 61 | + - name: Install dependencies (CLI) |
| 62 | + run: | |
| 63 | + uv sync |
| 64 | + |
| 65 | + - name: Remove .git |
| 66 | + run: | |
| 67 | + if [ -d ".git" ]; then |
| 68 | + echo ".git directory exists!" |
| 69 | + sudo rm -rf .git |
| 70 | + if [ -d ".git" ]; then |
| 71 | + echo ".git directory still exists after removal attempt!" |
| 72 | + exit 1 |
| 73 | + else |
| 74 | + echo ".git directory successfully removed." |
| 75 | + fi |
| 76 | + else |
| 77 | + echo ".git directory does not exist. Nothing to remove." |
| 78 | + exit 1 |
| 79 | + fi |
| 80 | +
|
| 81 | + - name: Run Codeflash to optimize code |
| 82 | + id: optimize_code |
| 83 | + run: | |
| 84 | + uv run python tests/scripts/end_to_end_test_bubblesort_pytest.py |
0 commit comments