Skip to content

Commit e43e60b

Browse files
author
Flossy
committed
Add JaCoCo with 100% coverage requirement and auto-versioning workflow
1 parent a454b04 commit e43e60b

2 files changed

Lines changed: 61 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,32 @@ jobs:
2424
java-version: ${{ matrix.java }}
2525
cache: 'maven'
2626

27+
- name: Configure Git for version bumps
28+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
29+
run: |
30+
git config user.name "Version Bump"
31+
git config user.email "version-bump@flossware.org"
32+
33+
- name: Auto-increment version
34+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
35+
run: |
36+
mvn -U build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion} versions:commit
37+
2738
- name: Build with Maven
2839
run: mvn -B clean verify
2940

3041
- name: Run tests
3142
run: mvn -B test
3243

44+
- name: Commit and tag version
45+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
46+
run: |
47+
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
48+
git add pom.xml
49+
git commit -m "Automated Version Bump ${VERSION} [ci skip]"
50+
git tag "${VERSION}"
51+
git push origin main --tags
52+
3353
- name: Generate test report
3454
if: always()
3555
run: mvn surefire-report:report-only

pom.xml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,47 @@
6565
<artifactId>maven-surefire-plugin</artifactId>
6666
<version>3.1.2</version>
6767
</plugin>
68+
<plugin>
69+
<groupId>org.jacoco</groupId>
70+
<artifactId>jacoco-maven-plugin</artifactId>
71+
<version>0.8.10</version>
72+
<executions>
73+
<execution>
74+
<id>prepare-agent</id>
75+
<goals>
76+
<goal>prepare-agent</goal>
77+
</goals>
78+
</execution>
79+
<execution>
80+
<id>report</id>
81+
<phase>test</phase>
82+
<goals>
83+
<goal>report</goal>
84+
</goals>
85+
</execution>
86+
<execution>
87+
<id>jacoco-check</id>
88+
<phase>verify</phase>
89+
<goals>
90+
<goal>check</goal>
91+
</goals>
92+
<configuration>
93+
<rules>
94+
<rule>
95+
<element>PACKAGE</element>
96+
<limits>
97+
<limit>
98+
<counter>LINE</counter>
99+
<value>COVEREDRATIO</value>
100+
<minimum>1.00</minimum>
101+
</limit>
102+
</limits>
103+
</rule>
104+
</rules>
105+
</configuration>
106+
</execution>
107+
</executions>
108+
</plugin>
68109
<plugin>
69110
<groupId>org.apache.maven.plugins</groupId>
70111
<artifactId>maven-source-plugin</artifactId>

0 commit comments

Comments
 (0)