1+ name : end-to-end-test 
2+ 
3+ on :
4+   #  Use pull_request_target for everything to ensure access to secrets
5+   pull_request_target :
6+     paths :
7+       - ' **'    #  Trigger for all paths
8+ 
9+   workflow_dispatch :
10+ 
11+ jobs :
12+   benchmark-bubble-sort-optimization :
13+     #  Dynamically determine if environment is needed only when workflow files change and contributor is external
14+     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' || '' }} 
15+ 
16+     runs-on : ubuntu-latest 
17+     env :
18+       CODEFLASH_AIS_SERVER : prod 
19+       POSTHOG_API_KEY : ${{ secrets.POSTHOG_API_KEY }} 
20+       CODEFLASH_API_KEY : ${{ secrets.CODEFLASH_API_KEY }} 
21+       COLUMNS : 110 
22+       MAX_RETRIES : 3 
23+       RETRY_DELAY : 5 
24+       EXPECTED_IMPROVEMENT_PCT : 5 
25+       CODEFLASH_END_TO_END : 1 
26+     steps :
27+       - name : 🛎️ Checkout 
28+         uses : actions/checkout@v4 
29+         with :
30+           ref : ${{ github.event.pull_request.head.ref }} 
31+           repository : ${{ github.event.pull_request.head.repo.full_name }} 
32+           fetch-depth : 0 
33+           token : ${{ secrets.GITHUB_TOKEN }} 
34+ 
35+       - name : Validate PR 
36+         run : | 
37+           # Check for any workflow changes 
38+           if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" | grep -q "^.github/workflows/"; then 
39+             echo "⚠️ Workflow changes detected." 
40+ 
41+             # Get the PR author 
42+             AUTHOR="${{ github.event.pull_request.user.login }}" 
43+             echo "PR Author: $AUTHOR" 
44+ 
45+             # Allowlist check 
46+             if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then 
47+               echo "✅ Authorized user ($AUTHOR). Proceeding." 
48+             elif [[ "${{ github.event.pull_request.state }}" == "open" ]]; then 
49+               echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding." 
50+             else 
51+               echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting." 
52+               exit 1 
53+             fi 
54+           else 
55+             echo "✅ No workflow file changes detected. Proceeding." 
56+           fi 
57+ 
58+        - name : Set up Python 3.11 for CLI 
59+         uses : astral-sh/setup-uv@v5 
60+         with :
61+           python-version : 3.11.6 
62+ 
63+       - name : Install dependencies (CLI) 
64+         run : | 
65+           uv tool install poetry 
66+           uv venv 
67+           source .venv/bin/activate 
68+           poetry install --with dev 
69+ 
70+        - name : Run Codeflash to optimize code 
71+         id : optimize_code_with_benchmarks 
72+         run : | 
73+           source .venv/bin/activate 
74+           poetry run python tests/scripts/end_to_end_test_benchmark_sort.py 
0 commit comments