Skip to content

Commit 131597c

Browse files
fix: add API key for tests and build codeflash-runtime JAR in CI
- Add CODEFLASH_API_KEY for test_instrumentation.py tests that instantiate Optimizer - Create pom.xml for codeflash-java-runtime with Gson and SQLite JDBC dependencies - Add CI step to build and install JAR before running tests - Update .gitignore to allow pom.xml in codeflash-java-runtime - All 348 Java tests now pass including 5 Comparator JAR integration tests
1 parent eb3d51a commit 131597c

4 files changed

Lines changed: 117 additions & 0 deletions

File tree

.github/workflows/java-e2e-tests.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ jobs:
5151
java -version
5252
mvn --version
5353
54+
- name: Build codeflash-runtime JAR
55+
run: |
56+
cd codeflash-java-runtime
57+
mvn clean package -q -DskipTests
58+
mvn install -q -DskipTests
59+
5460
- name: Build Java sample project
5561
run: |
5662
cd code_to_optimize/java

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ cython_debug/
168168
!tests/test_languages/fixtures/**/pom.xml
169169
# Allow pom.xml in Java sample project
170170
!code_to_optimize/java/pom.xml
171+
# Allow pom.xml in codeflash-java-runtime
172+
!codeflash-java-runtime/pom.xml
171173
*.pem
172174

173175
# Ruff cache

codeflash-java-runtime/pom.xml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
5+
http://maven.apache.org/xsd/maven-4.0.0.xsd">
6+
<modelVersion>4.0.0</modelVersion>
7+
8+
<groupId>com.codeflash</groupId>
9+
<artifactId>codeflash-runtime</artifactId>
10+
<version>1.0.0</version>
11+
<packaging>jar</packaging>
12+
13+
<name>CodeFlash Java Runtime</name>
14+
<description>Runtime library for CodeFlash Java instrumentation and comparison</description>
15+
16+
<properties>
17+
<maven.compiler.source>11</maven.compiler.source>
18+
<maven.compiler.target>11</maven.compiler.target>
19+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
20+
</properties>
21+
22+
<dependencies>
23+
<!-- Gson for JSON serialization -->
24+
<dependency>
25+
<groupId>com.google.code.gson</groupId>
26+
<artifactId>gson</artifactId>
27+
<version>2.10.1</version>
28+
</dependency>
29+
30+
<!-- SQLite JDBC driver -->
31+
<dependency>
32+
<groupId>org.xerial</groupId>
33+
<artifactId>sqlite-jdbc</artifactId>
34+
<version>3.45.0.0</version>
35+
</dependency>
36+
37+
<!-- JUnit 5 for testing -->
38+
<dependency>
39+
<groupId>org.junit.jupiter</groupId>
40+
<artifactId>junit-jupiter</artifactId>
41+
<version>5.10.1</version>
42+
<scope>test</scope>
43+
</dependency>
44+
</dependencies>
45+
46+
<build>
47+
<plugins>
48+
<!-- Compiler plugin -->
49+
<plugin>
50+
<groupId>org.apache.maven.plugins</groupId>
51+
<artifactId>maven-compiler-plugin</artifactId>
52+
<version>3.11.0</version>
53+
<configuration>
54+
<source>11</source>
55+
<target>11</target>
56+
</configuration>
57+
</plugin>
58+
59+
<!-- Surefire plugin for tests -->
60+
<plugin>
61+
<groupId>org.apache.maven.plugins</groupId>
62+
<artifactId>maven-surefire-plugin</artifactId>
63+
<version>3.0.0</version>
64+
</plugin>
65+
66+
<!-- Create JAR with dependencies -->
67+
<plugin>
68+
<groupId>org.apache.maven.plugins</groupId>
69+
<artifactId>maven-shade-plugin</artifactId>
70+
<version>3.5.1</version>
71+
<executions>
72+
<execution>
73+
<phase>package</phase>
74+
<goals>
75+
<goal>shade</goal>
76+
</goals>
77+
<configuration>
78+
<transformers>
79+
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
80+
<mainClass>com.codeflash.Comparator</mainClass>
81+
</transformer>
82+
</transformers>
83+
<filters>
84+
<filter>
85+
<artifact>*:*</artifact>
86+
<excludes>
87+
<exclude>META-INF/*.SF</exclude>
88+
<exclude>META-INF/*.DSA</exclude>
89+
<exclude>META-INF/*.RSA</exclude>
90+
</excludes>
91+
</filter>
92+
</filters>
93+
</configuration>
94+
</execution>
95+
</executions>
96+
</plugin>
97+
98+
<!-- Install to local Maven repository -->
99+
<plugin>
100+
<groupId>org.apache.maven.plugins</groupId>
101+
<artifactId>maven-install-plugin</artifactId>
102+
<version>3.1.1</version>
103+
</plugin>
104+
</plugins>
105+
</build>
106+
</project>

tests/test_languages/test_java/test_instrumentation.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
import pytest
2020

21+
# Set API key for tests that instantiate Optimizer
22+
os.environ["CODEFLASH_API_KEY"] = "cf-test-key"
23+
2124
from codeflash.languages.base import FunctionInfo, Language
2225
from codeflash.languages.current import set_current_language
2326
from codeflash.languages.java.build_tools import find_maven_executable

0 commit comments

Comments
 (0)