Skip to content

Commit

Permalink
chore: ci
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Sep 25, 2024
1 parent 3835fbb commit c3fd1e6
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 71 deletions.
43 changes: 1 addition & 42 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ jobs:
actions: read
contents: read
strategy:
#max-parallel: 3
fail-fast: false
matrix:
java: [ '17', '21' ]
Expand All @@ -19,59 +18,19 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: "Setup Git"
shell: bash
run: |
git branch -a
for branch in $(
git branch -a \
| grep '^\s*remotes' \
| egrep --invert-match '(:?HEAD|remotes/pull/[0-9]+/merge)$' \
| sed -e "s/^.*remotes\/origin\///"
); do
echo setting up $branch
git checkout $branch
git checkout -
done
git branch -a
git remote remove origin
git remote add origin [email protected]:${GITHUB_REPOSITORY}.git
git remote -v
fetch-depth: '1'
- name: Setup java
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: ${{ matrix.java }}
- name: prepare Gradle
shell: bash
run: |
mkdir -p ~/.gradle && echo "org.gradle.daemon=false" >> ~/.gradle/gradle.properties
- name: Check formatting
shell: bash
run: |
./gradlew --no-daemon spotlessJavaCheck
- name: "Gradle build"
shell: bash
run: |
java -version
javac -version
./gradlew --no-daemon build
- name: Transorm static code analysis to SARIF
if: ${{ (success() || failure()) }}
run: |
npx violations-command-line -sarif sarif-report.json \
-v "FINDBUGS" "." ".*build/reports/spotbugs/main\.xml$" "Spotbugs" \
-v "CHECKSTYLE" "." ".*build/reports/checkstyle/main\.xml$" "Checkstyle" \
-v "PMD" "." ".*build/reports/pmd/main\.xml$" "PMD" \
-v "JUNIT" "." ".*/build/test-results/test/TEST-.*\.xml$" "JUNIT"
- uses: github/codeql-action/upload-sarif@v3
if: ${{ (success() || failure()) }}
with:
sarif_file: sarif-report.json
category: violations-lib

- name: Publish Build
uses: actions/upload-artifact@v4
if: failure()
Expand Down
83 changes: 69 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,30 +1,85 @@
apply plugin: 'java-library'

buildscript {
repositories {
maven { url "https://oss.sonatype.org" }
maven { url "https://plugins.gradle.org/m2/" }
mavenCentral()
mavenLocal()
}
dependencies {
classpath 'se.bjurr.gradle:gradle-scripts:2.+'
classpath "org.wiremock.tools.gradle:extension-convention-plugin:0.3.0"
classpath 'se.bjurr.gitchangelog:git-changelog-lib:1.175.2'
}
}

plugins {
id 'idea'
id 'eclipse'
id 'project-report'
id 'com.diffplug.spotless' version '6.25.0'
id 'org.wiremock.tools.gradle.wiremock-extension-convention' version '0.3.0'
}

def bumpVersionTo(version) {
def propertyFile = new File("$projectDir/gradle.properties")
def gradleProps = new Properties()
propertyFile.withReader { gradleProps.load(it) }
gradleProps.setProperty('version', version)
propertyFile.withWriter { gradleProps.store(it, null) }
}

task setConventionalVersion() {
doFirst {
def nextVersion = se.bjurr.gitchangelog.api.GitChangelogApi.gitChangelogApiBuilder()
.withFromRepo(file('.'))
.withSemanticMajorVersionPattern("^[Bb]reak")
.withSemanticMinorVersionPattern("^[Ff]eat")
.getNextSemanticVersion()
.getVersion();
def nextSnapshot = "${nextVersion}-SNAPSHOT"
logger.lifecycle("Setting version ${nextSnapshot}...")
bumpVersionTo(nextSnapshot)
}
}

allprojects {
repositories {
mavenLocal()
mavenCentral()
}

apply plugin: 'java-library'
sourceCompatibility = 17
targetCompatibility = 17

project.ext.buildConfig = [
repoType: "DEFAULT",
sourceCompatibility: 17,
targetCompatibility: 17,
staticCodeAnalysis: [
maxViolations: 0
]
]
apply from: project.buildscript.classLoader.getResource('main.gradle').toURI()
apply plugin: 'com.diffplug.spotless'
spotless {
java {
target 'src/**/*.java'
googleJavaFormat('1.17.0')
ratchetFrom 'origin/main'
trimTrailingWhitespace()
endWithNewline()
targetExclude '**/Tmp*.java'
}
groovyGradle {
target '**/*.gradle'
greclipse()
indentWithSpaces(2)
trimTrailingWhitespace()
endWithNewline()
}
json {
target 'src/**/*.json'
targetExclude '**/tmp*.json', 'src/test/resources/sample.json', 'src/main/resources/swagger/*.json', 'src/test/resources/filesource/subdir/deepfile.json', 'src/test/resources/schema-validation/*.json'
simple().indentWithSpaces(2)
}
}

test {
useJUnitPlatform()
testLogging {
events "PASSED", "FAILED", "SKIPPED"
exceptionFormat "full"
}
}

dependencies {
Expand All @@ -42,7 +97,7 @@ project('wiremock-spring-boot', {
api "org.springframework.boot:spring-boot-test:3.3.4"
api "org.springframework:spring-test:6.1.13"
api "org.slf4j:slf4j-api:2.0.16"
api "org.junit.jupiter:junit-jupiter-api:5.11.0"
api "org.junit.jupiter:junit-jupiter-api:5.11.0"
}
})

Expand Down
18 changes: 12 additions & 6 deletions example/src/test/resources/custom-location/mappings/todos.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@
"url": "/"
},
"response": {
"status": 200,
"headers": {"Content-Type": "application/json"},
"jsonBody": [
{ "id": 1, "userId": 1, "title": "custom location todo 1" },
{ "id": 2, "userId": 1, "title": "custom location todo 2" }
{
"id": 1,
"title": "custom location todo 1",
"userId": 1
},
{
"id": 2,
"title": "custom location todo 2",
"userId": 1
}
],
"headers": {
"Content-Type": "application/json"
}
"status": 200
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
"url": "/1"
},
"response": {
"status": 200,
"jsonBody": { "id": 1, "name": "Jenna" },
"headers": {
"Content-Type": "application/json"
}
"headers": {"Content-Type": "application/json"},
"jsonBody": {
"name": "Jenna",
"id": 1
},
"status": 200
}
}
4 changes: 2 additions & 2 deletions example/src/test/wiremock-mappings/mappings/get.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"url": "/wiremockmappingsmock"
},
"response": {
"status": 200,
"jsonBody": { "wiremockmappingsmock": "yes" }
"jsonBody": {"wiremockmappingsmock": "yes"},
"status": 200
}
}
10 changes: 8 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
description="WireMock integration for Spring Boot."
version=1.0.0
#Wed Sep 25 17:54:02 CEST 2024
baseArtifact=wiremock-spring-boot
developer.id=tomasbjerre
githubRepo=wiremock-spring-boot
description=WireMock integration for Spring Boot.
developer.name=Tomas Bjerre
developer.email=[email protected]
version=3.0.0-SNAPSHOT
group=org.wiremock.spring

0 comments on commit c3fd1e6

Please sign in to comment.