diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7196936..676be21 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 circle@circle.tw.ee + 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 \ No newline at end of file + uses: gradle/gradle-build-action@v2 + with: + arguments: tagRelease --console=plain --info --stacktrace + diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b09ca1..5347c52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index d922c80..56fb689 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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 @@ -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 diff --git a/build.common.gradle b/build.common.gradle index 9012170..d70849c 100644 --- a/build.common.gradle +++ b/build.common.gradle @@ -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() } @@ -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 @@ -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 diff --git a/build.gradle b/build.gradle index 2f117e6..cfb16db 100644 --- a/build.gradle +++ b/build.gradle @@ -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 { diff --git a/build.libraries.gradle b/build.libraries.gradle new file mode 100644 index 0000000..1fa3bff --- /dev/null +++ b/build.libraries.gradle @@ -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', + ] +} diff --git a/build.publishing.gradle b/build.publishing.gradle index ea4e8a2..c08046a 100644 --- a/build.publishing.gradle +++ b/build.publishing.gradle @@ -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 @@ -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.") + } + } } } } diff --git a/google_checks.xml b/google_checks.xml index 4e75327..4141931 100644 --- a/google_checks.xml +++ b/google_checks.xml @@ -241,7 +241,6 @@ value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/> - diff --git a/gradle.properties b/gradle.properties index ef0464d..1bf5794 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -version=1.1.1 +version=1.2.0 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 01b8bf6..e708b1c 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a2a1514..fae0804 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Thu May 09 10:29:36 EEST 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip diff --git a/gradlew b/gradlew index cccdd3d..4f906e0 100755 --- a/gradlew +++ b/gradlew @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + ############################################################################## ## ## Gradle start up script for UN*X @@ -28,7 +44,7 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -66,6 +82,7 @@ esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then @@ -109,10 +126,11 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath @@ -138,19 +156,19 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi @@ -159,14 +177,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index e95643d..ac1b06f 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/settings.gradle b/settings.gradle index 5bbf0e5..adb85a6 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1,3 @@ rootProject.name = 'tw-incidents' + +include 'tw-incidents' \ No newline at end of file diff --git a/src/main/resources/META-INF/spring.factories b/src/main/resources/META-INF/spring.factories deleted file mode 100644 index b434881..0000000 --- a/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,2 +0,0 @@ -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ - com.transferwise.common.incidents.IncidentsAutoConfiguration diff --git a/tw-incidents/build.gradle b/tw-incidents/build.gradle new file mode 100644 index 0000000..5d6c498 --- /dev/null +++ b/tw-incidents/build.gradle @@ -0,0 +1,29 @@ +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: "${project.rootDir}/build.common.gradle" +apply from: "${project.rootDir}/build.publishing.gradle" + +dependencies { + compileOnly libraries.springBootAutoConfigure + compileOnly libraries.springBootActuator + compileOnly libraries.springWeb + + implementation libraries.slf4jApi + implementation libraries.twGracefulShutdownInterfaces + implementation libraries.twBaseUtils + implementation libraries.jacksonAnnotations + implementation libraries.jacksonDatabind + implementation libraries.commonsLang3 + + testImplementation libraries.springBootStarterTest + testImplementation libraries.springBootStarterWeb + testImplementation libraries.springBootStarterActuator + testImplementation libraries.spockSpring + testImplementation libraries.awaitility + + testRuntimeOnly libraries.twGracefulShutdown + +} \ No newline at end of file diff --git a/src/main/java/com/transferwise/common/incidents/DefaultIncidentsManager.java b/tw-incidents/src/main/java/com/transferwise/common/incidents/DefaultIncidentsManager.java similarity index 97% rename from src/main/java/com/transferwise/common/incidents/DefaultIncidentsManager.java rename to tw-incidents/src/main/java/com/transferwise/common/incidents/DefaultIncidentsManager.java index b620532..79d6cbe 100644 --- a/src/main/java/com/transferwise/common/incidents/DefaultIncidentsManager.java +++ b/tw-incidents/src/main/java/com/transferwise/common/incidents/DefaultIncidentsManager.java @@ -18,14 +18,14 @@ import java.util.concurrent.locks.ReentrantLock; import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.annotation.PostConstruct; import lombok.Data; import lombok.experimental.Accessors; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; @Slf4j -public class DefaultIncidentsManager implements IncidentsManager, GracefulShutdownStrategy { +public class DefaultIncidentsManager implements IncidentsManager, GracefulShutdownStrategy, InitializingBean { @Autowired private List notifiers; @@ -44,8 +44,8 @@ public class DefaultIncidentsManager implements IncidentsManager, GracefulShutdo private Thread onShutdownIncidentsReleasingThread; - @PostConstruct - public void init() { + @Override + public void afterPropertiesSet() { incidentGeneratorStates = new ConcurrentHashMap<>(); for (IncidentGenerator incidentGenerator : incidentGenerators) { log.info("Registering incident generator '" + incidentGenerator + "'."); diff --git a/src/main/java/com/transferwise/common/incidents/Incident.java b/tw-incidents/src/main/java/com/transferwise/common/incidents/Incident.java similarity index 100% rename from src/main/java/com/transferwise/common/incidents/Incident.java rename to tw-incidents/src/main/java/com/transferwise/common/incidents/Incident.java diff --git a/src/main/java/com/transferwise/common/incidents/IncidentGenerator.java b/tw-incidents/src/main/java/com/transferwise/common/incidents/IncidentGenerator.java similarity index 100% rename from src/main/java/com/transferwise/common/incidents/IncidentGenerator.java rename to tw-incidents/src/main/java/com/transferwise/common/incidents/IncidentGenerator.java diff --git a/src/main/java/com/transferwise/common/incidents/IncidentNotifier.java b/tw-incidents/src/main/java/com/transferwise/common/incidents/IncidentNotifier.java similarity index 100% rename from src/main/java/com/transferwise/common/incidents/IncidentNotifier.java rename to tw-incidents/src/main/java/com/transferwise/common/incidents/IncidentNotifier.java diff --git a/src/main/java/com/transferwise/common/incidents/IncidentsAutoConfiguration.java b/tw-incidents/src/main/java/com/transferwise/common/incidents/IncidentsAutoConfiguration.java similarity index 100% rename from src/main/java/com/transferwise/common/incidents/IncidentsAutoConfiguration.java rename to tw-incidents/src/main/java/com/transferwise/common/incidents/IncidentsAutoConfiguration.java diff --git a/src/main/java/com/transferwise/common/incidents/IncidentsHealthIndicator.java b/tw-incidents/src/main/java/com/transferwise/common/incidents/IncidentsHealthIndicator.java similarity index 100% rename from src/main/java/com/transferwise/common/incidents/IncidentsHealthIndicator.java rename to tw-incidents/src/main/java/com/transferwise/common/incidents/IncidentsHealthIndicator.java diff --git a/src/main/java/com/transferwise/common/incidents/IncidentsManager.java b/tw-incidents/src/main/java/com/transferwise/common/incidents/IncidentsManager.java similarity index 100% rename from src/main/java/com/transferwise/common/incidents/IncidentsManager.java rename to tw-incidents/src/main/java/com/transferwise/common/incidents/IncidentsManager.java diff --git a/src/main/java/com/transferwise/common/incidents/IncidentsProperties.java b/tw-incidents/src/main/java/com/transferwise/common/incidents/IncidentsProperties.java similarity index 100% rename from src/main/java/com/transferwise/common/incidents/IncidentsProperties.java rename to tw-incidents/src/main/java/com/transferwise/common/incidents/IncidentsProperties.java diff --git a/src/main/java/com/transferwise/common/incidents/LoggingIncidentNotifier.java b/tw-incidents/src/main/java/com/transferwise/common/incidents/LoggingIncidentNotifier.java similarity index 100% rename from src/main/java/com/transferwise/common/incidents/LoggingIncidentNotifier.java rename to tw-incidents/src/main/java/com/transferwise/common/incidents/LoggingIncidentNotifier.java diff --git a/src/main/java/com/transferwise/common/incidents/slack/SlackAttachment.java b/tw-incidents/src/main/java/com/transferwise/common/incidents/slack/SlackAttachment.java similarity index 100% rename from src/main/java/com/transferwise/common/incidents/slack/SlackAttachment.java rename to tw-incidents/src/main/java/com/transferwise/common/incidents/slack/SlackAttachment.java diff --git a/src/main/java/com/transferwise/common/incidents/slack/SlackField.java b/tw-incidents/src/main/java/com/transferwise/common/incidents/slack/SlackField.java similarity index 100% rename from src/main/java/com/transferwise/common/incidents/slack/SlackField.java rename to tw-incidents/src/main/java/com/transferwise/common/incidents/slack/SlackField.java diff --git a/src/main/java/com/transferwise/common/incidents/slack/SlackIncidentNotifier.java b/tw-incidents/src/main/java/com/transferwise/common/incidents/slack/SlackIncidentNotifier.java similarity index 100% rename from src/main/java/com/transferwise/common/incidents/slack/SlackIncidentNotifier.java rename to tw-incidents/src/main/java/com/transferwise/common/incidents/slack/SlackIncidentNotifier.java diff --git a/src/main/java/com/transferwise/common/incidents/slack/SlackMessage.java b/tw-incidents/src/main/java/com/transferwise/common/incidents/slack/SlackMessage.java similarity index 100% rename from src/main/java/com/transferwise/common/incidents/slack/SlackMessage.java rename to tw-incidents/src/main/java/com/transferwise/common/incidents/slack/SlackMessage.java diff --git a/src/main/java/com/transferwise/common/incidents/slack/SlackProperties.java b/tw-incidents/src/main/java/com/transferwise/common/incidents/slack/SlackProperties.java similarity index 100% rename from src/main/java/com/transferwise/common/incidents/slack/SlackProperties.java rename to tw-incidents/src/main/java/com/transferwise/common/incidents/slack/SlackProperties.java diff --git a/src/main/java/com/transferwise/common/incidents/victorops/VictorOpsIncidentNotifier.java b/tw-incidents/src/main/java/com/transferwise/common/incidents/victorops/VictorOpsIncidentNotifier.java similarity index 100% rename from src/main/java/com/transferwise/common/incidents/victorops/VictorOpsIncidentNotifier.java rename to tw-incidents/src/main/java/com/transferwise/common/incidents/victorops/VictorOpsIncidentNotifier.java diff --git a/src/main/java/com/transferwise/common/incidents/victorops/VictorOpsProperties.java b/tw-incidents/src/main/java/com/transferwise/common/incidents/victorops/VictorOpsProperties.java similarity index 100% rename from src/main/java/com/transferwise/common/incidents/victorops/VictorOpsProperties.java rename to tw-incidents/src/main/java/com/transferwise/common/incidents/victorops/VictorOpsProperties.java diff --git a/src/main/java/com/transferwise/common/incidents/victorops/VictorOpsRequest.java b/tw-incidents/src/main/java/com/transferwise/common/incidents/victorops/VictorOpsRequest.java similarity index 100% rename from src/main/java/com/transferwise/common/incidents/victorops/VictorOpsRequest.java rename to tw-incidents/src/main/java/com/transferwise/common/incidents/victorops/VictorOpsRequest.java diff --git a/src/main/java/com/transferwise/common/incidents/victorops/VictorOpsResponse.java b/tw-incidents/src/main/java/com/transferwise/common/incidents/victorops/VictorOpsResponse.java similarity index 100% rename from src/main/java/com/transferwise/common/incidents/victorops/VictorOpsResponse.java rename to tw-incidents/src/main/java/com/transferwise/common/incidents/victorops/VictorOpsResponse.java diff --git a/tw-incidents/src/main/resources/META-INF/spring.factories b/tw-incidents/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000..e0fa284 --- /dev/null +++ b/tw-incidents/src/main/resources/META-INF/spring.factories @@ -0,0 +1 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.transferwise.common.incidents.IncidentsAutoConfiguration diff --git a/tw-incidents/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/tw-incidents/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000..f1b3156 --- /dev/null +++ b/tw-incidents/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.transferwise.common.incidents.IncidentsAutoConfiguration diff --git a/src/test/groovy/com/transferwise/common/incidents/IncidentsIntSpec.groovy b/tw-incidents/src/test/groovy/com/transferwise/common/incidents/IncidentsIntSpec.groovy similarity index 99% rename from src/test/groovy/com/transferwise/common/incidents/IncidentsIntSpec.groovy rename to tw-incidents/src/test/groovy/com/transferwise/common/incidents/IncidentsIntSpec.groovy index 6baf08c..5f23206 100644 --- a/src/test/groovy/com/transferwise/common/incidents/IncidentsIntSpec.groovy +++ b/tw-incidents/src/test/groovy/com/transferwise/common/incidents/IncidentsIntSpec.groovy @@ -45,7 +45,7 @@ class IncidentsIntSpec extends Specification { } def cleanup() { - testIncidentGenerator.activeIncidents.clear() + testIncidentGenerator.getActiveIncidents().clear() testIncidentNotifier.openIncidents.clear() } diff --git a/src/test/groovy/com/transferwise/common/incidents/IncidentsManagerSpec.groovy b/tw-incidents/src/test/groovy/com/transferwise/common/incidents/IncidentsManagerSpec.groovy similarity index 97% rename from src/test/groovy/com/transferwise/common/incidents/IncidentsManagerSpec.groovy rename to tw-incidents/src/test/groovy/com/transferwise/common/incidents/IncidentsManagerSpec.groovy index 6b2330f..732ee52 100644 --- a/src/test/groovy/com/transferwise/common/incidents/IncidentsManagerSpec.groovy +++ b/tw-incidents/src/test/groovy/com/transferwise/common/incidents/IncidentsManagerSpec.groovy @@ -23,7 +23,7 @@ class IncidentsManagerSpec extends Specification { incidentsManager.notifiers = [] incidentsManager.incidentsProperties = new IncidentsProperties() - incidentsManager.init() + incidentsManager.afterPropertiesSet() Clock clock = Clock.fixed(Instant.now(), ZoneId.systemDefault()) ClockHolder.setClock(clock) when: diff --git a/src/test/groovy/com/transferwise/common/incidents/TestApplication.java b/tw-incidents/src/test/groovy/com/transferwise/common/incidents/TestApplication.java similarity index 100% rename from src/test/groovy/com/transferwise/common/incidents/TestApplication.java rename to tw-incidents/src/test/groovy/com/transferwise/common/incidents/TestApplication.java diff --git a/src/test/groovy/com/transferwise/common/incidents/test/TestIncidentGenerator.java b/tw-incidents/src/test/groovy/com/transferwise/common/incidents/test/TestIncidentGenerator.java similarity index 100% rename from src/test/groovy/com/transferwise/common/incidents/test/TestIncidentGenerator.java rename to tw-incidents/src/test/groovy/com/transferwise/common/incidents/test/TestIncidentGenerator.java diff --git a/src/test/groovy/com/transferwise/common/incidents/test/TestIncidentNotifier.java b/tw-incidents/src/test/groovy/com/transferwise/common/incidents/test/TestIncidentNotifier.java similarity index 100% rename from src/test/groovy/com/transferwise/common/incidents/test/TestIncidentNotifier.java rename to tw-incidents/src/test/groovy/com/transferwise/common/incidents/test/TestIncidentNotifier.java diff --git a/src/test/resources/application.properties b/tw-incidents/src/test/resources/application.properties similarity index 100% rename from src/test/resources/application.properties rename to tw-incidents/src/test/resources/application.properties diff --git a/src/test/resources/logback-spring.xml b/tw-incidents/src/test/resources/logback-spring.xml similarity index 100% rename from src/test/resources/logback-spring.xml rename to tw-incidents/src/test/resources/logback-spring.xml