Skip to content

Commit 5940ed2

Browse files
committed
Use Markdown Architectural Decision Records https://adr.github.io/madr/
Improve maintainability by adding SpringBoot framework Added IT (Docker tests) Added performance tests (Gatling) logback.xml can be overridden from command line
1 parent def9b0c commit 5940ed2

56 files changed

Lines changed: 2031 additions & 3566 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/continuous-integration-workflow.yml

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
sudo tar vxf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
2121
sudo mv wkhtmltox/bin/wkhtmlto* /usr/bin
2222
- name: Build with Gradle
23-
run: ./gradlew clean test shadowJar --stacktrace --no-daemon
23+
run: ./gradlew clean check --stacktrace --no-daemon
2424
env:
2525
NO_NEXUS: true
2626
- uses: actions/cache@v1
@@ -34,29 +34,7 @@ jobs:
3434
if: ${{ always() }}
3535
with:
3636
name: JUnit Report
37-
path: build/reports/tests/test/**
38-
- name: copy created artifacts into docker context
39-
run: |
40-
cp build/libs/*-all.jar ./docker/app.jar
41-
- name: Build docker image
42-
if: success()
43-
run: |
44-
COMMIT_AUTHOR=$(git --no-pager show -s --format='%an (%ae)' $GITHUB_SHA)
45-
COMMIT_MESSAGE=$(git log -1 --pretty=%B $GITHUB_SHA)
46-
COMMIT_TIME=$(git show -s --format=%ci $GITHUB_SHA)
47-
BUILD_TIME=$(date -u "+%Y-%m-%d %H:%M:%S %z")
48-
docker build \
49-
--label "ods.build.job.url=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" \
50-
--label "ods.build.source.repo.ref=$GITHUB_REF" \
51-
--label "ods.build.source.repo.commit.author=$COMMIT_AUTHOR" \
52-
--label "ods.build.source.repo.commit.msg=$COMMIT_MESSAGE" \
53-
--label "ods.build.source.repo.commit.sha=$GITHUB_SHA" \
54-
--label "ods.build.source.repo.commit.timestamp=$COMMIT_TIME" \
55-
--label "ods.build.source.repo.url=https://github.com/$GITHUB_REPOSITORY.git" \
56-
--label "ods.build.timestamp=$BUILD_TIME" \
57-
-t ods-document-generation-svc:local .
58-
docker inspect ods-document-generation-svc:local --format='{{.Config.Labels}}'
59-
working-directory: docker
37+
path: build/reports/**/**
6038
- name: Push docker image
6139
if: success() && github.repository == 'opendevstack/ods-document-generation-svc' && github.event_name == 'push'
6240
shell: bash

CHANGELOG.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,21 @@
44
- Fix TIR and DTR documents are not properly indexed ([#55](https://github.com/opendevstack/ods-document-generation-svc/pull/55))
55
- Fix wkhtmltox hangs ([#66](https://github.com/opendevstack/ods-document-generation-svc/pull/66))
66
- Improve memory management and error handling ([#70](https://github.com/opendevstack/ods-document-generation-svc/pull/70))
7+
- Use Markdown Architectural Decision Records https://adr.github.io/madr/
8+
- Improve maintainability by adding SpringBoot framework
9+
- Added IT (Docker tests)
10+
- Added performance tests
11+
- logback.xml can be overridden from command line
712

8-
### Fixed
9-
- Github template tests fail in proxy environment ([#56](https://github.com/opendevstack/ods-document-generation-svc/issues/56))
10-
11-
## [4.0] - 2021-15-11
13+
## [4.0] - 2021-18-11
1214

1315
### Added
1416
- Added log to print /document endpoint input
1517

18+
### Fixed
19+
- Github template tests fail in proxy environment ([#56](https://github.com/opendevstack/ods-document-generation-svc/issues/56))
20+
- Fix TIR and DTR documents are not properly indexed ([#55](https://github.com/opendevstack/ods-document-generation-svc/pull/55))
21+
1622
### Changed
1723
- Updated maxRequestSize value from 100m to 200m
1824

build.gradle

Lines changed: 126 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
buildscript {
22
ext {
3+
groovyallVersion = '3.0.9'
4+
springbootVersion = "2.6.2"
5+
spockCoreVersion = "2.0-groovy-3.0"
6+
spockReportsVersion = '2.1-groovy-3.0'
7+
38
nexus_url = "${project.findProperty('nexus_url') ?: System.getenv('NEXUS_HOST')}"
49
nexus_user = "${project.findProperty('nexus_user') ?: System.getenv('NEXUS_USERNAME')}"
510
nexus_pw = "${project.findProperty('nexus_pw') ?: System.getenv('NEXUS_PASSWORD')}"
611
no_nexus = (project.findProperty('no_nexus') ?: System.getenv('NO_NEXUS') ?: false).toBoolean()
712
if (!no_nexus && (nexus_url == "null" || nexus_user == "null" || nexus_pw == "null")) {
813
throw new GradleException("property no_nexus='false' (or not defined) but at least one of the properties nexus_url, nexus_user or nexus_pw is not configured. Please configure those properties!")
914
}
10-
11-
def folderRel = (String)("${project.findProperty('nexus_folder_releases') ?: System.getenv('NEXUS_FOLDER_RELEASES')}")
12-
nexusFolderReleases = folderRel == "null" ? "maven-releases" : folderRel
13-
14-
def folderSnaps = (String)("${project.findProperty('nexus_folder_snapshots') ?: System.getenv('NEXUS_FOLDER_SNAPSHOTS')}")
15-
nexusFolderSnapshots = folderSnaps == "null" ? "maven-snapshots" : folderSnaps
16-
17-
snippetsDir = file('build/generated-snippets')
1815
}
1916

2017
repositories {
@@ -51,32 +48,21 @@ buildscript {
5148
}
5249
}
5350

54-
buildscript {
55-
ext {
56-
joobyVersion = "1.6.6"
57-
}
58-
59-
dependencies {
60-
classpath "org.jooby:jooby-gradle-plugin:$joobyVersion"
61-
}
62-
}
63-
6451
plugins {
65-
id "com.github.johnrengelman.shadow"
66-
id "com.google.osdetector" version "1.6.2"
67-
id "io.spring.dependency-management" version "1.0.8.RELEASE"
52+
id "groovy"
53+
id 'com.adarshr.test-logger' version '3.1.0'
54+
id 'jacoco'
55+
id 'org.springframework.boot' version "${springbootVersion}"
56+
id 'com.bmuschko.docker-spring-boot-application' version '7.1.0'
57+
id "io.gatling.gradle" version "3.7.3"
6858
}
69-
70-
apply plugin: "application"
71-
apply plugin: "com.github.johnrengelman.shadow"
72-
apply plugin: "groovy"
73-
apply plugin: "jooby"
74-
apply plugin: "jacoco"
59+
// related to gatling and Springboot
60+
ext['netty.version'] = '4.0.51.Final'
7561

7662
repositories {
63+
mavenCentral()
7764
if (no_nexus) {
7865
println("using repositories 'jcenter' and 'mavenCentral', because property no_nexus=$no_nexus")
79-
jcenter()
8066
mavenCentral()
8167
} else {
8268
println("using nexus repositories")
@@ -107,74 +93,143 @@ repositories {
10793
}
10894

10995
group = 'org.ods'
110-
version = '0.1'
111-
mainClassName = "app.App"
112-
sourceCompatibility = 1.8
96+
version = '1.0'
11397

114-
dependencyManagement {
115-
imports {
116-
mavenBom "org.jooby:jooby-bom:$joobyVersion"
98+
java {
99+
toolchain {
100+
languageVersion.set(JavaLanguageVersion.of(11))
117101
}
118102
}
119103

104+
compileGroovy {
105+
groovyOptions.javaAnnotationProcessing = true
106+
}
107+
120108
dependencies {
121-
implementation "com.github.ben-manes.caffeine:caffeine:2.7.0"
122-
implementation "com.github.jknack:handlebars:4.1.2"
123-
implementation "commons-io:commons-io:2.11.0"
124-
implementation "io.github.openfeign:feign-core:10.2.3"
125-
implementation "io.github.openfeign:feign-gson:10.2.3"
126-
implementation "io.github.openfeign:feign-okhttp:10.2.3"
127-
implementation "net.lingala.zip4j:zip4j:1.3.3"
128-
implementation "org.apache.httpcomponents:httpclient:4.5.8"
129-
implementation "org.codehaus.groovy:groovy-all:2.5.7"
130-
implementation "org.jooby:jooby-jackson"
131-
implementation "org.jooby:jooby-netty"
132-
133-
implementation "io.netty:netty-transport-native-epoll:${dependencyManagement.importedProperties['netty.version']}:${osdetector.classifier.contains('linux') ? 'linux-x86_64' : ''}"
134-
implementation "io.netty:netty-tcnative-boringssl-static:${dependencyManagement.importedProperties['boringssl.version']}"
109+
implementation (group: 'org.codehaus.groovy', name: 'groovy-all', version: groovyallVersion){
110+
exclude group: "org.codehaus.groovy", module: "groovy-test-junit5"
111+
}
135112

113+
implementation "org.springframework.boot:spring-boot-starter:${springbootVersion}"
114+
implementation "org.springframework.boot:spring-boot-starter-web:${springbootVersion}"
115+
implementation "org.springframework.boot:spring-boot-starter-cache:${springbootVersion}"
116+
117+
implementation("javax.inject:javax.inject:1")
118+
implementation("javax.cache:cache-api:1.1.1")
119+
120+
implementation 'com.fasterxml.jackson.core:jackson-databind'
121+
implementation 'com.github.ben-manes.caffeine:caffeine:3.0.5'
122+
implementation 'com.github.jknack:handlebars:4.3.0'
123+
implementation 'commons-io:commons-io:2.11.0'
124+
implementation 'io.github.openfeign:feign-core:11.8'
125+
implementation 'io.github.openfeign:feign-gson:11.8'
126+
implementation 'io.github.openfeign:feign-okhttp:11.8'
127+
implementation 'net.lingala.zip4j:zip4j:2.9.1'
128+
implementation 'org.apache.httpcomponents:httpclient:4.5.13'
136129
implementation "org.apache.pdfbox:pdfbox:2.0.24"
137130

138-
testImplementation "junit:junit:4.12"
139-
testImplementation "com.github.stefanbirkner:system-rules:1.19.0" // for managing environment variables
140-
testImplementation "com.github.tomakehurst:wiremock:2.23.2" // for mocking HTTP server reponses
141-
testImplementation "io.rest-assured:rest-assured:4.0.0" // for validating REST services
142-
testImplementation "org.spockframework:spock-core:1.3-groovy-2.5"
131+
testImplementation "org.junit.jupiter:junit-jupiter-api"
132+
testImplementation "org.junit.jupiter:junit-jupiter-engine"
133+
testImplementation("uk.org.webcompere:system-stubs-core:1.2.0")
134+
testImplementation "org.testcontainers:spock:1.16.2"
135+
testImplementation("org.testcontainers:testcontainers:1.16.2")
143136

144-
testImplementation "cglib:cglib-nodep:3.3.0" // for mocking classes
145-
testImplementation "org.objenesis:objenesis:3.1"
146-
}
137+
testImplementation("org.spockframework:spock-core:${spockCoreVersion}")
138+
testImplementation ("com.athaydes:spock-reports:$spockReportsVersion"){ transitive = false }
139+
testImplementation "org.spockframework:spock-spring:${spockCoreVersion}"
140+
testImplementation "org.springframework.boot:spring-boot-starter-test:${springbootVersion}"
147141

148-
import com.github.jengelman.gradle.plugins.shadow.transformers.NewGroovyExtensionModuleTransformer
142+
testImplementation "com.github.stefanbirkner:system-rules:1.19.0"
143+
testImplementation 'com.github.tomakehurst:wiremock:2.27.2'
144+
testImplementation 'io.rest-assured:rest-assured:4.4.0'
149145

150-
shadowJar {
151-
mergeServiceFiles()
152-
mergeGroovyExtensionModules()
153-
transform(NewGroovyExtensionModuleTransformer)
146+
gatlingImplementation 'org.awaitility:awaitility:4.1.1'
147+
gatlingImplementation 'io.rest-assured:rest-assured:4.4.0'
154148
}
155149

156150
test {
157-
outputs.dir snippetsDir
158-
159-
// Use overrides in conf/application.test.conf in ConfigFactory.load()
160-
// TODO: setting application.env should be enough, but apparently isn't
161-
systemProperty "application.env", "test"
162-
systemProperty "config.resource", "application.test.conf"
163-
164151
testLogging {
165152
showStandardStreams = true
153+
exceptionFormat = 'full'
166154
}
155+
filter {
156+
includeTestsMatching "*Spec"
157+
}
158+
systemProperty 'com.athaydes.spockframework.report.outputDir', 'build/reports/spock'
159+
maxHeapSize = "2048m"
160+
jvmArgs "-XX:MaxPermSize=256m"
161+
useJUnitPlatform()
167162

168163
finalizedBy jacocoTestReport
169164
}
170165

166+
task dockerTest(type: Test) {
167+
dependsOn(test)
168+
group("verification")
169+
filter {
170+
includeTestsMatching "*IT"
171+
}
172+
systemProperty 'com.athaydes.spockframework.report.outputDir', 'build/reports/spock'
173+
useJUnitPlatform()
174+
}
175+
171176
jacocoTestReport {
177+
dependsOn test
172178
reports {
173179
xml.enabled true
180+
html.enabled true
181+
}
182+
}
183+
184+
jacocoTestCoverageVerification {
185+
dependsOn jacocoTestReport
186+
violationRules {
187+
rule {
188+
limit {
189+
minimum = 0.7
190+
}
191+
}
174192
}
175193
}
176194

177-
/** We diverge from the default resources structure to adopt the Jooby standard: */
178-
sourceSets.main.resources {
179-
srcDirs = ["conf", "public"]
195+
import com.bmuschko.gradle.docker.tasks.image.*
196+
task buildImage(type: DockerBuildImage) {
197+
inputDir = file("src/main/resources")
198+
images.add('docgen-base:latest')
199+
}
200+
201+
docker {
202+
springBootApplication {
203+
baseImage = 'docgen-base:latest'
204+
ports = [9090, 8080]
205+
images = ['ods-document-generation-svc:local']
206+
jvmArgs = ["-XX:+UseCompressedOops", "-XX:+UseG1GC", "-XX:MaxGCPauseMillis=100"]
207+
}
180208
}
209+
buildImage.dependsOn(bootJar)
210+
dockerBuildImage.dependsOn(buildImage)
211+
dockerTest.dependsOn(dockerBuildImage)
212+
213+
import com.bmuschko.gradle.docker.tasks.container.*
214+
215+
task createDocGenServer(type: DockerCreateContainer) {
216+
dependsOn dockerBuildImage
217+
targetImageId dockerBuildImage.getImageId()
218+
hostConfig.portBindings = ['8080:8080']
219+
hostConfig.autoRemove = true
220+
}
221+
222+
task startDocGenServer(type: DockerStartContainer) {
223+
dependsOn createDocGenServer
224+
targetContainerId createDocGenServer.getContainerId()
225+
}
226+
227+
task stopDocGenServer(type: DockerStopContainer) {
228+
targetContainerId createDocGenServer.getContainerId()
229+
}
230+
231+
gatlingRun.group("verification")
232+
gatlingRun.dependsOn(dockerTest, startDocGenServer)
233+
gatlingRun.finalizedBy(stopDocGenServer)
234+
235+
check.dependsOn(jacocoTestCoverageVerification, gatlingRun)

buildSrc/build.gradle

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)