ci: add Java CI workflows and optimize workflow template
Add java-e2e-tests.yml, e2e-java-fibonacci-nogit.yaml workflows, codeflash-optimize-java.yaml template, and update unit-tests.yaml to include Java test paths.
This commit is contained in:
parent
031708509c
commit
ece1bc8589
4 changed files with 235 additions and 0 deletions
105
.github/workflows/e2e-java-fibonacci-nogit.yaml
vendored
Normal file
105
.github/workflows/e2e-java-fibonacci-nogit.yaml
vendored
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
name: E2E - Java Fibonacci (No Git)
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- 'codeflash/languages/java/**'
|
||||
- 'codeflash/languages/base.py'
|
||||
- 'codeflash/languages/registry.py'
|
||||
- 'codeflash/optimization/**'
|
||||
- 'codeflash/verification/**'
|
||||
- 'code_to_optimize/java/**'
|
||||
- 'codeflash-java-runtime/**'
|
||||
- 'tests/scripts/end_to_end_test_java_fibonacci.py'
|
||||
- '.github/workflows/e2e-java-fibonacci-nogit.yaml'
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref_name }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
java-fibonacci-optimization-no-git:
|
||||
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' || '' }}
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
CODEFLASH_AIS_SERVER: prod
|
||||
POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
|
||||
CODEFLASH_API_KEY: ${{ secrets.CODEFLASH_API_KEY }}
|
||||
COLUMNS: 110
|
||||
MAX_RETRIES: 3
|
||||
RETRY_DELAY: 5
|
||||
EXPECTED_IMPROVEMENT_PCT: 70
|
||||
CODEFLASH_END_TO_END: 1
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.ref }}
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Validate PR
|
||||
env:
|
||||
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
|
||||
PR_STATE: ${{ github.event.pull_request.state }}
|
||||
BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
||||
run: |
|
||||
if git diff --name-only "$BASE_SHA" "$HEAD_SHA" | grep -q "^.github/workflows/"; then
|
||||
echo "⚠️ Workflow changes detected."
|
||||
echo "PR Author: $PR_AUTHOR"
|
||||
if [[ "$PR_AUTHOR" == "misrasaurabh1" || "$PR_AUTHOR" == "KRRT7" ]]; then
|
||||
echo "✅ Authorized user ($PR_AUTHOR). Proceeding."
|
||||
elif [[ "$PR_STATE" == "open" ]]; then
|
||||
echo "✅ PR is open. Proceeding."
|
||||
else
|
||||
echo "⛔ Unauthorized user ($PR_AUTHOR) attempting to modify workflows. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "✅ No workflow file changes detected. Proceeding."
|
||||
fi
|
||||
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '11'
|
||||
distribution: 'temurin'
|
||||
cache: maven
|
||||
|
||||
- name: Set up Python 3.11 for CLI
|
||||
uses: astral-sh/setup-uv@v6
|
||||
with:
|
||||
python-version: 3.11.6
|
||||
|
||||
- name: Install dependencies (CLI)
|
||||
run: uv sync
|
||||
|
||||
- name: Build codeflash-runtime JAR
|
||||
run: |
|
||||
cd codeflash-java-runtime
|
||||
mvn clean package -q -DskipTests
|
||||
mvn install -q -DskipTests
|
||||
|
||||
- name: Verify Java installation
|
||||
run: |
|
||||
java -version
|
||||
mvn --version
|
||||
|
||||
- name: Remove .git
|
||||
run: |
|
||||
if [ -d ".git" ]; then
|
||||
sudo rm -rf .git
|
||||
echo ".git directory removed."
|
||||
else
|
||||
echo ".git directory does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Run Codeflash to optimize Fibonacci
|
||||
run: |
|
||||
uv run python tests/scripts/end_to_end_test_java_fibonacci.py
|
||||
76
.github/workflows/java-e2e-tests.yml
vendored
Normal file
76
.github/workflows/java-e2e-tests.yml
vendored
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
name: Java E2E Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- omni-java
|
||||
paths:
|
||||
- 'codeflash/languages/java/**'
|
||||
- 'tests/test_languages/test_java*.py'
|
||||
- 'code_to_optimize/java/**'
|
||||
- '.github/workflows/java-e2e-tests.yml'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'codeflash/languages/java/**'
|
||||
- 'tests/test_languages/test_java*.py'
|
||||
- 'code_to_optimize/java/**'
|
||||
- '.github/workflows/java-e2e-tests.yml'
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref_name }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
java-e2e:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '11'
|
||||
distribution: 'temurin'
|
||||
cache: maven
|
||||
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v6
|
||||
|
||||
- name: Set up Python environment
|
||||
run: |
|
||||
uv venv --seed
|
||||
uv sync
|
||||
|
||||
- name: Verify Java installation
|
||||
run: |
|
||||
java -version
|
||||
mvn --version
|
||||
|
||||
- name: Build codeflash-runtime JAR
|
||||
run: |
|
||||
cd codeflash-java-runtime
|
||||
mvn clean package -q -DskipTests
|
||||
mvn install -q -DskipTests
|
||||
|
||||
- name: Build Java sample project
|
||||
run: |
|
||||
cd code_to_optimize/java
|
||||
mvn compile -q
|
||||
|
||||
- name: Run Java sample project tests
|
||||
run: |
|
||||
cd code_to_optimize/java
|
||||
mvn test -q
|
||||
|
||||
- name: Run Java E2E tests
|
||||
run: |
|
||||
uv run pytest tests/test_languages/test_java_e2e.py -v --tb=short
|
||||
|
||||
- name: Run Java unit tests
|
||||
run: |
|
||||
uv run pytest tests/test_languages/test_java/ -v --tb=short -x
|
||||
13
.github/workflows/unit-tests.yaml
vendored
13
.github/workflows/unit-tests.yaml
vendored
|
|
@ -40,6 +40,19 @@ jobs:
|
|||
fetch-depth: 0
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '11'
|
||||
distribution: 'temurin'
|
||||
cache: maven
|
||||
|
||||
- name: Build and install codeflash-runtime JAR
|
||||
run: |
|
||||
cd codeflash-java-runtime
|
||||
mvn clean package -q -DskipTests
|
||||
mvn install -q -DskipTests
|
||||
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v6
|
||||
with:
|
||||
|
|
|
|||
41
codeflash/cli_cmds/workflows/codeflash-optimize-java.yaml
Normal file
41
codeflash/cli_cmds/workflows/codeflash-optimize-java.yaml
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
name: Codeflash
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
# So that this workflow only runs when code within the target module is modified
|
||||
- '{{ codeflash_module_path }}'
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
# Any new push to the PR will cancel the previous run, so that only the latest code is optimized
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
|
||||
jobs:
|
||||
optimize:
|
||||
name: Optimize new code
|
||||
# Don't run codeflash on codeflash-ai[bot] commits, prevent duplicate optimizations
|
||||
if: ${{ github.actor != 'codeflash-ai[bot]' }}
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
CODEFLASH_API_KEY: ${{ secrets.CODEFLASH_API_KEY }}
|
||||
{{ working_directory }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
cache: '{{ java_build_tool }}'
|
||||
- name: Install Dependencies
|
||||
run: {{ install_dependencies_command }}
|
||||
- name: Install Codeflash
|
||||
run: pip install codeflash
|
||||
- name: Codeflash Optimization
|
||||
run: codeflash
|
||||
Loading…
Reference in a new issue