Skip to content

Commit

Permalink
Added support for Spring Boot 3. (#10)
Browse files Browse the repository at this point in the history
* Added support for Spring Boot 3.
  • Loading branch information
onukristo authored May 10, 2023
1 parent c88b847 commit a836df3
Show file tree
Hide file tree
Showing 43 changed files with 288 additions and 126 deletions.
104 changes: 85 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,114 @@ on:
- master

jobs:
build:
name: "Build and Test"
matrix_build:
name: "Matrix Build"
runs-on:
- ubuntu-latest
strategy:
fail-fast: false
max-parallel: 100
matrix:
spring_boot_version:
- 3.0.6
- 2.7.11
- 2.6.14
env:
SPRING_BOOT_VERSION: ${{ matrix.spring_boot_version }}
GRADLE_OPTS: "-Djava.security.egd=file:/dev/./urandom -Dorg.gradle.parallel=true"
IN_CI: true
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: "Retrieve gradle settings"
uses: actions/cache@v2
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
path: |
~/.gradle
key: gradle-v1-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties', '**/*.gradle*') }}
gradle-home-cache-cleanup: true
# Comment out when you are upgrading gradle in a branch and doing tons of commits you would need to test.
# cache-read-only: false
- name: "Assemble jar"
run: GRADLE_USER_HOME=$HOME/.gradle ./gradlew assemble --console=plain --no-daemon
uses: gradle/gradle-build-action@v2
with:
arguments: assemble --console=plain --info --stacktrace --parallel
- name: "Compile tests"
uses: gradle/gradle-build-action@v2
with:
arguments: compileTestJava compileTestGroovy --console=plain --info --stacktrace --parallel
- name: "Run checks"
uses: gradle/gradle-build-action@v2
with:
arguments: check -x test --console=plain --stacktrace
- name: "Run tests"
run: GRADLE_USER_HOME=$HOME/.gradle ./gradlew -Dspring.profiles.include=continuous-integration check --console=plain --no-daemon --stacktrace
uses: gradle/gradle-build-action@v2
with:
arguments: test --console=plain --info --stacktrace
- name: "Test if publishing works"
run: GRADLE_USER_HOME=$HOME/.gradle ./gradlew publishToMavenLocal --console=plain --no-daemon --stacktrace
uses: gradle/gradle-build-action@v2
with:
arguments: publishToMavenLocal --console=plain --info --stacktrace
- name: "Publish Test Report"
uses: mikepenz/action-junit-report@v2
uses: mikepenz/action-junit-report@v3
if: always()
with:
check_name: Test Report-(${{ matrix.spring_boot_version }})
report_paths: '**/build/test-results/**/*.xml'
github_token: ${{ secrets.GITHUB_TOKEN }}
require_tests: true
- name: Publish checkstyle report
if: failure()
if: always()
uses: jwgmeligmeyling/checkstyle-github-action@master
with:
name: Checkstyle Report-(${{ matrix.spring_boot_version }})
path: '**/build/reports/**/*.xml'
- name: Publish spotbugs report
if: failure()
uses: jwgmeligmeyling/spotbugs-github-action@master
with:
name: Spotbugs Report-(${{ matrix.spring_boot_version }})
path: '**/build/reports/**/*.xml'
- name: "Bootstrap git config"
if: github.ref == 'refs/heads/master'
- name: "Collect test reports"
run: |
mkdir -p ~/.ssh
ssh-keyscan github.com >> ~/.ssh/known_hosts
git config --global user.name "TW GitHub Actions" && git config --global user.email [email protected]
tar -zcvf all-test-reports-${{ matrix.spring_boot_version }}.tar.gz **/build/reports
if: always()
- name: "Store test results"
uses: actions/upload-artifact@v3
if: always()
with:
name: all-test-reports-${{ matrix.spring_boot_version }}
path: all-test-reports-${{ matrix.spring_boot_version }}.tar.gz
retention-days: 7
build:
name: "Build and Test"
runs-on:
- ubuntu-latest
needs: matrix_build
container:
image: azul/zulu-openjdk:17
steps:
# Needed hacks to properly fail the build when one matrix build fails.
- name: Do something so that GHA is happy
run: echo "Be happy!"
- name: Verify matrix jobs succeeded
if: ${{ needs.matrix_build.result != 'success' }}
run: exit 1
- name: "Install packages"
run: apt-get update && apt-get install -y git unzip
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true
# Comment out when you are upgrading gradle in a branch and doing tons of commits you would need to test.
# cache-read-only: false
- name: "Tag release"
if: github.ref == 'refs/heads/master'
run: GRADLE_USER_HOME=$HOME/.gradle ./gradlew tagRelease --console=plain --no-daemon
uses: gradle/gradle-build-action@v2
with:
arguments: tagRelease --console=plain --info --stacktrace

5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.2.0] - 2023-05-08

### Added

* Support for Spring Boot 3

## [1.1.1] - 2022-02-01

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Allows applications to raise incidents and recover from them.

Configuration options are in [IncidentsProperties](src/main/java/com/transferwise/common/incidents/IncidentsProperties.java)
Configuration options are in [IncidentsProperties](tw-incidents/src/main/java/com/transferwise/common/incidents/IncidentsProperties.java)

Engineers have to provide implementations for `IncidentGenerator`s, which are responsible for gathering active incidents.

Expand Down Expand Up @@ -47,7 +47,7 @@ public class StuckTasksIncidentGenerator implements IncidentGenerator {

## VictorOps

Configuration options are in [VictorOpsProperties](src/main/java/com/transferwise/common/incidents/victorops/VictorOpsProperties.java).
Configuration options are in [VictorOpsProperties](tw-incidents/src/main/java/com/transferwise/common/incidents/victorops/VictorOpsProperties.java).

VictorOps example:
```yaml
Expand All @@ -66,7 +66,7 @@ Notes:

## Slack

Configuration options are in [SlackProperties](src/main/java/com/transferwise/common/incidents/slack/SlackProperties.java)
Configuration options are in [SlackProperties](tw-incidents/src/main/java/com/transferwise/common/incidents/slack/SlackProperties.java)

Slack example:
```yaml
Expand Down
64 changes: 46 additions & 18 deletions build.common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,60 @@ apply plugin: 'checkstyle'
apply plugin: 'com.github.spotbugs'

group = 'com.transferwise.common'
ext.springBootVersion = "2.5.8"

repositories {
mavenCentral()
mavenLocal()
}

apply from: "${project.rootDir}/build.libraries.gradle"

configurations {
local {
canBeResolved(false)
canBeConsumed(false)
}
compileClasspath {
extendsFrom(local)
}
runtimeClasspath {
extendsFrom(local)
}
testCompileClasspath {
extendsFrom(local)
}
testRuntimeClasspath {
extendsFrom(local)
}
annotationProcessor {
extendsFrom(local)
}
testAnnotationProcessor {
extendsFrom(local)
}
}

dependencies {
annotationProcessor(platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}"))
compileOnly(platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}"))
implementation(platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}"))
testAnnotationProcessor(platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}"))

annotationProcessor 'org.projectlombok:lombok'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
compileOnly 'org.projectlombok:lombok'
compileOnly 'com.github.spotbugs:spotbugs-annotations:4.2.3'

testAnnotationProcessor 'org.projectlombok:lombok'
testCompileOnly 'org.projectlombok:lombok'
testCompileOnly 'com.github.spotbugs:spotbugs-annotations:4.2.3'
local platform(libraries.springBootDependencies)

compileOnly libraries.lombok
annotationProcessor libraries.lombok
annotationProcessor libraries.springBootConfigurationProcessor
testCompileOnly libraries.lombok
testAnnotationProcessor libraries.lombok

compileOnly libraries.spotbugsAnnotations
}

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
if (springBootVersion.startsWith("3.")) {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
else{
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
withSourcesJar()
withJavadocJar()
}
Expand Down Expand Up @@ -60,7 +88,7 @@ test {

tasks.findAll { it.name.startsWith("spotbugs") }*.configure {
effort = "max"
excludeFilter = file('spotbugs-exclude.xml')
excludeFilter = file("${project.rootDir}/spotbugs-exclude.xml")
reports {
xml.required = true
html.required = true
Expand All @@ -72,7 +100,7 @@ spotbugs {
}

tasks.withType(Checkstyle) {
config = resources.text.fromFile(file('google_checks.xml'))
config = resources.text.fromFile(file("${project.rootDir}/google_checks.xml"))

maxWarnings = 0

Expand Down
39 changes: 4 additions & 35 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,47 +1,16 @@
import org.eclipse.jgit.api.errors.RefAlreadyExistsException

plugins {
id "com.github.spotbugs" version "5.0.3" apply false
id "com.github.spotbugs" version "5.0.14" apply false
id "idea"
id 'org.ajoberstar.grgit' version '4.1.1'
id 'org.ajoberstar.grgit' version '5.2.0'
id 'io.github.gradle-nexus.publish-plugin' version "1.1.0"
}

idea.project {
vcs = 'Git'
languageLevel = JavaVersion.VERSION_11
targetBytecodeVersion = JavaVersion.VERSION_11
}

ext.projectName = 'TransferWise Incidents Registration System'
ext.projectDescription = 'TransferWise Incidents Registration System - uses VictorOps model to register and unregister incidents.'
ext.projectGitHubRepoName = 'tw-incidents'
ext.projectArtifactName = 'tw-incidents'

apply from: 'build.common.gradle'
apply from: 'build.publishing.gradle'

dependencies {
compileOnly 'org.springframework.boot:spring-boot-autoconfigure'
compileOnly 'org.springframework.boot:spring-boot-actuator'
compileOnly 'org.springframework:spring-web'
compileOnly 'javax.annotation:jsr250-api:1.0'

implementation 'org.slf4j:slf4j-api'
implementation 'com.transferwise.common:tw-graceful-shutdown:2.3.0'
implementation 'com.transferwise.common:tw-graceful-shutdown-interfaces:2.3.0'
implementation 'com.transferwise.common:tw-base-utils:1.5.0'
implementation 'com.fasterxml.jackson.core:jackson-annotations'
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'org.apache.commons:commons-lang3'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework:spring-web'
testImplementation 'org.springframework.boot:spring-boot-actuator'
testImplementation 'org.spockframework:spock-core:2.0-groovy-3.0'
testImplementation 'org.spockframework:spock-spring:2.0-groovy-3.0'
testImplementation 'org.awaitility:awaitility:4.1.1'
testImplementation 'javax.servlet:javax.servlet-api'
languageLevel = JavaVersion.VERSION_17
targetBytecodeVersion = JavaVersion.VERSION_17
}

task tagRelease {
Expand Down
29 changes: 29 additions & 0 deletions build.libraries.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
ext {
springBootVersion = "${System.getenv("SPRING_BOOT_VERSION") ?: '2.6.14'}"

libraries = [
// version defined
awaitility : 'org.awaitility:awaitility:4.2.0',
spotbugsAnnotations : "com.github.spotbugs:spotbugs-annotations:${spotbugs.toolVersion.get()}",
spockSpring : 'org.spockframework:spock-spring:2.4-M1-groovy-4.0',

springBootDependencies : "org.springframework.boot:spring-boot-dependencies:${springBootVersion}",
twGracefulShutdown : 'com.transferwise.common:tw-graceful-shutdown:2.11.0',
twGracefulShutdownInterfaces : 'com.transferwise.common:tw-graceful-shutdown-interfaces:2.11.0',
twBaseUtils : 'com.transferwise.common:tw-base-utils:1.10.1',

// versions managed by spring-boot-dependencies platform
commonsLang3 : 'org.apache.commons:commons-lang3',
jacksonAnnotations : 'com.fasterxml.jackson.core:jackson-annotations',
jacksonDatabind : 'com.fasterxml.jackson.core:jackson-databind',
lombok : 'org.projectlombok:lombok',
slf4jApi : 'org.slf4j:slf4j-api',
springBootActuator : 'org.springframework.boot:spring-boot-actuator',
springBootAutoConfigure : 'org.springframework.boot:spring-boot-autoconfigure',
springBootConfigurationProcessor: 'org.springframework.boot:spring-boot-configuration-processor',
springBootStarterActuator : 'org.springframework.boot:spring-boot-starter-actuator',
springBootStarterTest : 'org.springframework.boot:spring-boot-starter-test',
springBootStarterWeb : 'org.springframework.boot:spring-boot-starter-web',
springWeb : 'org.springframework:spring-web',
]
}
18 changes: 18 additions & 0 deletions build.publishing.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ publishing {
artifactId = projectArtifactName
}

/*
This ensures that libraries will have explicit dependency versions in their Maven POM and Gradle module files, so that there would be less
ambiguity and less chances of dependency conflicts.
*/
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionOf('runtimeClasspath')
}
}

pom {
name = projectName
description = projectDescription
Expand All @@ -40,6 +53,11 @@ publishing {
developerConnection = projectScmConnection
url = projectScmUrl
}
withXml {
if (!asNode().dependencyManagement.isEmpty()){
throw new IllegalStateException("There should not be any `dependencyManagement` block in POM.")
}
}
}
}
}
Expand Down
1 change: 0 additions & 1 deletion google_checks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@
value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
</module>
<module name="JavadocMethod">
<property name="scope" value="public"/>
<property name="allowMissingParamTags" value="true"/>
<property name="allowMissingReturnTag" value="true"/>
<property name="allowedAnnotations" value="Override, Test"/>
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=1.1.1
version=1.2.0
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Loading

0 comments on commit a836df3

Please sign in to comment.