Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inject autoconfiguration in the Spring Boot 3 style #831

Merged
merged 4 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,28 @@ on:

jobs:
build:
name: "Build jdk:${{ matrix.java }} sb:${{ matrix.spring-boot-version }} exp:${{ matrix.experimental }}"
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: true
matrix:
java: [ 11, 13, 15, 16 ]
spring-boot-version: [ 2.7.8 ]
experimental: [ false ]
include:
- java: 11
spring-boot-version: 2.6.14
experimental: false
- java: 11
spring-boot-version: 2.5.7
experimental: false
- java: 11
spring-boot-version: 2.4.0
experimental: false
- java: 11
spring-boot-version: 2.3.6.RELEASE
experimental: false
env:
GOVER: 1.19
GOOS: linux
Expand Down Expand Up @@ -92,18 +110,18 @@ jobs:
docker-compose -f ./sdk-tests/deploy/local-test-mongo.yml up -d
docker ps
- name: Clean up files
run: mvn clean
run: mvn clean -B
- name: Build sdk
run: mvn compile -q
run: mvn compile -B -q
- name: Unit tests
run: mvn test -q
run: mvn -B test -q
- name: Codecov
uses: codecov/[email protected]
- name: Install jars
run: mvn install -q
- name: Integration tests
run: mvn install -q -B -DskipTests
- name: Integration tests using spring boot version ${{ matrix.spring-boot-version }}
id: integration_tests
run: mvn -f sdk-tests/pom.xml verify
run: PRODUCT_SPRING_BOOT_VERSION=${{ matrix.spring-boot-version }} mvn -B -f sdk-tests/pom.xml verify
- name: Upload test report for sdk
uses: actions/upload-artifact@master
with:
Expand Down Expand Up @@ -145,7 +163,7 @@ jobs:
java-version: ${{ env.JDK_VER }}
- name: Get pom parent version
run: |
PARENT_VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
PARENT_VERSION=$(mvn -B -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
echo "PARENT_VERSION=$PARENT_VERSION" >> $GITHUB_ENV
- name: Is SNAPSHOT release ?
if: contains(github.ref, 'master') && contains(env.PARENT_VERSION, '-SNAPSHOT')
Expand All @@ -157,7 +175,7 @@ jobs:
echo "DEPLOY_OSSRH=true" >> $GITHUB_ENV
- name: Install jars
if: env.DEPLOY_OSSRH == 'true'
run: mvn clean install -q
run: mvn clean install -B -q
- name: Publish to ossrh
if: env.DEPLOY_OSSRH == 'true'
run: |
Expand Down
2 changes: 0 additions & 2 deletions sdk-springboot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,11 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.3.25</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.3.25</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
io.dapr.springboot.DaprAutoConfiguration
38 changes: 36 additions & 2 deletions sdk-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@
<spring-boot.version>2.7.8</spring-boot.version>
</properties>

<dependencyManagement>
<!-- Reproduce a product fixing its own spring boot version -->
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>commons-cli</groupId>
Expand Down Expand Up @@ -102,13 +115,11 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>${spring-boot.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -203,4 +214,27 @@
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>custom-spring-boot-version</id>
<activation>
<property>
<name>env.PRODUCT_SPRING_BOOT_VERSION</name>
</property>
</activation>
<properties>
<spring-boot.version>${env.PRODUCT_SPRING_BOOT_VERSION}</spring-boot.version>
</properties>
<dependencies>
<dependency>
<!-- Needed for dapr compatibility for spring boot versions before 2.7 -->
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.9.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
2 changes: 1 addition & 1 deletion sdk-tests/src/test/java/io/dapr/it/AppRun.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
public class AppRun implements Stoppable {

private static final String APP_COMMAND =
"mvn exec:java -D exec.mainClass=%s -D exec.classpathScope=test -D exec.args=\"%s\" -D %s=%s -D %s=%s";
"mvn exec:java -B -D exec.mainClass=%s -D exec.classpathScope=test -D exec.args=\"%s\" -D %s=%s -D %s=%s";

private final DaprPorts ports;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -755,8 +755,8 @@ public void testLongValues() throws Exception {
for (CloudEvent<ConvertToLong> message : messages) {
actual.add(message.getData());
}
Assert.assertEquals(values, actual);
}, 2000);
Assert.assertEquals(values, actual);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.propagation.TextMapPropagator;
import org.jetbrains.annotations.Nullable;
import javax.annotation.Nullable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
Expand Down