Skip to content

Commit

Permalink
ci: enable code coverage with jacoco and coveralls (#94)
Browse files Browse the repository at this point in the history
* ci: enable code coverage with jacoco and coveralls

* ci: compile and copy the .class for running

* ci: fix using coveralls

* ci: remove settings in the mvn command

* ci: add jacoco when testing
  • Loading branch information
danglotb committed Jun 21, 2021
1 parent 4672b2f commit 3541dd9
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 4 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/mvn-build-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,21 @@ jobs:
java-version: '8'
distribution: 'adopt'
- name: Build with Maven
run: mvn install -DskipTests
run: ./src/update-classes-in-resources.sh
- name: Export Maven Home
run: export MAVEN_HOME=`mvn --version | grep 'Maven home' | sed -e 's/Maven h.* //'` && echo "🎉 ${MAVEN_HOME} "
- name: Prepare resources binaries
run: ./src/compile-and-clean-test-projects.sh
- name: Test with Maven
run: mvn test

- name: Test and Coverage with Maven
run: mvn test jacoco:report
- name: "Report: Coverage via coveralls.io"
run: |
export CI_BRANCH=${BRANCH_NAME_OR_REF#refs/heads/}
export CI_PULL_REQUEST=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
mvn coveralls:report --no-transfer-progress -DrepoToken=$COVERALLS_SECRET
env:
CI_NAME: github
BRANCH_NAME_OR_REF: ${{ github.head_ref || github.ref }}
CI_BUILD_NUMBER: ${{ github.run_id }}
CI_BUILD_URL: https://github.com/${{ github.repository }}/commit/${{ github.event.after }}/checks
COVERALLS_SECRET: ${{ secrets.GITHUB_TOKEN }}
44 changes: 44 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,55 @@
</dependencies>
</plugin>

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.5.201505241946</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>

<pluginManagement>
<plugins>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>4.3.0</version>
</plugin>
</plugins>
</pluginManagement>

</build>



<profiles>
<profile>
<id>coveralls</id>
<build>
<plugins>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>4.3.0</version>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>release</id>
<build>
Expand Down

0 comments on commit 3541dd9

Please sign in to comment.