Skip to content

Commit f5a61fb

Browse files
authored
Merge pull request #1058 from codeflash-ai/multi-language
codeflash-omni
2 parents d12553c + 7303936 commit f5a61fb

235 files changed

Lines changed: 61593 additions & 2935 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/codeflash.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Codeflash
2+
3+
on:
4+
pull_request:
5+
paths:
6+
# So that this workflow only runs when code within the target module is modified
7+
- 'code_to_optimize_js_esm/**'
8+
workflow_dispatch:
9+
10+
concurrency:
11+
# Any new push to the PR will cancel the previous run, so that only the latest code is optimized
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
16+
jobs:
17+
optimize:
18+
name: Optimize new code
19+
# Don't run codeflash on codeflash-ai[bot] commits, prevent duplicate optimizations
20+
if: ${{ github.actor != 'codeflash-ai[bot]' }}
21+
runs-on: ubuntu-latest
22+
env:
23+
CODEFLASH_API_KEY: ${{ secrets.CODEFLASH_API_KEY }}
24+
defaults:
25+
run:
26+
working-directory: ./code_to_optimize_js_esm
27+
steps:
28+
- name: 🛎️ Checkout
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
- name: 🟢 Setup Node.js
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version: '22'
36+
cache: 'npm'
37+
- name: 📦 Install Dependencies
38+
run: npm ci
39+
40+
- name: ⚡️ Codeflash Optimization
41+
run: npx codeflash
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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 codeflash npm package dependencies
67+
run: |
68+
cd packages/codeflash
69+
npm install
70+
71+
- name: Install JS test project dependencies
72+
run: |
73+
cd code_to_optimize/js/code_to_optimize_js
74+
npm install
75+
76+
- name: Set up Python 3.11 for CLI
77+
uses: astral-sh/setup-uv@v6
78+
with:
79+
python-version: 3.11.6
80+
81+
- name: Install dependencies (CLI)
82+
run: |
83+
uv sync
84+
85+
- name: Run Codeflash to optimize JS CommonJS function
86+
id: optimize_code
87+
run: |
88+
uv run python tests/scripts/end_to_end_test_js_cjs_function.py
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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 codeflash npm package dependencies
67+
run: |
68+
cd packages/codeflash
69+
npm install
70+
71+
- name: Install JS test project dependencies
72+
run: |
73+
cd code_to_optimize/js/code_to_optimize_js_esm
74+
npm install
75+
76+
- name: Set up Python 3.11 for CLI
77+
uses: astral-sh/setup-uv@v6
78+
with:
79+
python-version: 3.11.6
80+
81+
- name: Install dependencies (CLI)
82+
run: |
83+
uv sync
84+
85+
- name: Run Codeflash to optimize ESM async function
86+
id: optimize_code
87+
run: |
88+
uv run python tests/scripts/end_to_end_test_js_esm_async.py
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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 codeflash npm package dependencies
67+
run: |
68+
cd packages/codeflash
69+
npm install
70+
71+
- name: Install JS test project dependencies
72+
run: |
73+
cd code_to_optimize/js/code_to_optimize_ts
74+
npm install
75+
76+
- name: Set up Python 3.11 for CLI
77+
uses: astral-sh/setup-uv@v6
78+
with:
79+
python-version: 3.11.6
80+
81+
- name: Install dependencies (CLI)
82+
run: |
83+
uv sync
84+
85+
- name: Run Codeflash to optimize TypeScript class method
86+
id: optimize_code
87+
run: |
88+
uv run python tests/scripts/end_to_end_test_js_ts_class.py

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ cython_debug/
163163
#.idea/
164164
.aider*
165165
/js/common/node_modules/
166-
/node_modules/
167166
*.xml
168167
*.pem
169168

@@ -259,6 +258,9 @@ WARP.MD
259258
.mcp.json
260259
.tessl/
261260
tessl.json
261+
**/node_modules/**
262+
**/dist-nuitka/**
263+
**/.npmrc
262264

263265
# Tessl auto-generates AGENTS.md on install; ignore to avoid cluttering git status
264266
AGENTS.md

0 commit comments

Comments
 (0)