Skip to content

Commit c4f2d02

Browse files
Add Jacoco coverage configuration and GitHub workflow for Codecov
- Configure jacoco-maven-plugin in org.moreunit.build/pom.xml with a coverage profile. - Add .github/workflows/coverage.yml to automate coverage report generation and upload to Codecov. - Add Codecov badge to README.md. Co-authored-by: RoiSoleil <3462260+RoiSoleil@users.noreply.github.com>
1 parent 538b845 commit c4f2d02

3 files changed

Lines changed: 100 additions & 3 deletions

File tree

.github/workflows/coverage.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Coverage
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
permissions: write-all
10+
11+
jobs:
12+
build:
13+
14+
runs-on: windows-latest
15+
16+
steps:
17+
- name: Checkout 🛎
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Java ☕️
21+
uses: actions/setup-java@v4
22+
with:
23+
distribution: 'temurin'
24+
java-version: '21'
25+
cache: 'maven'
26+
27+
- name: Setup Maven
28+
uses: stCarolas/setup-maven@v4.5
29+
with:
30+
maven-version: 3.9.4
31+
32+
- name: Build with Coverage
33+
run: mvn -file org.moreunit.build/pom.xml clean install -Pcoverage "-Dtarget.platform.classifier=eclipse-latest" --fail-at-end --batch-mode --strict-checksums --update-snapshots "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"
34+
35+
- name: Upload coverage to Codecov
36+
uses: codecov/codecov-action@v5
37+
with:
38+
files: ./org.moreunit.build/target/site/jacoco-aggregate/jacoco.xml
39+
verbose: true
40+
fail_ci_if_error: true
41+
token: ${{ secrets.CODECOV_TOKEN }}

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
# MoreUnit For Eclipse
44

5+
[![codecov](https://codecov.io/gh/MoreUnit/MoreUnit-Eclipse/branch/master/graph/badge.svg)](https://codecov.io/gh/MoreUnit/MoreUnit-Eclipse)
6+
57
<img alt="MoreUnit Logo" src="https://moreunit.github.io/MoreUnit-Eclipse/img/logo.png" />
68

79
MoreUnit is an Eclipse plugin that should assist you in writing more unit tests.

org.moreunit.build/pom.xml

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<tycho-version>4.0.12</tycho-version>
2727
<exec-maven-version>3.5.0</exec-maven-version>
2828
<surefire-version>3.5.3</surefire-version>
29+
<jacoco.version>0.8.14</jacoco.version>
2930

3031
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3132
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
@@ -99,11 +100,14 @@
99100
<showEclipseLog>true</showEclipseLog>
100101
<skipAfterFailureCount>10</skipAfterFailureCount>
101102
<providerHint>junit4</providerHint>
102-
<argLine>
103-
--add-opens java.base/java.lang=ALL-UNNAMED
104-
</argLine>
103+
<argLine>@{argLine} --add-opens java.base/java.lang=ALL-UNNAMED</argLine>
105104
</configuration>
106105
</plugin>
106+
<plugin>
107+
<groupId>org.jacoco</groupId>
108+
<artifactId>jacoco-maven-plugin</artifactId>
109+
<version>${jacoco.version}</version>
110+
</plugin>
107111
<plugin>
108112
<groupId>org.eclipse.tycho</groupId>
109113
<artifactId>tycho-p2-director-plugin</artifactId>
@@ -264,6 +268,56 @@
264268
</build>
265269

266270
<profiles>
271+
<profile>
272+
<id>coverage</id>
273+
<build>
274+
<plugins>
275+
<plugin>
276+
<groupId>org.jacoco</groupId>
277+
<artifactId>jacoco-maven-plugin</artifactId>
278+
<executions>
279+
<execution>
280+
<id>prepare-agent</id>
281+
<goals>
282+
<goal>prepare-agent</goal>
283+
</goals>
284+
</execution>
285+
<execution>
286+
<id>merge-all</id>
287+
<phase>verify</phase>
288+
<goals>
289+
<goal>merge</goal>
290+
</goals>
291+
<inherited>false</inherited>
292+
<configuration>
293+
<fileSets>
294+
<fileSet>
295+
<directory>${project.basedir}/..</directory>
296+
<includes>
297+
<include>**/target/jacoco.exec</include>
298+
</includes>
299+
</fileSet>
300+
</fileSets>
301+
<destFile>${project.build.directory}/jacoco-all.exec</destFile>
302+
</configuration>
303+
</execution>
304+
<execution>
305+
<id>report-aggregate</id>
306+
<phase>verify</phase>
307+
<goals>
308+
<goal>report-aggregate</goal>
309+
</goals>
310+
<inherited>false</inherited>
311+
<configuration>
312+
<dataFile>${project.build.directory}/jacoco-all.exec</dataFile>
313+
<outputDirectory>${project.build.directory}/site/jacoco-aggregate</outputDirectory>
314+
</configuration>
315+
</execution>
316+
</executions>
317+
</plugin>
318+
</plugins>
319+
</build>
320+
</profile>
267321
<profile>
268322
<!-- makes test run in UI thread when under OSX -->
269323
<id>osx</id>

0 commit comments

Comments
 (0)