Skip to content

Commit 79ae59f

Browse files
committed
add gha e2e tests
1 parent 54ef710 commit 79ae59f

3 files changed

Lines changed: 249 additions & 0 deletions

File tree

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: E2E - JS CommonJS Function
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '**' # Trigger for all paths
7+
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref_name }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
js-cjs-function-optimization:
16+
# Dynamically determine if environment is needed only when workflow files change and contributor is external
17+
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' || '' }}
18+
19+
runs-on: ubuntu-latest
20+
env:
21+
CODEFLASH_AIS_SERVER: prod
22+
POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
23+
CODEFLASH_API_KEY: ${{ secrets.CODEFLASH_API_KEY }}
24+
COLUMNS: 110
25+
MAX_RETRIES: 3
26+
RETRY_DELAY: 5
27+
EXPECTED_IMPROVEMENT_PCT: 50
28+
CODEFLASH_END_TO_END: 1
29+
steps:
30+
- name: 🛎️ Checkout
31+
uses: actions/checkout@v4
32+
with:
33+
ref: ${{ github.event.pull_request.head.ref }}
34+
repository: ${{ github.event.pull_request.head.repo.full_name }}
35+
fetch-depth: 0
36+
token: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- name: Validate PR
39+
run: |
40+
# Check for any workflow changes
41+
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" | grep -q "^.github/workflows/"; then
42+
echo "⚠️ Workflow changes detected."
43+
44+
# Get the PR author
45+
AUTHOR="${{ github.event.pull_request.user.login }}"
46+
echo "PR Author: $AUTHOR"
47+
48+
# Allowlist check
49+
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
50+
echo "✅ Authorized user ($AUTHOR). Proceeding."
51+
elif [[ "${{ github.event.pull_request.state }}" == "open" ]]; then
52+
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
53+
else
54+
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
55+
exit 1
56+
fi
57+
else
58+
echo "✅ No workflow file changes detected. Proceeding."
59+
fi
60+
61+
- name: Set up Node.js
62+
uses: actions/setup-node@v4
63+
with:
64+
node-version: '20'
65+
66+
- name: Install JS test project dependencies
67+
run: |
68+
cd code_to_optimize/js/code_to_optimize_js
69+
npm install
70+
71+
- name: Set up Python 3.11 for CLI
72+
uses: astral-sh/setup-uv@v6
73+
with:
74+
python-version: 3.11.6
75+
76+
- name: Install dependencies (CLI)
77+
run: |
78+
uv sync
79+
80+
- name: Run Codeflash to optimize JS CommonJS function
81+
id: optimize_code
82+
run: |
83+
uv run python tests/scripts/end_to_end_test_js_cjs_function.py
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: E2E - JS ESM Async
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '**' # Trigger for all paths
7+
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref_name }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
js-esm-async-optimization:
16+
# Dynamically determine if environment is needed only when workflow files change and contributor is external
17+
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' || '' }}
18+
19+
runs-on: ubuntu-latest
20+
env:
21+
CODEFLASH_AIS_SERVER: prod
22+
POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
23+
CODEFLASH_API_KEY: ${{ secrets.CODEFLASH_API_KEY }}
24+
COLUMNS: 110
25+
MAX_RETRIES: 3
26+
RETRY_DELAY: 5
27+
EXPECTED_IMPROVEMENT_PCT: 10
28+
CODEFLASH_END_TO_END: 1
29+
steps:
30+
- name: 🛎️ Checkout
31+
uses: actions/checkout@v4
32+
with:
33+
ref: ${{ github.event.pull_request.head.ref }}
34+
repository: ${{ github.event.pull_request.head.repo.full_name }}
35+
fetch-depth: 0
36+
token: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- name: Validate PR
39+
run: |
40+
# Check for any workflow changes
41+
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" | grep -q "^.github/workflows/"; then
42+
echo "⚠️ Workflow changes detected."
43+
44+
# Get the PR author
45+
AUTHOR="${{ github.event.pull_request.user.login }}"
46+
echo "PR Author: $AUTHOR"
47+
48+
# Allowlist check
49+
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
50+
echo "✅ Authorized user ($AUTHOR). Proceeding."
51+
elif [[ "${{ github.event.pull_request.state }}" == "open" ]]; then
52+
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
53+
else
54+
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
55+
exit 1
56+
fi
57+
else
58+
echo "✅ No workflow file changes detected. Proceeding."
59+
fi
60+
61+
- name: Set up Node.js
62+
uses: actions/setup-node@v4
63+
with:
64+
node-version: '20'
65+
66+
- name: Install JS test project dependencies
67+
run: |
68+
cd code_to_optimize/js/code_to_optimize_js_esm
69+
npm install
70+
71+
- name: Set up Python 3.11 for CLI
72+
uses: astral-sh/setup-uv@v6
73+
with:
74+
python-version: 3.11.6
75+
76+
- name: Install dependencies (CLI)
77+
run: |
78+
uv sync
79+
80+
- name: Run Codeflash to optimize ESM async function
81+
id: optimize_code
82+
run: |
83+
uv run python tests/scripts/end_to_end_test_js_esm_async.py
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: E2E - JS TypeScript Class
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '**' # Trigger for all paths
7+
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref_name }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
js-ts-class-optimization:
16+
# Dynamically determine if environment is needed only when workflow files change and contributor is external
17+
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' || '' }}
18+
19+
runs-on: ubuntu-latest
20+
env:
21+
CODEFLASH_AIS_SERVER: prod
22+
POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
23+
CODEFLASH_API_KEY: ${{ secrets.CODEFLASH_API_KEY }}
24+
COLUMNS: 110
25+
MAX_RETRIES: 3
26+
RETRY_DELAY: 5
27+
EXPECTED_IMPROVEMENT_PCT: 30
28+
CODEFLASH_END_TO_END: 1
29+
steps:
30+
- name: 🛎️ Checkout
31+
uses: actions/checkout@v4
32+
with:
33+
ref: ${{ github.event.pull_request.head.ref }}
34+
repository: ${{ github.event.pull_request.head.repo.full_name }}
35+
fetch-depth: 0
36+
token: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- name: Validate PR
39+
run: |
40+
# Check for any workflow changes
41+
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" | grep -q "^.github/workflows/"; then
42+
echo "⚠️ Workflow changes detected."
43+
44+
# Get the PR author
45+
AUTHOR="${{ github.event.pull_request.user.login }}"
46+
echo "PR Author: $AUTHOR"
47+
48+
# Allowlist check
49+
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
50+
echo "✅ Authorized user ($AUTHOR). Proceeding."
51+
elif [[ "${{ github.event.pull_request.state }}" == "open" ]]; then
52+
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
53+
else
54+
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
55+
exit 1
56+
fi
57+
else
58+
echo "✅ No workflow file changes detected. Proceeding."
59+
fi
60+
61+
- name: Set up Node.js
62+
uses: actions/setup-node@v4
63+
with:
64+
node-version: '20'
65+
66+
- name: Install JS test project dependencies
67+
run: |
68+
cd code_to_optimize/js/code_to_optimize_ts
69+
npm install
70+
71+
- name: Set up Python 3.11 for CLI
72+
uses: astral-sh/setup-uv@v6
73+
with:
74+
python-version: 3.11.6
75+
76+
- name: Install dependencies (CLI)
77+
run: |
78+
uv sync
79+
80+
- name: Run Codeflash to optimize TypeScript class method
81+
id: optimize_code
82+
run: |
83+
uv run python tests/scripts/end_to_end_test_js_ts_class.py

0 commit comments

Comments
 (0)