Skip to content

pc - update pom.xml for partial pitest runs #38

pc - update pom.xml for partial pitest runs

pc - update pom.xml for partial pitest runs #38

# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: "13-backend-incremental-pitest: Java Mutation Testing (Pitest)"
on:
workflow_dispatch:
pull_request:
paths: [src/**, pom.xml, lombok.config]
push:
branches: [ main ]
paths: [src/**, pom.xml, lombok.config]
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v3.5.2
- name: Set up Java (version from .java-version file)
uses: actions/setup-java@v3
with:
distribution: semeru # See: https://github.com/actions/setup-java#supported-distributions
java-version-file: ./.java-version
- name: Figure out branch name
id: get-branch-name
run: |
GITHUB_HEAD_REF="${GITHUB_HEAD_REF}"
echo GITHUB_HEAD_REF=${GITHUB_HEAD_REF}
GITHUB_REF_CLEANED=${GITHUB_REF/refs\/heads\//}
echo GITHUB_REF_CLEANED=${GITHUB_REF_CLEANED}
GITHUB_REF_CLEANED=${GITHUB_REF_CLEANED//\//-}
echo GITHUB_REF_CLEANED=${GITHUB_REF_CLEANED}
BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF_CLEANED}}"
echo "branch_name=${BRANCH}"
echo "branch_name=${BRANCH}" >> "$GITHUB_ENV"
- name: Download artifact
id: download-artifact
uses: dawidd6/action-download-artifact@v2.27.0
with:
github_token: ${{secrets.GITHUB_TOKEN}}
branch: ${{ env.branch_name }}
name: pitest-${{env.branch_name}}-history.bin
path: target/pit-history
check_artifacts: true
if_no_artifact_found: warn
- name: Copy artifact to pit-history/history.bin # specified in pom.xml as historyInputFile
continue-on-error: true
run: |
historyFile=target/pit-history/pitest-main-history.bin
[ -f "$historyFile" ] && cp $historyFile target/pit-history/history.bin
- name: Build with Maven
run: mvn -B test
- name: Pitest
run: mvn pitest:mutationCoverage -DmutationThreshold=100
- name: Upload Pitest History to Artifacts
if: always() # always upload artifacts, even if tests fail
uses: actions/upload-artifact@v3.1.2
with:
name: pitest-${{env.branch_name}}-history.bin
path: target/pit-history/history.bin
- name: Upload Pitest Report to Artifacts
if: always() # always upload artifacts, even if tests fail
uses: actions/upload-artifact@v3.1.2
with:
name: pitest
path: target/pit-reports/*
- name: Get PR number
id: get-pr-num
run: |
echo "GITHUB_EVENT_PATH=${GITHUB_EVENT_PATH}"
pr_number=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
echo "pr_number=${pr_number}"
echo "pr_number=${pr_number}" >> "$GITHUB_ENV"
- name: Set path for github pages deploy when there is a PR num
if: ${{ env.pr_number != 'null' }}
run: |
prefix="prs/${pr_number}/"
echo "prefix=${prefix}"
echo "prefix=${prefix}" >> "$GITHUB_ENV"
- name: Set path for github pages deploy when there is NOT a PR num
if: ${{ env.pr_number == 'null' }}
run: |
prefix=""
echo "prefix=${prefix}"
echo "prefix=${prefix}" >> "$GITHUB_ENV"
- name: Deploy 🚀
if: always() # always upload artifacts, even if tests fail
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages # The branch the action should deploy to.
folder: target/pit-reports # The folder where the files we want to publish are located
clean: true # Automatically remove deleted files from the deploy branch
target-folder: ${{env.prefix}}pitest # The folder that we serve our files from