Skip to content

Commit 7b839a6

Browse files
Merge branch 'main' into grounding
2 parents ecfb112 + 7efcc38 commit 7b839a6

File tree

6 files changed

+77
-49
lines changed

6 files changed

+77
-49
lines changed

.github/workflows/continuous-integration.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
6868
- name: "Run Unit Tests"
6969
run: |
70-
MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} org.jacoco:jacoco-maven-plugin:prepare-agent surefire:test org.jacoco:jacoco-maven-plugin:report"
70+
MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} org.jacoco:jacoco-maven-plugin:prepare-agent surefire:test org.jacoco:jacoco-maven-plugin:report org.jacoco:jacoco-maven-plugin:check@default-check"
7171
mvn $MVN_ARGS
7272
7373
- name: "Slack Notification"

.github/workflows/spec-update.yaml

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
outputs:
3838
spec_diff: ${{ steps.spec_diff.outputs.spec_diff }}
3939
branch: ${{ steps.push.outputs.branch }}
40+
pr_url: ${{ steps.create-pr.outputs.pr_url }}
4041
compilation_result: ${{ steps.compile.outputs.compilation_result }}
4142
test_result: ${{ steps.compile.outputs.test_result }}
4243
env:
@@ -50,6 +51,15 @@ jobs:
5051
with:
5152
token: ${{ secrets.BOT_SDK_JS_FOR_DOCS_REPO_PR }}
5253

54+
- name: "Checkout or Create Branch"
55+
id: branch
56+
# Checkout branch if it exists, otherwise create it
57+
run: |
58+
BRANCH="spec-update/$CHOICE/$REF"
59+
git fetch origin $BRANCH || true
60+
git checkout -B $BRANCH origin/$BRANCH || git checkout -b $BRANCH
61+
echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"
62+
5363
- name: "Download specification file"
5464
id: download
5565
env:
@@ -83,27 +93,6 @@ jobs:
8393
echo "spec_diff=false" >> "$GITHUB_OUTPUT"
8494
fi
8595
86-
- name: "Checkout or Create Branch"
87-
# Always create a new branch to ensure we generate from a clean state.
88-
# In case a PR exist we can't delete and re-create the branch (without closing the PR first).
89-
# So the workflow will exist in this case.
90-
id: branch
91-
env:
92-
GH_TOKEN: ${{ secrets.BOT_SDK_JS_FOR_DOCS_REPO_PR }}
93-
run: |
94-
BRANCH="spec-update/$CHOICE/$REF"
95-
if gh pr list --head $BRANCH --json number -q '.[].number' | grep -q .; then
96-
echo "An open PR already exists for this branch. Please close the PR first before re-running the workflow."
97-
exit 1
98-
fi
99-
100-
if git ls-remote --exit-code origin refs/heads/$BRANCH >/dev/null 2>&1; then
101-
echo "Branch '$BRANCH' exists on remote, deleting it..."
102-
git push origin --delete $BRANCH
103-
fi
104-
git checkout -b $BRANCH
105-
echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"
106-
10796
- name: "Setup java"
10897
uses: actions/setup-java@v4
10998
if: steps.spec_diff.outputs.spec_diff == 'true'
@@ -133,6 +122,7 @@ jobs:
133122
fi
134123
else
135124
echo "compilation_result=failure" >> "$GITHUB_OUTPUT"
125+
echo "test_result=skipped" >> "$GITHUB_OUTPUT"
136126
fi
137127
138128
- name: "Push changes"
@@ -141,40 +131,60 @@ jobs:
141131
run: |
142132
git config --global user.email "[email protected]"
143133
git config --global user.name "SAP Cloud SDK Bot"
144-
git add .
134+
git add --all
135+
git status
145136
git commit -m "Update $CHOICE based on $REF"
146137
git push --set-upstream origin ${{ steps.branch.outputs.branch }}
147138
148139
- name: "Create PR"
149-
if: ${{ env.CREATE_PR && steps.spec_diff.outputs.spec_diff == 'true'}}
140+
id: create-pr
141+
if: ${{ env.CREATE_PR == 'true' && steps.spec_diff.outputs.spec_diff == 'true'}}
150142
env:
151143
GH_TOKEN: ${{ secrets.BOT_SDK_JS_FOR_DOCS_REPO_PR }}
144+
BRANCH: ${{ steps.branch.outputs.branch }}
152145
run: |
153-
gh pr create --base main --head ${{ steps.branch.outputs.branch }} --title "feat: [DevOps] Update $CHOICE Specification" --body "
146+
if gh pr list --head $BRANCH --json number -q '.[].number' | grep -q .; then
147+
echo "An open PR already exists for this branch. Skipping PR creation."
148+
exit 0
149+
fi
150+
151+
PR_URL=$(gh pr create --base main --head $BRANCH --title "feat: [DevOps] Update $CHOICE specification" --body "
154152
## Context
155153
156154
Update $CHOICE specification file based on $REF.
157155
158156
This PR was created automatically by the [spec-update workflow](https://github.com/SAP/ai-sdk-java/actions/workflows/spec-update.yaml).
159157
You can commit on top of this branch, but as long as this PR is open the action can't be re-run.
160158
161-
- Compilation outcome: ${{ steps.compile.output.test_result }}
162-
- Test run outcome: ${{ steps.compile.output.test_result }}
159+
- Compilation outcome: ${{ steps.compile.outputs.compilation_result }}
160+
- Test run outcome: ${{ steps.compile.outputs.test_result }}
163161
164162
Before merging, make sure to update tests and release notes, if necessary.
165163
166164
## Definition of Done
167165
168166
- [ ] Unit tests cover new classes
169167
- [ ] Release notes updated
170-
"
168+
") && echo "pr_url=$PR_URL" >> "$GITHUB_OUTPUT"
171169
172-
- name: "Print Summary"
170+
- name: Generate Job Summary
173171
if: ${{ always() }}
172+
env:
173+
BRANCH: ${{ steps.branch.outputs.branch }}
174+
PR_URL: ${{ steps.create-pr.outputs.pr_url }}
174175
run: |
175-
echo "Branch creation: ${{ steps.branch.outcome }}"
176-
echo "File download outcome: ${{ steps.download.outcome }}"
177-
echo "Spec file contained changes: ${{ steps.spec_diff.outputs.spec_diff }}"
178-
echo "Client generation outcome: ${{ steps.generate.outcome }}"
179-
echo "Client compilation outcome: ${{ steps.compile.output.compilation_result }}"
180-
echo "Client test outcome: ${{ steps.compile.output.test_result }}"
176+
DIFF_URL="https://github.com/SAP/ai-sdk-java/compare/main...$BRANCH"
177+
echo "## Workflow Execution Summary" >> $GITHUB_STEP_SUMMARY
178+
echo "" >> $GITHUB_STEP_SUMMARY
179+
echo "| Step | Status |" >> $GITHUB_STEP_SUMMARY
180+
echo "|------|--------|" >> $GITHUB_STEP_SUMMARY
181+
echo "| File Download | ${{ steps.download.outcome == 'success' && '✅' || '❌' }} ${{ steps.download.outcome }}" >> $GITHUB_STEP_SUMMARY
182+
echo "| Spec File Changes | ${{ steps.spec_diff.outputs.spec_diff == 'true' && '🔄 Changes Detected' || '⏹️ No Changes' }}" >> $GITHUB_STEP_SUMMARY
183+
184+
if ${{ steps.spec_diff.outputs.spec_diff == 'true' }}; then
185+
echo "| Client Generation | ${{ steps.generate.outcome == 'success' && '✅' || '❌' }} ${{ steps.generate.outcome }}" >> $GITHUB_STEP_SUMMARY
186+
echo "| Client Compilation | ${{ steps.compile.outputs.compilation_result == 'success' && '✅' || '❌' }} ${{ steps.compile.outputs.compilation_result }}" >> $GITHUB_STEP_SUMMARY
187+
echo "| Client Testing | ${{ steps.compile.outputs.test_result == 'success' && '✅' || steps.compile.outputs.test_result == 'skipped' && '⏩' || '❌' }} ${{ steps.compile.outputs.test_result }}" >> $GITHUB_STEP_SUMMARY
188+
echo "| Branch Creation | ${{ steps.push.outcome == 'success' && '✅ [Branch Link]($DIFF_URL)' || '❌ failure' }}" >> $GITHUB_STEP_SUMMARY
189+
echo "| Pull Request Creation | ${{ env.CREATE_PR == 'false' && '⏩ skipped' || '' }}${{ env.CREATE_PR == 'true' && steps.push.outcome == 'success' && '✅ [PR Link]($PR_URL)' || '' }}" >> $GITHUB_STEP_SUMMARY
190+
fi

core/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
</developers>
3131
<properties>
3232
<project.rootdir>${project.basedir}/../</project.rootdir>
33-
<coverage.complexity>62%</coverage.complexity>
34-
<coverage.line>76%</coverage.line>
35-
<coverage.instruction>76%</coverage.instruction>
33+
<coverage.complexity>64%</coverage.complexity>
34+
<coverage.line>78%</coverage.line>
35+
<coverage.instruction>79%</coverage.instruction>
3636
<coverage.branch>60%</coverage.branch>
37-
<coverage.method>74%</coverage.method>
37+
<coverage.method>77%</coverage.method>
3838
<coverage.class>90%</coverage.class>
3939
</properties>
4040

core/src/test/java/com/sap/ai/sdk/core/AiCoreServiceTest.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
package com.sap.ai.sdk.core;
22

3+
import static com.github.tomakehurst.wiremock.client.WireMock.get;
4+
import static com.github.tomakehurst.wiremock.client.WireMock.okJson;
5+
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
6+
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
37
import static org.assertj.core.api.Assertions.assertThat;
48
import static org.assertj.core.api.Assertions.assertThatCode;
59
import static org.assertj.core.api.Assertions.assertThatThrownBy;
610

11+
import com.github.tomakehurst.wiremock.WireMockServer;
712
import com.sap.cloud.sdk.cloudplatform.connectivity.DefaultHttpDestination;
813
import com.sap.cloud.sdk.cloudplatform.connectivity.Header;
914
import com.sap.cloud.sdk.cloudplatform.connectivity.HttpDestination;
@@ -63,17 +68,30 @@ void testCustomBaseDestination() {
6368

6469
@Test
6570
void testGetInferenceDestination() {
66-
var builder = service.getInferenceDestination();
71+
// default resource group destination
72+
val builder = service.getInferenceDestination();
6773
assertThatThrownBy(() -> builder.forScenario("doesn't exist"))
6874
.isExactlyInstanceOf(DeploymentResolutionException.class);
6975

76+
// custom resource group destination
7077
val destination = service.getInferenceDestination("foo").usingDeploymentId("123");
71-
7278
assertThat(destination.getUri())
7379
.hasHost("api.ai.com")
7480
.hasPath("/v2/inference/deployments/123/");
75-
7681
assertThat(destination.getHeaders()).containsExactly(new Header("AI-Resource-Group", "foo"));
82+
83+
// scenario-based destination
84+
val d = "{\"count\":1,\"resources\":[{\"id\":\"0123456789abcdef\",\"scenarioId\":\"foobar\"}]}";
85+
val server = new WireMockServer(wireMockConfig().dynamicPort());
86+
server.start();
87+
server.stubFor(get(urlEqualTo("/v2/lm/deployments")).willReturn(okJson(d)));
88+
HttpDestination foobar =
89+
service
90+
.withBaseDestination(DefaultHttpDestination.builder(server.baseUrl() + "/v2/").build())
91+
.getInferenceDestination()
92+
.forScenario("foobar");
93+
assertThat(foobar.getUri()).hasPath("/v2/inference/deployments/0123456789abcdef/");
94+
server.stop();
7795
}
7896

7997
@Test

foundation-models/openai/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
</developers>
3434
<properties>
3535
<project.rootdir>${project.basedir}/../../</project.rootdir>
36-
<coverage.complexity>71%</coverage.complexity>
36+
<coverage.complexity>72%</coverage.complexity>
3737
<coverage.line>80%</coverage.line>
3838
<coverage.instruction>76%</coverage.instruction>
39-
<coverage.branch>69%</coverage.branch>
39+
<coverage.branch>70%</coverage.branch>
4040
<coverage.method>83%</coverage.method>
4141
<coverage.class>84%</coverage.class>
4242
</properties>

orchestration/pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
</developers>
3232
<properties>
3333
<project.rootdir>${project.basedir}/../</project.rootdir>
34-
<coverage.complexity>76%</coverage.complexity>
35-
<coverage.line>90%</coverage.line>
36-
<coverage.instruction>91%</coverage.instruction>
37-
<coverage.branch>69%</coverage.branch>
38-
<coverage.method>70%</coverage.method>
34+
<coverage.complexity>77%</coverage.complexity>
35+
<coverage.line>92%</coverage.line>
36+
<coverage.instruction>92%</coverage.instruction>
37+
<coverage.branch>70%</coverage.branch>
38+
<coverage.method>92%</coverage.method>
3939
<coverage.class>100%</coverage.class>
4040
</properties>
4141

0 commit comments

Comments
 (0)