1+ name : E2E - Async
2+
3+ on :
4+ pull_request :
5+ paths :
6+ - ' **' # Trigger for all paths
7+
8+ workflow_dispatch :
9+
10+ jobs :
11+ async-optimization :
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 : 10
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+
34+ - name : Validate PR
35+ run : |
36+ # Check for any workflow changes
37+ if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" | grep -q "^.github/workflows/"; then
38+ echo "⚠️ Workflow changes detected."
39+
40+ # Get the PR author
41+ AUTHOR="${{ github.event.pull_request.user.login }}"
42+ echo "PR Author: $AUTHOR"
43+
44+ # Allowlist check
45+ if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
46+ echo "✅ Authorized user ($AUTHOR). Proceeding."
47+ elif [[ "${{ github.event.pull_request.state }}" == "open" ]]; then
48+ echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
49+ else
50+ echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
51+ exit 1
52+ fi
53+ else
54+ echo "✅ No workflow file changes detected. Proceeding."
55+ fi
56+
57+ - name : Set up Python 3.11 for CLI
58+ uses : astral-sh/setup-uv@v5
59+ with :
60+ python-version : 3.11.6
61+
62+ - name : Install dependencies (CLI)
63+ run : |
64+ uv sync
65+
66+ - name : Run Codeflash to optimize async code
67+ id : optimize_async_code
68+ run : |
69+ uv run python tests/scripts/end_to_end_test_async.py
0 commit comments