[2] CI/CD #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Java CI with Maven | |
on: | |
push: | |
branches: ["master"] | |
pull_request: | |
branches: ["master"] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: "17" | |
distribution: "temurin" | |
cache: maven | |
- name: Build with Maven | |
run: mvn -B package --file pom.xml | |
- name: Add coverage to PR | |
id: jacoco | |
uses: madrapps/jacoco-report@v1.6.1 | |
with: | |
paths: | | |
${{ github.workspace }}/**/target/site/jacoco/jacoco.xml | |
token: ${{ secrets.GITHUB_TOKEN }} | |
min-coverage-overall: 100 | |
- name: Run PITest | |
run: | | |
mvn test-compile org.pitest:pitest-maven:mutationCoverage -DoutputFormats=CSV,HTML | |
{ echo '| File | Package | Mutation | Function | Line | Status | Test |'; \ | |
echo -n '| ---- | ------- | -------- | -------- | ---- | ------ | ---- |'; \ | |
cat target/pit-reports/mutations.csv | grep "SURVIVED" | awk -F, '{print "| " $1 " | " $2 " | " $3 " | " $4 " | " $5 " | " $6 " | " $7 " |"}'; | |
} > target/pit-reports/mutations.md | |
- name: Archive PITest report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: pitest-report | |
path: target/pit-reports | |
- name: Add PITest report to PR | |
uses: mshick/add-pr-comment@v2 | |
with: | |
message-path: | | |
target/pit-reports/mutations.md |