Skip to content

Commit a4473c3

Browse files
merge: resolve conflict with main — adapt exit-code handling to combined invocation
Keep the combined JFR + tracing agent single JVM invocation from main while preserving the fix's intent: raise when trace-db was not created, warn when exit code is non-zero but trace-db exists. Integration tests rewritten to match the combined-invocation semantics.
2 parents 470482e + d8b6236 commit a4473c3

30 files changed

Lines changed: 531 additions & 208 deletions

tests/benchmarks/test_benchmark_code_extract_code_context.py renamed to .codeflash/benchmarks/test_benchmark_code_extract_code_context.py

File renamed without changes.
File renamed without changes.

tests/benchmarks/test_benchmark_discover_unit_tests.py renamed to .codeflash/benchmarks/test_benchmark_discover_unit_tests.py

File renamed without changes.

tests/benchmarks/test_benchmark_libcst_multi_file.py renamed to .codeflash/benchmarks/test_benchmark_libcst_multi_file.py

File renamed without changes.
File renamed without changes.

tests/benchmarks/test_benchmark_merge_test_results.py renamed to .codeflash/benchmarks/test_benchmark_merge_test_results.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from codeflash.verification.parse_test_output import merge_test_results
33

44

5-
def generate_test_invocations(count=100):
5+
def generate_test_invocations(count: int = 100) -> tuple[TestResults, TestResults]:
66
"""Generate a set number of test invocations for benchmarking."""
77
test_results_xml = TestResults()
88
test_results_bin = TestResults()
@@ -21,7 +21,7 @@ def generate_test_invocations(count=100):
2121
function_getting_tested="sorter",
2222
iteration_id=iteration_id,
2323
),
24-
file_name="/tmp/tests/unittest/test_bubble_sort__perfinstrumented.py",
24+
file_name="/tmp/tests/unittest/test_bubble_sort__perfinstrumented.py", # noqa: S108
2525
did_pass=True,
2626
runtime=None if i % 3 == 0 else i * 100, # Vary runtime values
2727
test_framework="unittest",
@@ -42,7 +42,7 @@ def generate_test_invocations(count=100):
4242
function_getting_tested="sorter",
4343
iteration_id=iteration_id,
4444
),
45-
file_name="/tmp/tests/unittest/test_bubble_sort__perfinstrumented.py",
45+
file_name="/tmp/tests/unittest/test_bubble_sort__perfinstrumented.py", # noqa: S108
4646
did_pass=True,
4747
runtime=500 + i * 20, # Generate varying runtime values
4848
test_framework="unittest",
@@ -56,12 +56,12 @@ def generate_test_invocations(count=100):
5656
return test_results_xml, test_results_bin
5757

5858

59-
def run_merge_benchmark(count=100):
59+
def run_merge_benchmark(count: int = 100) -> None:
6060
test_results_xml, test_results_bin = generate_test_invocations(count)
6161

6262
# Perform the merge operation that will be benchmarked
6363
merge_test_results(xml_test_results=test_results_xml, bin_test_results=test_results_bin, test_framework="unittest")
6464

6565

66-
def test_benchmark_merge_test_results(benchmark):
66+
def test_benchmark_merge_test_results(benchmark) -> None:
6767
benchmark(run_merge_benchmark, 1000) # Default to 100 test invocations

.github/workflows/ci.yaml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ jobs:
9595
'codeflash/languages/java/' 'codeflash/languages/base.py' \
9696
'codeflash/languages/registry.py' 'codeflash/optimization/' \
9797
'codeflash/verification/' 'codeflash-java-runtime/' \
98-
'code_to_optimize/java/' 'tests/scripts/end_to_end_test_java*'
98+
'code_to_optimize/java/' 'tests/scripts/end_to_end_test_java*' \
99+
'tests/test_languages/fixtures/java_tracer_e2e/'
99100
env:
100101
MERGE_BASE: ${{ steps.merge_base.outputs.sha }}
101102

@@ -257,7 +258,7 @@ jobs:
257258
- name: init-optimization
258259
script: end_to_end_test_init_optimization.py
259260
expected_improvement: 10
260-
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' || '' }}
261+
environment: ${{ ((github.event_name == 'workflow_dispatch' && github.actor != 'misrasaurabh1' && github.actor != 'KRRT7') || (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' || '' }}
261262
runs-on: ubuntu-latest
262263
env:
263264
CODEFLASH_AIS_SERVER: prod
@@ -344,7 +345,7 @@ jobs:
344345
script: end_to_end_test_js_ts_class.py
345346
js_project_dir: code_to_optimize/js/code_to_optimize_ts
346347
expected_improvement: 30
347-
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' || '' }}
348+
environment: ${{ ((github.event_name == 'workflow_dispatch' && github.actor != 'misrasaurabh1' && github.actor != 'KRRT7') || (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' || '' }}
348349
runs-on: ubuntu-latest
349350
env:
350351
CODEFLASH_AIS_SERVER: prod
@@ -424,7 +425,7 @@ jobs:
424425
script: end_to_end_test_java_void_optimization.py
425426
expected_improvement: 70
426427
remove_git: true
427-
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' || '' }}
428+
environment: ${{ ((github.event_name == 'workflow_dispatch' && github.actor != 'misrasaurabh1' && github.actor != 'KRRT7') || (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' || '' }}
428429
runs-on: ubuntu-latest
429430
env:
430431
CODEFLASH_AIS_SERVER: prod
@@ -435,6 +436,7 @@ jobs:
435436
RETRY_DELAY: 5
436437
EXPECTED_IMPROVEMENT_PCT: ${{ matrix.expected_improvement }}
437438
CODEFLASH_END_TO_END: 1
439+
CODEFLASH_LOOPING_TIME: 5
438440
steps:
439441
- uses: actions/checkout@v6
440442
with:
@@ -468,7 +470,15 @@ jobs:
468470
- name: Install dependencies
469471
run: uv sync
470472

473+
- name: Cache codeflash-runtime JAR
474+
id: runtime-jar-cache
475+
uses: actions/cache@v4
476+
with:
477+
path: ~/.m2/repository/io/codeflash
478+
key: codeflash-runtime-${{ hashFiles('codeflash-java-runtime/pom.xml', 'codeflash-java-runtime/src/**') }}
479+
471480
- name: Build and install codeflash-runtime JAR
481+
if: steps.runtime-jar-cache.outputs.cache-hit != 'true'
472482
run: |
473483
cd codeflash-java-runtime
474484
mvn install -q -DskipTests

.github/workflows/codeflash-optimize.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ jobs:
4343
- name: ⚡️Codeflash Optimization
4444
id: optimize_code
4545
run: |
46-
uv run codeflash --benchmark --testgen-review
46+
uv run codeflash --benchmark --testgen-review --no-pr

.github/workflows/java-e2e.yaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Java E2E Tests
2+
on:
3+
workflow_dispatch:
4+
5+
jobs:
6+
e2e-java:
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
include:
11+
- name: java-fibonacci-nogit
12+
script: end_to_end_test_java_fibonacci.py
13+
expected_improvement: 70
14+
remove_git: true
15+
- name: java-tracer
16+
script: end_to_end_test_java_tracer.py
17+
expected_improvement: 10
18+
- name: java-void-optimization-nogit
19+
script: end_to_end_test_java_void_optimization.py
20+
expected_improvement: 70
21+
remove_git: true
22+
runs-on: ubuntu-latest
23+
env:
24+
CODEFLASH_AIS_SERVER: prod
25+
POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
26+
CODEFLASH_API_KEY: ${{ secrets.CODEFLASH_API_KEY }}
27+
COLUMNS: 110
28+
MAX_RETRIES: 3
29+
RETRY_DELAY: 5
30+
EXPECTED_IMPROVEMENT_PCT: ${{ matrix.expected_improvement }}
31+
CODEFLASH_END_TO_END: 1
32+
CODEFLASH_LOOPING_TIME: 5
33+
steps:
34+
- uses: actions/checkout@v6
35+
36+
- name: Set up JDK 11
37+
uses: actions/setup-java@v5
38+
with:
39+
java-version: '11'
40+
distribution: 'temurin'
41+
cache: maven
42+
43+
- name: Install uv
44+
uses: astral-sh/setup-uv@v8.0.0
45+
with:
46+
python-version: 3.11.6
47+
enable-cache: true
48+
49+
- name: Install dependencies
50+
run: uv sync
51+
52+
- name: Cache codeflash-runtime JAR
53+
id: runtime-jar-cache
54+
uses: actions/cache@v4
55+
with:
56+
path: ~/.m2/repository/io/codeflash
57+
key: codeflash-runtime-${{ hashFiles('codeflash-java-runtime/pom.xml', 'codeflash-java-runtime/src/**') }}
58+
59+
- name: Build and install codeflash-runtime JAR
60+
if: steps.runtime-jar-cache.outputs.cache-hit != 'true'
61+
run: |
62+
cd codeflash-java-runtime
63+
mvn install -q -DskipTests
64+
65+
- name: Remove .git
66+
if: matrix.remove_git
67+
run: |
68+
if [ -d ".git" ]; then
69+
sudo rm -rf .git
70+
echo ".git directory removed."
71+
else
72+
echo ".git directory does not exist."
73+
exit 1
74+
fi
75+
76+
- name: Run E2E test
77+
run: uv run python tests/scripts/${{ matrix.script }}

0 commit comments

Comments
 (0)