From 920f83cd1a2aa96929d7fe0e2e8f4259a3db7017 Mon Sep 17 00:00:00 2001 From: Linar Abzaltdinov Date: Sat, 7 Jun 2025 22:44:36 +0300 Subject: [PATCH 1/7] =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=81=20=D1=81=D0=B1?= =?UTF-8?q?=D0=BE=D1=80=D0=BA=D0=B8=20=D1=82=D0=B5=D1=81=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Linar Abzaltdinov --- pom.xml | 1 + .../src/main/java/chat/giga/springai/api/chat/GigaChatApi.java | 2 +- .../test/java/chat/giga/springai/api/chat/GigaChatApiIT.java | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 5f56954..26f9a06 100644 --- a/pom.xml +++ b/pom.xml @@ -248,6 +248,7 @@ org.apache.maven.plugins maven-failsafe-plugin + 3.5.3 diff --git a/spring-ai-gigachat/src/main/java/chat/giga/springai/api/chat/GigaChatApi.java b/spring-ai-gigachat/src/main/java/chat/giga/springai/api/chat/GigaChatApi.java index cc30a0e..6ec61eb 100644 --- a/spring-ai-gigachat/src/main/java/chat/giga/springai/api/chat/GigaChatApi.java +++ b/spring-ai-gigachat/src/main/java/chat/giga/springai/api/chat/GigaChatApi.java @@ -184,10 +184,10 @@ public ResponseEntity models() { private Consumer applyHeaders(@Nullable HttpHeaders headers) { return httpHeaders -> { - httpHeaders.add(HttpHeaders.USER_AGENT, USER_AGENT_SPRING_AI_GIGACHAT); if (!CollectionUtils.isEmpty(headers)) { httpHeaders.addAll(headers); } + httpHeaders.set(HttpHeaders.USER_AGENT, USER_AGENT_SPRING_AI_GIGACHAT); }; } } diff --git a/spring-ai-gigachat/src/test/java/chat/giga/springai/api/chat/GigaChatApiIT.java b/spring-ai-gigachat/src/test/java/chat/giga/springai/api/chat/GigaChatApiIT.java index bef58c6..4496bd6 100644 --- a/spring-ai-gigachat/src/test/java/chat/giga/springai/api/chat/GigaChatApiIT.java +++ b/spring-ai-gigachat/src/test/java/chat/giga/springai/api/chat/GigaChatApiIT.java @@ -20,7 +20,7 @@ public class GigaChatApiIT { static { GigaChatApiProperties apiProperties = GigaChatApiProperties.builder() - .scope(GigaChatApiProperties.GigaChatApiScope.valueOf(System.getenv("GIGACHAT_API_SCOPE"))) + .scope(GigaChatApiProperties.GigaChatApiScope.valueOf(System.getenv("GIGACHAT_API_SCOPE").toUpperCase())) .clientId(System.getenv("GIGACHAT_API_CLIENT_ID")) .clientSecret(System.getenv("GIGACHAT_API_CLIENT_SECRET")) .unsafeSsl(true) From 0136fc3821400e4fab8d22a1bfbf2340b3cee428 Mon Sep 17 00:00:00 2001 From: Linar Abzaltdinov Date: Sat, 7 Jun 2025 22:49:20 +0300 Subject: [PATCH 2/7] spotless Signed-off-by: Linar Abzaltdinov --- .../test/java/chat/giga/springai/api/chat/GigaChatApiIT.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-ai-gigachat/src/test/java/chat/giga/springai/api/chat/GigaChatApiIT.java b/spring-ai-gigachat/src/test/java/chat/giga/springai/api/chat/GigaChatApiIT.java index 4496bd6..a938206 100644 --- a/spring-ai-gigachat/src/test/java/chat/giga/springai/api/chat/GigaChatApiIT.java +++ b/spring-ai-gigachat/src/test/java/chat/giga/springai/api/chat/GigaChatApiIT.java @@ -20,7 +20,8 @@ public class GigaChatApiIT { static { GigaChatApiProperties apiProperties = GigaChatApiProperties.builder() - .scope(GigaChatApiProperties.GigaChatApiScope.valueOf(System.getenv("GIGACHAT_API_SCOPE").toUpperCase())) + .scope(GigaChatApiProperties.GigaChatApiScope.valueOf( + System.getenv("GIGACHAT_API_SCOPE").toUpperCase())) .clientId(System.getenv("GIGACHAT_API_CLIENT_ID")) .clientSecret(System.getenv("GIGACHAT_API_CLIENT_SECRET")) .unsafeSsl(true) From b10e590e80b217a506add201cf11dc4ca1279a17 Mon Sep 17 00:00:00 2001 From: Linar Abzaltdinov Date: Sat, 7 Jun 2025 23:09:28 +0300 Subject: [PATCH 3/7] upd test Signed-off-by: Linar Abzaltdinov --- .../test/java/chat/giga/springai/api/chat/GigaChatApiIT.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spring-ai-gigachat/src/test/java/chat/giga/springai/api/chat/GigaChatApiIT.java b/spring-ai-gigachat/src/test/java/chat/giga/springai/api/chat/GigaChatApiIT.java index a938206..1305105 100644 --- a/spring-ai-gigachat/src/test/java/chat/giga/springai/api/chat/GigaChatApiIT.java +++ b/spring-ai-gigachat/src/test/java/chat/giga/springai/api/chat/GigaChatApiIT.java @@ -20,8 +20,7 @@ public class GigaChatApiIT { static { GigaChatApiProperties apiProperties = GigaChatApiProperties.builder() - .scope(GigaChatApiProperties.GigaChatApiScope.valueOf( - System.getenv("GIGACHAT_API_SCOPE").toUpperCase())) + .scope(GigaChatApiProperties.GigaChatApiScope.GIGACHAT_API_CORP) .clientId(System.getenv("GIGACHAT_API_CLIENT_ID")) .clientSecret(System.getenv("GIGACHAT_API_CLIENT_SECRET")) .unsafeSsl(true) From 3cf0b35630d692a81fedd06e09aec1553336d6bd Mon Sep 17 00:00:00 2001 From: Linar Abzaltdinov Date: Sat, 7 Jun 2025 23:23:39 +0300 Subject: [PATCH 4/7] upd dependencies Signed-off-by: Linar Abzaltdinov --- pom.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 26f9a06..ef85a56 100644 --- a/pom.xml +++ b/pom.xml @@ -53,11 +53,11 @@ 17 17 UTF-8 - 2.26.0 - 1.9.22 + 2.29.1 + 1.9.24 3.4.5 1.0.0 - 8.3.5 + 8.3.7 3.1.4 @@ -127,7 +127,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.2.5 + 3.5.3 false @@ -162,7 +162,7 @@ io.qameta.allure allure-maven - 2.12.0 + 2.15.2 ${allure-bom.version} ${project.build.directory}/allure-results @@ -172,7 +172,7 @@ com.diffplug.spotless spotless-maven-plugin - 2.43.0 + 2.44.5 From bae45a037712503f3ea0081c4402e7e888a87e74 Mon Sep 17 00:00:00 2001 From: Linar Abzaltdinov Date: Sat, 7 Jun 2025 23:45:06 +0300 Subject: [PATCH 5/7] upd build Signed-off-by: Linar Abzaltdinov --- .github/workflows/maven-build.yml | 4 ++-- .../test/java/chat/giga/springai/api/chat/GigaChatApiIT.java | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml index 5b7f299..46b5970 100644 --- a/.github/workflows/maven-build.yml +++ b/.github/workflows/maven-build.yml @@ -21,10 +21,10 @@ jobs: distribution: 'temurin' - name: Build with Maven (+ unit tests only) - run: mvn clean test + run: mvn clean test --no-transfer-progress - name: Integration tests - run: mvn verify -P integration-tests + run: mvn verify -P integration-tests --no-transfer-progress env: GIGACHAT_API_CLIENT_ID: ${{ secrets.GIGACHAT_API_CLIENT_ID }} GIGACHAT_API_CLIENT_SECRET: ${{ secrets.GIGACHAT_API_CLIENT_SECRET }} diff --git a/spring-ai-gigachat/src/test/java/chat/giga/springai/api/chat/GigaChatApiIT.java b/spring-ai-gigachat/src/test/java/chat/giga/springai/api/chat/GigaChatApiIT.java index 1305105..b45d223 100644 --- a/spring-ai-gigachat/src/test/java/chat/giga/springai/api/chat/GigaChatApiIT.java +++ b/spring-ai-gigachat/src/test/java/chat/giga/springai/api/chat/GigaChatApiIT.java @@ -25,6 +25,7 @@ public class GigaChatApiIT { .clientSecret(System.getenv("GIGACHAT_API_CLIENT_SECRET")) .unsafeSsl(true) .build(); + log.info("clientId=" + apiProperties.getClientId().length()); gigaChatApi = new GigaChatApi(apiProperties); } From 570374e2921b0d6508bbf232fdaa596cac24022f Mon Sep 17 00:00:00 2001 From: Linar Abzaltdinov Date: Sun, 8 Jun 2025 00:01:32 +0300 Subject: [PATCH 6/7] upd tests Signed-off-by: Linar Abzaltdinov --- pom.xml | 5 +++++ .../test/java/chat/giga/springai/api/chat/GigaChatApiIT.java | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index ef85a56..03e50dc 100644 --- a/pom.xml +++ b/pom.xml @@ -260,6 +260,11 @@ **/*IT.java + + ${env.GIGACHAT_API_SCOPE} + ${env.GIGACHAT_API_CLIENT_ID} + ${env.GIGACHAT_API_CLIENT_SECRET} + diff --git a/spring-ai-gigachat/src/test/java/chat/giga/springai/api/chat/GigaChatApiIT.java b/spring-ai-gigachat/src/test/java/chat/giga/springai/api/chat/GigaChatApiIT.java index b45d223..bef58c6 100644 --- a/spring-ai-gigachat/src/test/java/chat/giga/springai/api/chat/GigaChatApiIT.java +++ b/spring-ai-gigachat/src/test/java/chat/giga/springai/api/chat/GigaChatApiIT.java @@ -20,12 +20,11 @@ public class GigaChatApiIT { static { GigaChatApiProperties apiProperties = GigaChatApiProperties.builder() - .scope(GigaChatApiProperties.GigaChatApiScope.GIGACHAT_API_CORP) + .scope(GigaChatApiProperties.GigaChatApiScope.valueOf(System.getenv("GIGACHAT_API_SCOPE"))) .clientId(System.getenv("GIGACHAT_API_CLIENT_ID")) .clientSecret(System.getenv("GIGACHAT_API_CLIENT_SECRET")) .unsafeSsl(true) .build(); - log.info("clientId=" + apiProperties.getClientId().length()); gigaChatApi = new GigaChatApi(apiProperties); } From a9d3c0ad4430da651861ad5fd3a59ba754cb84e5 Mon Sep 17 00:00:00 2001 From: Linar Abzaltdinov Date: Sun, 8 Jun 2025 00:52:06 +0300 Subject: [PATCH 7/7] upd build and tests Signed-off-by: Linar Abzaltdinov --- .github/workflows/maven-build.yml | 9 +----- .github/workflows/maven-integration-tests.yml | 32 +++++++++++++++++++ pom.xml | 25 +++++++++++---- spring-ai-gigachat-example/pom.xml | 16 ++++++++++ .../api/auth/GigaChatApiProperties.java | 2 ++ 5 files changed, 69 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/maven-integration-tests.yml diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml index 46b5970..b7fe4a1 100644 --- a/.github/workflows/maven-build.yml +++ b/.github/workflows/maven-build.yml @@ -20,12 +20,5 @@ jobs: java-version: '17' distribution: 'temurin' - - name: Build with Maven (+ unit tests only) + - name: Build with Maven (unit tests only) run: mvn clean test --no-transfer-progress - - - name: Integration tests - run: mvn verify -P integration-tests --no-transfer-progress - env: - GIGACHAT_API_CLIENT_ID: ${{ secrets.GIGACHAT_API_CLIENT_ID }} - GIGACHAT_API_CLIENT_SECRET: ${{ secrets.GIGACHAT_API_CLIENT_SECRET }} - GIGACHAT_API_SCOPE: ${{ secrets.GIGACHAT_API_SCOPE }} diff --git a/.github/workflows/maven-integration-tests.yml b/.github/workflows/maven-integration-tests.yml new file mode 100644 index 0000000..38e1c63 --- /dev/null +++ b/.github/workflows/maven-integration-tests.yml @@ -0,0 +1,32 @@ +name: PR Merged build (with integration tests) + +on: + pull_request: + branches: + - main + - release/* + types: [closed] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + - name: Build with Maven (unit tests) + run: mvn clean test --no-transfer-progress + + - name: Integration tests + run: mvn verify -P integration-tests --no-transfer-progress + env: + GIGACHAT_API_CLIENT_ID: ${{ secrets.GIGACHAT_API_CLIENT_ID }} + GIGACHAT_API_CLIENT_SECRET: ${{ secrets.GIGACHAT_API_CLIENT_SECRET }} + GIGACHAT_API_SCOPE: ${{ secrets.GIGACHAT_API_SCOPE }} diff --git a/pom.xml b/pom.xml index 03e50dc..dce10c6 100644 --- a/pom.xml +++ b/pom.xml @@ -50,14 +50,14 @@ 17 - 17 - 17 + 17 UTF-8 2.29.1 1.9.24 3.4.5 1.0.0 8.3.7 + 1.18.38 3.1.4 @@ -124,6 +124,22 @@ ${project.artifactId} + + org.apache.maven.plugins + maven-compiler-plugin + 3.14.0 + + + + org.projectlombok + lombok + ${lombok.version} + + + ${maven.compiler.release} + + + org.apache.maven.plugins maven-surefire-plugin @@ -260,11 +276,6 @@ **/*IT.java - - ${env.GIGACHAT_API_SCOPE} - ${env.GIGACHAT_API_CLIENT_ID} - ${env.GIGACHAT_API_CLIENT_SECRET} - diff --git a/spring-ai-gigachat-example/pom.xml b/spring-ai-gigachat-example/pom.xml index 96752b1..cc1b80c 100644 --- a/spring-ai-gigachat-example/pom.xml +++ b/spring-ai-gigachat-example/pom.xml @@ -85,6 +85,22 @@ + + org.apache.maven.plugins + maven-compiler-plugin + 3.14.0 + + + + org.projectlombok + lombok + ${lombok.version} + + + ${java.version} + + + org.apache.maven.plugins maven-install-plugin diff --git a/spring-ai-gigachat/src/main/java/chat/giga/springai/api/auth/GigaChatApiProperties.java b/spring-ai-gigachat/src/main/java/chat/giga/springai/api/auth/GigaChatApiProperties.java index 4683e4b..51b563c 100644 --- a/spring-ai-gigachat/src/main/java/chat/giga/springai/api/auth/GigaChatApiProperties.java +++ b/spring-ai-gigachat/src/main/java/chat/giga/springai/api/auth/GigaChatApiProperties.java @@ -25,6 +25,8 @@ public class GigaChatApiProperties { private Resource clientCertificate; private Resource clientKey; + + @Builder.Default private boolean unsafeSsl = false; public enum GigaChatApiScope {