Skip to content

Commit

Permalink
enabling code coverage from e2e tests as well
Browse files Browse the repository at this point in the history
  • Loading branch information
kmrdhruv committed Jul 12, 2023
1 parent d87a969 commit e566b40
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
with:
gradle-version: 5.6.4
- name: Execute Gradle build
run: ./gradlew clean build copyDependencies
- name: Build the Docker image
run: ./gradlew clean build copyDependencies :server:copyJacocoAgent -x test
- name: Build the Varadhi Docker image
run: docker build . --file setup/docker/Dockerfile --tag varadhi.docker.registry/varadhi:latest --build-arg ENV=test
- name: Setup the environment
run: docker compose --profile test -f setup/docker/compose.yml up -d --wait --wait-timeout 180
Expand All @@ -50,6 +50,9 @@ jobs:
uses: jwalton/gh-docker-logs@v2
with:
images: 'varadhi.docker.registry/varadhi,apachepulsar/pulsar,zookeeper'

- name: Restart the server process to force the code coverage dump
run: docker exec docker-web-1 pkill java
- name: Generate Code Coverage report
run: ./gradlew jacocoTestReport
- name: Publish code coverage (uses CodeCov.io)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ tasks.withType(JacocoReport).configureEach {
}
getSourceDirectories().from(sourceSets.main.allSource.srcDirs)
getClassDirectories().from(sourceSets.main.output)
getExecutionData().from(layout.buildDirectory.files().findAll { it.name.endsWith('.exec') })
getExecutionData().from(fileTree(buildDir).include("/jacoco/*.exec"))
}

tasks.withType(Test).configureEach {
Expand Down
9 changes: 8 additions & 1 deletion server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
id 'com.flipkart.varadhi.java-application-conventions'
}

def jacoco_ver = "0.8.10"

dependencies {

Expand Down Expand Up @@ -48,10 +49,16 @@ dependencies {
testE2EImplementation("javax.ws.rs:javax.ws.rs-api")
testE2EImplementation("org.glassfish.jersey.core:jersey-client")
testE2EImplementation("org.glassfish.jersey.media:jersey-media-json-jackson")

testE2ERuntime("org.jacoco:org.jacoco.agent:$jacoco_ver:runtime")
runtimeOnly project(':pulsar')
}

task copyJacocoAgent(type: Copy) {
from configurations.testE2ERuntime.find { it.name.contentEquals("org.jacoco.agent-$jacoco_ver-runtime.jar") }
into "$buildDir/jacoco"
rename("org.jacoco.agent-$jacoco_ver-runtime.jar", "org.jacoco.agent-runtime.jar")
}

application {
mainClass = 'com.flipkart.varadhi.Server'
}
Expand Down
4 changes: 4 additions & 0 deletions setup/docker/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ services:
web:
image: varadhi.docker.registry/varadhi:latest
profiles: [ "test", "service" ]
environment:
- JAVA_TOOL_OPTIONS=-javaagent:/jacoco/org.jacoco.agent-runtime.jar=destfile=/jacoco/testE2E.exec
networks:
hostnet:
ipv4_address: 10.5.5.2
ports:
- 8080:8080
volumes:
- ../../server/build/jacoco:/jacoco
restart: "no"
healthcheck:
test: curl -s http://localhost:8080/v1/health-check | grep iam_ok
Expand Down

0 comments on commit e566b40

Please sign in to comment.