Skip to content

Commit

Permalink
Merge pull request #114 from cicirello/prep-release
Browse files Browse the repository at this point in the history
Prepare release 2.9.0
  • Loading branch information
cicirello authored May 24, 2023
2 parents 43849d8 + 4f9842f commit a0c1eb1
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 10 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] - 2023-05-24

### Added
* 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).

### Changed

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

### Fixed

### Dependencies

### CI/CD


## [2.9.0] - 2023-05-24

### Added
* 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).

### Dependencies
* Bump cicirello/pyaction from 4.11.1 to 4.19.0, including upgrading Python within the Docker container to 3.11.

Expand Down
94 changes: 86 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,17 @@ and in particular see the [Multi-Module Example Workflows](#multi-module-example
for an example of how to do this. Multi-module support is limited to cases where
each module has its own test coverage report, and where those reports don't overlap.

You can also use a glob pattern to specify the set of JaCoCo reports for your modules.
For example, `jacoco-csv-file: "**/jacoco.csv"` will match all `jacoco.csv` files found
across all directories within your project. Or for example `jacoco-csv-file: "**/*.csv"`
will match all `csv` files found within your project, but be careful with such a pattern
if your project has other `csv` files that are not JaCoCo reports. Or as another example,
maybe all of your JaCoCo reports are in the same directory, but with names with numbers.
The pattern `jacoco-csv-file: "target/site/jacoco/module*.csv"` will match all `csv` files
in the directory `target/site/jacoco/` whose name begins with `module`. Note that in all of
these examples you need the quotes around the glob pattern or else GitHub Actions will
give you an error that your workflow file is invalid.

The action assumes that all reports passed via this input are
independent of each other. If you are using matrix testing, such that
each group of tests produces a report, and where the groups overlap in what
Expand Down Expand Up @@ -556,7 +567,7 @@ along the lines of the following:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.8</version>
<version>0.8.10</version>
<executions>
<execution>
<goals>
Expand All @@ -578,7 +589,7 @@ along the lines of the following:

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

##### Running JaCoCo via Gradle
Expand Down Expand Up @@ -648,7 +659,7 @@ You can also use a specific release with:
```yml
- name: Generate JaCoCo Badge
uses: cicirello/jacoco-badge-generator@v2.8.0
uses: cicirello/jacoco-badge-generator@v2.9.0
with:
generate-branches-badge: true
```
Expand Down Expand Up @@ -728,7 +739,7 @@ jobs:
- name: Set up the Java JDK
uses: actions/setup-java@v2
with:
java-version: '11'
java-version: '17'
distribution: 'adopt'
- name: Build with Maven
Expand Down Expand Up @@ -786,7 +797,7 @@ jobs:
- name: Set up the Java JDK
uses: actions/setup-java@v2
with:
java-version: '11'
java-version: '17'
distribution: 'adopt'

- name: Build with Maven
Expand Down Expand Up @@ -846,7 +857,7 @@ jobs:
- name: Set up the Java JDK
uses: actions/setup-java@v2
with:
java-version: '11'
java-version: '17'
distribution: 'adopt'
- name: Build with Maven
Expand Down Expand Up @@ -878,7 +889,62 @@ jobs:
fi
```

#### Example Workflow 4: Multi-Module Project with Separate Badges for Each Module.
#### Example Workflow 4: Glob Pattern to Specify Reports of a Multi-Module Project.

This example workflow uses a glob pattern to specify the reports of a multi-module project,
and generates both badges (instructions coverage percentage and branches coverage percentage).
The badges that are generated are computed over all modules. In this example, all of the JaCoCo
reports are named `jacoco.csv` but reside in different directories. You can match all of them
with `jacoco-csv-file: "**/jacoco.csv"`. The quotes around the glob are required to avoid an
invalid workflow error from GitHub Actions.

```yml
name: build

on:
push:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up the Java JDK
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'

- name: Build with Maven
run: mvn -B test

- name: Generate JaCoCo Badge
id: jacoco
uses: cicirello/jacoco-badge-generator@v2
with:
generate-branches-badge: true
jacoco-csv-file: "**/jacoco.csv"

- name: Log coverage percentage
run: |
echo "coverage = ${{ steps.jacoco.outputs.coverage }}"
echo "branch coverage = ${{ steps.jacoco.outputs.branches }}"
- name: Commit the badge (if it changed)
run: |
if [[ `git status --porcelain` ]]; then
git config --global user.name 'YOUR NAME HERE'
git config --global user.email '[email protected]'
git add -A
git commit -m "Autogenerated JaCoCo coverage badge"
git push
fi
```
#### Example Workflow 5: Multi-Module Project with Separate Badges for Each Module.
If you would prefer to generate separate coverage badges for each of the
modules of a multi-module project, then just include multiple steps of the
Expand Down Expand Up @@ -907,7 +973,7 @@ jobs:
- name: Set up the Java JDK
uses: actions/setup-java@v2
with:
java-version: '11'
java-version: '17'
distribution: 'adopt'
- name: Build with Maven
Expand Down Expand Up @@ -1111,6 +1177,18 @@ something like:
python3 -m jacoco_badge_generator --jacoco-csv-file reports/report1.csv reports/report2.csv
```

In CLI mode, glob patterns will be handled by your shell. You can accomplish the above with:

```Shell
python3 -m jacoco_badge_generator --jacoco-csv-file reports/report*.csv
```

Or perhaps all of your reports are named `jacoco.csv` but in different directories, then you can
match all of them with:

```Shell
python3 -m jacoco_badge_generator --jacoco-csv-file **/jacoco.csv
```

## Summary of Input Defaults

Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "jacoco-badge-generator"
version = "2.8.1"
version = "2.9.0"
authors = [
{ name="Vincent A. Cicirello", email="[email protected]" },
]
Expand Down Expand Up @@ -46,6 +46,7 @@ exclude = [
"/.github",
"/images",
"/src/entrypoint.py",
"/tests",
"/.dockerignore",
"/action.yml",
"/Dockerfile",
Expand Down

0 comments on commit a0c1eb1

Please sign in to comment.