Skip to content

Commit a0c1eb1

Browse files
authored
Merge pull request #114 from cicirello/prep-release
Prepare release 2.9.0
2 parents 43849d8 + 4f9842f commit a0c1eb1

File tree

3 files changed

+98
-10
lines changed

3 files changed

+98
-10
lines changed

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## [Unreleased] - 2023-05-24
88

99
### Added
10-
* Support for glob patterns in GitHub Actions mode for specifying multiple JaCoCo reports for multi-module projects (note: CLI mode already supported this indirectly since the shell expands globs automatically).
1110

1211
### Changed
1312

@@ -17,6 +16,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1716

1817
### Fixed
1918

19+
### Dependencies
20+
21+
### CI/CD
22+
23+
24+
## [2.9.0] - 2023-05-24
25+
26+
### Added
27+
* Support for glob patterns in GitHub Actions mode for specifying multiple JaCoCo reports for multi-module projects (note: CLI mode already supported this indirectly since the shell expands globs automatically).
28+
2029
### Dependencies
2130
* Bump cicirello/pyaction from 4.11.1 to 4.19.0, including upgrading Python within the Docker container to 3.11.
2231

README.md

Lines changed: 86 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,17 @@ and in particular see the [Multi-Module Example Workflows](#multi-module-example
276276
for an example of how to do this. Multi-module support is limited to cases where
277277
each module has its own test coverage report, and where those reports don't overlap.
278278

279+
You can also use a glob pattern to specify the set of JaCoCo reports for your modules.
280+
For example, `jacoco-csv-file: "**/jacoco.csv"` will match all `jacoco.csv` files found
281+
across all directories within your project. Or for example `jacoco-csv-file: "**/*.csv"`
282+
will match all `csv` files found within your project, but be careful with such a pattern
283+
if your project has other `csv` files that are not JaCoCo reports. Or as another example,
284+
maybe all of your JaCoCo reports are in the same directory, but with names with numbers.
285+
The pattern `jacoco-csv-file: "target/site/jacoco/module*.csv"` will match all `csv` files
286+
in the directory `target/site/jacoco/` whose name begins with `module`. Note that in all of
287+
these examples you need the quotes around the glob pattern or else GitHub Actions will
288+
give you an error that your workflow file is invalid.
289+
279290
The action assumes that all reports passed via this input are
280291
independent of each other. If you are using matrix testing, such that
281292
each group of tests produces a report, and where the groups overlap in what
@@ -556,7 +567,7 @@ along the lines of the following:
556567
<plugin>
557568
<groupId>org.jacoco</groupId>
558569
<artifactId>jacoco-maven-plugin</artifactId>
559-
<version>0.8.8</version>
570+
<version>0.8.10</version>
560571
<executions>
561572
<execution>
562573
<goals>
@@ -578,7 +589,7 @@ along the lines of the following:
578589

579590
Note that the jacoco-badge-generator action has been tested with
580591
the `jacoco.csv` files generated by `jacoco-maven-plugin` versions
581-
0.8.6 through 0.8.8, and has not been tested with earlier versions
592+
0.8.6 through 0.8.10, and has not been tested with earlier versions
582593
of JaCoCo.
583594

584595
##### Running JaCoCo via Gradle
@@ -648,7 +659,7 @@ You can also use a specific release with:
648659
649660
```yml
650661
- name: Generate JaCoCo Badge
651-
uses: cicirello/jacoco-badge-generator@v2.8.0
662+
uses: cicirello/jacoco-badge-generator@v2.9.0
652663
with:
653664
generate-branches-badge: true
654665
```
@@ -728,7 +739,7 @@ jobs:
728739
- name: Set up the Java JDK
729740
uses: actions/setup-java@v2
730741
with:
731-
java-version: '11'
742+
java-version: '17'
732743
distribution: 'adopt'
733744
734745
- name: Build with Maven
@@ -786,7 +797,7 @@ jobs:
786797
- name: Set up the Java JDK
787798
uses: actions/setup-java@v2
788799
with:
789-
java-version: '11'
800+
java-version: '17'
790801
distribution: 'adopt'
791802

792803
- name: Build with Maven
@@ -846,7 +857,7 @@ jobs:
846857
- name: Set up the Java JDK
847858
uses: actions/setup-java@v2
848859
with:
849-
java-version: '11'
860+
java-version: '17'
850861
distribution: 'adopt'
851862
852863
- name: Build with Maven
@@ -878,7 +889,62 @@ jobs:
878889
fi
879890
```
880891

881-
#### Example Workflow 4: Multi-Module Project with Separate Badges for Each Module.
892+
#### Example Workflow 4: Glob Pattern to Specify Reports of a Multi-Module Project.
893+
894+
This example workflow uses a glob pattern to specify the reports of a multi-module project,
895+
and generates both badges (instructions coverage percentage and branches coverage percentage).
896+
The badges that are generated are computed over all modules. In this example, all of the JaCoCo
897+
reports are named `jacoco.csv` but reside in different directories. You can match all of them
898+
with `jacoco-csv-file: "**/jacoco.csv"`. The quotes around the glob are required to avoid an
899+
invalid workflow error from GitHub Actions.
900+
901+
```yml
902+
name: build
903+
904+
on:
905+
push:
906+
branches: [ main ]
907+
908+
jobs:
909+
build:
910+
runs-on: ubuntu-latest
911+
912+
steps:
913+
- uses: actions/checkout@v2
914+
915+
- name: Set up the Java JDK
916+
uses: actions/setup-java@v2
917+
with:
918+
java-version: '17'
919+
distribution: 'adopt'
920+
921+
- name: Build with Maven
922+
run: mvn -B test
923+
924+
- name: Generate JaCoCo Badge
925+
id: jacoco
926+
uses: cicirello/jacoco-badge-generator@v2
927+
with:
928+
generate-branches-badge: true
929+
jacoco-csv-file: "**/jacoco.csv"
930+
931+
- name: Log coverage percentage
932+
run: |
933+
echo "coverage = ${{ steps.jacoco.outputs.coverage }}"
934+
echo "branch coverage = ${{ steps.jacoco.outputs.branches }}"
935+
936+
- name: Commit the badge (if it changed)
937+
run: |
938+
if [[ `git status --porcelain` ]]; then
939+
git config --global user.name 'YOUR NAME HERE'
940+
git config --global user.email 'YOUR-GITHUB-USERID@users.noreply.github.com'
941+
git add -A
942+
git commit -m "Autogenerated JaCoCo coverage badge"
943+
git push
944+
fi
945+
```
946+
947+
#### Example Workflow 5: Multi-Module Project with Separate Badges for Each Module.
882948
883949
If you would prefer to generate separate coverage badges for each of the
884950
modules of a multi-module project, then just include multiple steps of the
@@ -907,7 +973,7 @@ jobs:
907973
- name: Set up the Java JDK
908974
uses: actions/setup-java@v2
909975
with:
910-
java-version: '11'
976+
java-version: '17'
911977
distribution: 'adopt'
912978
913979
- name: Build with Maven
@@ -1111,6 +1177,18 @@ something like:
11111177
python3 -m jacoco_badge_generator --jacoco-csv-file reports/report1.csv reports/report2.csv
11121178
```
11131179

1180+
In CLI mode, glob patterns will be handled by your shell. You can accomplish the above with:
1181+
1182+
```Shell
1183+
python3 -m jacoco_badge_generator --jacoco-csv-file reports/report*.csv
1184+
```
1185+
1186+
Or perhaps all of your reports are named `jacoco.csv` but in different directories, then you can
1187+
match all of them with:
1188+
1189+
```Shell
1190+
python3 -m jacoco_badge_generator --jacoco-csv-file **/jacoco.csv
1191+
```
11141192

11151193
## Summary of Input Defaults
11161194

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "jacoco-badge-generator"
7-
version = "2.8.1"
7+
version = "2.9.0"
88
authors = [
99
{ name="Vincent A. Cicirello", email="development@cicirello.org" },
1010
]
@@ -46,6 +46,7 @@ exclude = [
4646
"/.github",
4747
"/images",
4848
"/src/entrypoint.py",
49+
"/tests",
4950
"/.dockerignore",
5051
"/action.yml",
5152
"/Dockerfile",

0 commit comments

Comments
 (0)