Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report mutation test coverage of proposed changes #346

Merged
merged 28 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
88faea0
Compute mutation test coverage of proposed changes
Stephan202 Nov 12, 2022
a0d1f7d
Fix syntax error
Stephan202 Nov 12, 2022
ce11309
Fix uploading
Stephan202 Nov 12, 2022
2256a9b
Test `update-pr`
Stephan202 Nov 12, 2022
3850f4d
Likely should drop this, too
Stephan202 Nov 12, 2022
b293b30
Permissions
Stephan202 Nov 12, 2022
7ad894a
Less accurate, but want to see it work
Stephan202 Nov 12, 2022
4c01656
More permissions
Stephan202 Nov 12, 2022
addbc4f
More...
Stephan202 Nov 12, 2022
221d955
Doh
Stephan202 Nov 12, 2022
76016b2
Test
Stephan202 Nov 12, 2022
db5a238
What about this?
Stephan202 Nov 12, 2022
c12701e
Next step
Stephan202 Nov 12, 2022
6c64123
So indeed it isn't inferred
Stephan202 Nov 12, 2022
6a3978c
Hmm, is the report always generated?
Stephan202 Nov 12, 2022
afb4f43
Nicer link?
Stephan202 Nov 12, 2022
6c48f53
Final tweaks
Stephan202 Nov 12, 2022
0ed96b2
Drop test code
Stephan202 Nov 12, 2022
5e7d7c5
`s/Licence/License` and suggestions
rickie Nov 19, 2022
35e6fe7
Revert most changes
rickie Nov 24, 2022
26a8b32
Re-introduce test code
Stephan202 Nov 12, 2022
9700f5e
Remove bad code to see other emoji
rickie Nov 24, 2022
0fc8799
Add properly tested code?
rickie Nov 24, 2022
f8d564c
Add missing comment
rickie Nov 24, 2022
f6637aa
Specify more specific JDK version for workflows and revert test changes
rickie Nov 24, 2022
3da91ab
Drop timestamp comment
Stephan202 Nov 24, 2022
4054314
Suggestion for linking blogpost on Pitest PR analysis
Badbond Nov 29, 2022
1cc5e8c
Proposal for sharper phrasing
Stephan202 Nov 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/pitest-analyze-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Performs mutation testing analysis on the files changed by a pull request and
# uploads the results. The associated PR is subsequently updated by the
# `pitest-update-pr.yml` workflow. See https://blog.pitest.org/oss-pitest-pr/
# for details.
name: "Mutation testing"
Stephan202 marked this conversation as resolved.
Show resolved Hide resolved
on:
pull_request:
permissions:
contents: read
jobs:
analyze-pr:
runs-on: ubuntu-22.04
steps:
Stephan202 marked this conversation as resolved.
Show resolved Hide resolved
- name: Check out code
uses: actions/checkout@v3.1.0
with:
fetch-depth: 2
- name: Set up JDK
uses: actions/setup-java@v3.6.0
with:
java-version: 17.0.4
distribution: temurin
cache: maven
- name: Run Pitest
# By running with features `+GIT(from[HEAD~1]), +gitci`, Pitest only
# analyzes lines changed in the associated pull request, as GitHub
# exposes the changes unique to the PR as a single commit on top of the
# target branch. See https://blog.pitest.org/pitest-pr-setup for
# details.
run: mvn test pitest:mutationCoverage -DargLine.xmx=2048m -Dverification.skip -Dfeatures="+GIT(from[HEAD~1]), +gitci"
Stephan202 marked this conversation as resolved.
Show resolved Hide resolved
- name: Aggregate Pitest reports
run: mvn pitest-git:aggregate -DkilledEmoji=":tada:" -DmutantEmoji=":zombie:" -DtrailingText="Mutation testing report by [Pitest](https://pitest.org/). Review any surviving mutants by inspecting the line comments under [_Files changed_](${{ github.event.number }}/files)."
- name: Upload Pitest reports as artifact
uses: actions/upload-artifact@v3.1.1
with:
name: pitest-reports
path: ./target/pit-reports-ci
35 changes: 35 additions & 0 deletions .github/workflows/pitest-update-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Updates a pull request based on the corresponding mutation testing analysis
# performed by the `pitest-analyze-pr.yml` workflow. See
# https://blog.pitest.org/oss-pitest-pr/ for details.
Stephan202 marked this conversation as resolved.
Show resolved Hide resolved
name: "Mutation testing: post results"
on:
workflow_run:
workflows: ["Mutation testing"]
types:
- completed
permissions:
actions: read
checks: write
contents: read
pull-requests: write
jobs:
update-pr:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v3.1.0
- name: Set up JDK
uses: actions/setup-java@v3.6.0
with:
java-version: 17.0.4
distribution: temurin
cache: maven
- name: Download Pitest analysis artifact
uses: dawidd6/action-download-artifact@v2.24.2
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
name: pitest-reports
path: ./target/pit-reports-ci
- name: Update PR
run: mvn -DrepoToken="${{ secrets.GITHUB_TOKEN }}" pitest-github:updatePR
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Some other commands one may find relevant:

- `mvn fmt:format` formats the code using
[`google-java-format`][google-java-format].
- `./run-mutation-tests.sh` runs mutation tests using [PIT][pitest]. The
- `./run-mutation-tests.sh` runs mutation tests using [Pitest][pitest]. The
results can be reviewed by opening the respective
`target/pit-reports/index.html` files. For more information check the [PIT
Maven plugin][pitest-maven].
Expand Down
7 changes: 7 additions & 0 deletions cdg-pitest-licence.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Arcmutate license for Error Prone Support, requested by sending an email to
# support@arcmutate.com.
expires=07/11/2023
keyVersion=1
signature=MhZxMbnO6UovNfllM0JuVWkZyvRT3/G5o/uT0Mm36c7200VpZNVu03gTAGivnl9W5RzvZhfpIHccuQ5ctjQkrqhsFSrl4fyqPqu3y5V2fsHIdFXP/G72EGj6Kay9ndLpaEHalqE0bEwxdnHMzEYq5y3O9vUPv8MhUl57xk+rvBo\=
packages=tech.picnic.errorprone.*
type=OSSS
20 changes: 20 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
<version.mockito>4.9.0</version.mockito>
<version.nopen-checker>1.0.1</version.nopen-checker>
<version.nullaway>0.10.5</version.nullaway>
<version.pitest-git>1.0.1</version.pitest-git>
<version.surefire>2.22.2</version.surefire>
</properties>

Expand Down Expand Up @@ -428,6 +429,16 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.groupcdg</groupId>
<artifactId>pitest-git-maven-plugin</artifactId>
<version>${version.pitest-git}</version>
</plugin>
<plugin>
<groupId>com.groupcdg</groupId>
<artifactId>pitest-github-maven-plugin</artifactId>
<version>${version.pitest-git}</version>
</plugin>
<plugin>
<groupId>com.spotify.fmt</groupId>
<artifactId>fmt-maven-plugin</artifactId>
Expand Down Expand Up @@ -1231,8 +1242,12 @@
<version>1.9.11</version>
<configuration>
<excludedClasses>
<!-- AutoValue generated classes. -->
<excludedClass>*.AutoValue_*</excludedClass>
<!-- Refaster rule collections. -->
<excludedClass>*.refaster*.*Rules*</excludedClass>
Stephan202 marked this conversation as resolved.
Show resolved Hide resolved
</excludedClasses>
<failWhenNoMutations>false</failWhenNoMutations>
<!-- Use multiple threads to speed things up. Extend
timeouts to prevent false positives as a result of
contention. -->
Expand All @@ -1241,6 +1256,11 @@
<timestampedReports>false</timestampedReports>
</configuration>
<dependencies>
<dependency>
<groupId>com.groupcdg</groupId>
<artifactId>pitest-git-plugin</artifactId>
<version>${version.pitest-git}</version>
</dependency>
<dependency>
<groupId>org.pitest</groupId>
<artifactId>pitest-junit5-plugin</artifactId>
Expand Down