Skip to content

Commit

Permalink
Fix test setup gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghost-in-a-Jar committed May 24, 2023
1 parent a138279 commit 70a426f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 30 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,22 @@ jobs:
key: v1-${{ runner.os }}-gradle-${{ github.ref }}-${{ github.sha }}

- name: Test with coverage
run: ./gradlew --build-cache jacocoTestReport --scan
run: ./gradlew --build-cache unitTest jacocoTestReport --scan

- name: Configure pact
env:
PACTBROKER_APPLICATION_YAML_B64: ${{ secrets.PACTBROKER_APPLICATION_YAML_B64 }}
run: |
mkdir -p ./service/src/test/resources
echo $PACTBROKER_APPLICATION_YAML_B64 | base64 --decode >> ./service/src/test/resources/application-test.yml
echo $PACTBROKER_APPLICATION_YAML_B64 | base64 --decode >> ./service/src/test/resources/application.yml
- name: Verify pacts
env:
PACT_BROKER_URL: https://pact-broker.dsp-eng-tools.broadinstitute.org
PACT_PROVIDER_COMMIT: (git rev-parse HEAD)
PACT_PROVIDER_BRANCH: $(git rev-parse --abbrev-ref HEAD)
PACT_BROKER_USERNAME: ${{ secrets.PACT_BROKER_USERNAME }}
PACT_BROKER_PASSWORD: ${{ secrets.PACT_BROKER_PASSWORD }}
PACT_BROKER_USERNAME: ${{ env.PACT_BROKER_USERNAME }}
PACT_BROKER_PASSWORD: ${{ env.PACT_BROKER_PASSWORD }}
run: |
./gradlew --build-cache verifyPacts
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ DrsHub uses Gradle as a build tool. Some common Gradle commands you may want to
```shell
./gradlew generateSwaggerCode # Generate Swagger code for models and Swagger UI
./gradlew bootRun # Run DrsHub locally (Swagger UI at localhost:8080)
./gradlew test # Run the unit tests
./gradlew unitTest # Run the unit tests
./gradlew jib # Build the DrsHub Docker image
```

Expand Down
21 changes: 18 additions & 3 deletions service/analysis.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ jacocoTestReport {
xml.required = true
}

dependsOn test

// https://www.baeldung.com/jacoco-report-exclude#2-gradle-configuration
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
Expand Down Expand Up @@ -35,9 +33,26 @@ task runMinnieKenny(type: Exec) {
commandLine './minnie-kenny.sh'
}

test {
task unitTest(type: Test) {
dependsOn runMinnieKenny
useJUnitPlatform()
filter {
excludeTestsMatching "*VerifyPacts*"
}
}

task verifyPacts(type: Test) {
useJUnitPlatform()
systemProperty 'pact.provider.version', System.getenv('PACT_PROVIDER_COMMIT')
systemProperty 'pact.provider.branch', System.getenv('PACT_PROVIDER_BRANCH')
systemProperty 'pact.verifier.publishResults', true
systemProperty 'pactbroker.host', System.getenv('PACT_BROKER_URL')
systemProperty 'pactbroker.auth.username', System.getenv('PACT_BROKER_USERNAME')
systemProperty 'pactbroker.auth.password', System.getenv('PACT_BROKER_PASSWORD')
systemProperty 'pactbroker.scheme', 'https'

filter {
includeTestsMatching "*VerifyPacts*"
}
}

15 changes: 0 additions & 15 deletions service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,3 @@ sonarqube {
}
}

tasks.register('verifyPacts', Test) {
useJUnitPlatform()
systemProperty 'pact.provider.version', System.getenv('PACT_PROVIDER_COMMIT')
systemProperty 'pact.provider.branch', System.getenv('PACT_PROVIDER_BRANCH')
systemProperty 'pact.verifier.publishResults', true
systemProperty 'pactbroker.host', System.getenv('PACT_BROKER_URL')
systemProperty 'pactbroker.auth.username', System.getenv('PACT_BROKER_USERNAME')
systemProperty 'pactbroker.auth.password', System.getenv('PACT_BROKER_PASSWORD')
systemProperty 'pactbroker.scheme', 'https'

filter {
includeTestsMatching "*VerifyPacts*"
}
}

7 changes: 0 additions & 7 deletions service/spring.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ dependencies {
testImplementation 'org.mockito:mockito-inline:5.2.0'
}

test {
useJUnitPlatform()
filter {
excludeTestsMatching "*VerifyPacts*"
}
}

task bootRunDev {
bootRun.configure { systemProperty 'spring.profiles.active', 'human-readable-logging' }
finalizedBy(bootRun)
Expand Down

0 comments on commit 70a426f

Please sign in to comment.