Skip to content

Commit 2228057

Browse files
authored
Merge pull request #1778 from codeflash-ai/fix/github_actions_init
[Fix] Github Actions init
2 parents 5f3480e + 1230675 commit 2228057

4 files changed

Lines changed: 15 additions & 39 deletions

File tree

codeflash/cli_cmds/init_javascript.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -690,22 +690,9 @@ def get_js_codeflash_install_step(pkg_manager: JsPackageManager, *, is_dependenc
690690
# Codeflash will be installed with other dependencies
691691
return ""
692692

693-
# Need to install codeflash separately
694-
if pkg_manager == JsPackageManager.BUN:
695-
return """- name: 📥 Install Codeflash
696-
run: bun add -g codeflash"""
697-
698-
if pkg_manager == JsPackageManager.PNPM:
699-
return """- name: 📥 Install Codeflash
700-
run: pnpm add -g codeflash"""
701-
702-
if pkg_manager == JsPackageManager.YARN:
703-
return """- name: 📥 Install Codeflash
704-
run: yarn global add codeflash"""
705-
706-
# NPM or UNKNOWN
693+
# Install codeflash via uv (Python + uv are set up in the workflow)
707694
return """- name: 📥 Install Codeflash
708-
run: npm install -g codeflash"""
695+
run: uv tool install codeflash"""
709696

710697

711698
def get_js_codeflash_run_command(pkg_manager: JsPackageManager, *, is_dependency: bool) -> str:

codeflash/cli_cmds/workflows/codeflash-optimize-js.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ jobs:
2727
uses: actions/checkout@v4
2828
with:
2929
fetch-depth: 0
30+
- name: 🐍 Setup Python
31+
uses: actions/setup-python@v5
32+
with:
33+
python-version: '3.12'
34+
- name: 📦 Setup uv
35+
uses: astral-sh/setup-uv@v4
3036
{{ setup_runtime_steps }}
3137
- name: 📦 Install Dependencies
3238
run: {{ install_dependencies_command }}

codeflash/cli_cmds/workflows/codeflash-optimize.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
uses: actions/checkout@v4
2828
with:
2929
fetch-depth: 0
30-
- {{ setup_python_dependency_manager }}
30+
- {{ setup_runtime_environment }}
3131
- name: 📦 Install Dependencies
3232
run: {{ install_dependencies_command }}
3333
- name: ⚡️Codeflash Optimization

tests/code_utils/test_js_workflow_helpers.py

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -131,30 +131,13 @@ def test_returns_empty_when_is_dependency(self) -> None:
131131

132132
assert result == ""
133133

134-
def test_npm_global_install(self) -> None:
135-
"""Should generate npm global install when not a dependency."""
136-
result = get_js_codeflash_install_step(JsPackageManager.NPM, is_dependency=False)
134+
def test_uv_tool_install_when_not_dependency(self) -> None:
135+
"""Should generate uv tool install when not a dependency, regardless of package manager."""
136+
for pkg_manager in (JsPackageManager.NPM, JsPackageManager.YARN, JsPackageManager.PNPM, JsPackageManager.BUN):
137+
result = get_js_codeflash_install_step(pkg_manager, is_dependency=False)
137138

138-
assert "Install Codeflash" in result
139-
assert "npm install -g codeflash" in result
140-
141-
def test_yarn_global_install(self) -> None:
142-
"""Should generate yarn global install when not a dependency."""
143-
result = get_js_codeflash_install_step(JsPackageManager.YARN, is_dependency=False)
144-
145-
assert "yarn global add codeflash" in result
146-
147-
def test_pnpm_global_install(self) -> None:
148-
"""Should generate pnpm global install when not a dependency."""
149-
result = get_js_codeflash_install_step(JsPackageManager.PNPM, is_dependency=False)
150-
151-
assert "pnpm add -g codeflash" in result
152-
153-
def test_bun_global_install(self) -> None:
154-
"""Should generate bun global install when not a dependency."""
155-
result = get_js_codeflash_install_step(JsPackageManager.BUN, is_dependency=False)
156-
157-
assert "bun add -g codeflash" in result
139+
assert "Install Codeflash" in result
140+
assert "uv tool install codeflash" in result
158141

159142

160143
class TestGetJsCodeflashRunCommand:

0 commit comments

Comments
 (0)