Skip to content

Commit f429df4

Browse files
committed
Add Infection MSI badge
1 parent 7ae64f2 commit f429df4

File tree

3 files changed

+42
-19
lines changed

3 files changed

+42
-19
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
[![Version](https://img.shields.io/badge/version-0.0.0-success.svg)](https://github.com/steevanb/php-parallel-processes/tree/0.0.0)
1+
[![Version](https://img.shields.io/badge/version-0.0.0-blueviolet.svg)](https://github.com/steevanb/php-parallel-processes/tree/0.0.0)
22
[![PHP](https://img.shields.io/badge/php-^7.4||^8.0-blue.svg)](https://php.net)
3-
![Lines](https://img.shields.io/badge/code%20lines-4278-success.svg)
3+
![Lines](https://img.shields.io/badge/code%20lines-4,356-blue.svg)
44
![Downloads](https://poser.pugx.org/steevanb/php-parallel-processes/downloads)
55
![GitHub workflow status](https://img.shields.io/github/workflow/status/steevanb/php-parallel-processes/CI)
6-
![Coverage](https://img.shields.io/badge/coverage-76%25-success.svg)
6+
![Coverage](https://img.shields.io/badge/coverage-75%25-success.svg)
7+
![Infection](https://img.shields.io/badge/infection-80%25-success.svg)
78

89
# php-parallel-process
910

bin/release/prepare

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function onError() {
1717

1818
trap onError ERR
1919

20-
function init-log() {
20+
function initLog() {
2121
if [ ! -d "${logFilePath}" ]; then
2222
mkdir -p "${logFilePath}"
2323
fi
@@ -27,28 +27,51 @@ function init-log() {
2727
fi
2828
}
2929

30-
function edit-readme() {
30+
function editReadme() {
3131
trap onError ERR
3232

3333
echo "Edit README.md"
3434

35-
readonly releaseBadge="[![Version](https:\/\/img.shields.io\/badge\/version-${version}-success.svg)](https:\/\/github.com\/steevanb\/php-parallel-processes\/tree\/${version})"
35+
local releaseBadge="[![Version](https:\/\/img.shields.io\/badge\/version-${version}-blueviolet.svg)](https:\/\/github.com\/steevanb\/php-parallel-processes\/tree\/${version})"
3636
sed -i "1s/.*/${releaseBadge}/" "${rootDir}"/README.md
3737

38-
readonly codeLines=$("${rootDir}"/bin/release/code-lines)
39-
readonly codeLinesBadge="![Lines](https:\/\/img.shields.io\/badge\/code%20lines-${codeLines}-success.svg)"
38+
local codeLines=
39+
codeLines=$("${rootDir}"/bin/release/code-lines)
40+
local codeLinesBadge="![Lines](https:\/\/img.shields.io\/badge\/code%20lines-${codeLines}-blue.svg)"
4041
sed -i "3s/.*/${codeLinesBadge}/" "${rootDir}"/README.md
4142
}
4243

43-
function edit-coverage() {
44+
function editCoverage() {
4445
echo "Calculate coverage"
4546

46-
readonly coveragePercent="$(${rootDir}/bin/release/phpunit-coverage)"
47+
local coveragePercent=
48+
coveragePercent="$(${rootDir}/bin/release/phpunit-coverage)"
4749
echo "Coverage: ${coveragePercent}%"
48-
readonly coverageBadge="![Coverage](https:\/\/img.shields.io\/badge\/coverage-${coveragePercent}%25-success.svg)"
49-
sed -i "6s/.*/${coverageBadge}/" "${rootDir}"/README.md
50+
51+
local badge="![Coverage](https:\/\/img.shields.io\/badge\/coverage-${coveragePercent}%25-success.svg)"
52+
sed -i "6s/.*/${badge}/" "${rootDir}"/README.md
53+
}
54+
55+
function editInfection() {
56+
echo "Calculate Infection MSI"
57+
58+
local logsPath="${rootDir}"/var/ci/infection/logs.json
59+
if [ -f "${logsPath}" ]; then
60+
rm "${logsPath}"
61+
fi
62+
63+
"${rootDir}"/bin/ci/infection > /dev/null
64+
65+
local infectionMsiPercent=
66+
infectionMsiPercent=$(jq -r ".stats.msi" < "${logsPath}")
67+
infectionMsiPercent=$(printf "%.0f" "${infectionMsiPercent}")
68+
echo "Infection MSI: ${infectionMsiPercent}%"
69+
70+
local badge="![Infection](https:\/\/img.shields.io\/badge\/infection-${infectionMsiPercent}%25-success.svg)"
71+
sed -i "7s/.*/${badge}/" "${rootDir}"/README.md
5072
}
5173

52-
init-log
53-
edit-readme
54-
edit-coverage
74+
initLog
75+
editReadme
76+
editCoverage
77+
editInfection

config/ci/infection.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
},
1010
"tmpDir": "../../var/ci/infection",
1111
"logs": {
12-
"text": "php://stdout"
13-
},
14-
"minMsi": 100,
15-
"minCoveredMsi": 100
12+
"text": "php://stdout",
13+
"json": "var/ci/infection/logs.json"
14+
}
1615
}

0 commit comments

Comments
 (0)