-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (92 loc) · 3.8 KB
/
13-backend-incremental-pitest.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# 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/[email protected]
- 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
continue-on-error: true
uses: dawidd6/[email protected]
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 test org.pitest:pitest-maven:mutationCoverage -DmutationThreshold=100
- name: Upload Pitest History to Artifacts
if: always() # always upload artifacts, even if tests fail
uses: actions/[email protected]
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/[email protected]
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