Commit c8d947c3 authored by Tomas Norre Mikkelsen's avatar Tomas Norre Mikkelsen Committed by Thomas Löffler
Browse files

[CI] Add Mutation badges with colors based on result

parent ec5f014c
......@@ -64,23 +64,32 @@ test:mutation:
- mkdir $TYPO3_PATH_WEB/fileadmin/ && touch $TYPO3_PATH_WEB/fileadmin/currentcoredata.json
script:
- composer install --ignore-platform-reqs
- ./vendor/bin/infection --min-msi=11 --min-covered-msi=79 --threads=4 > mutation-metric-log.txt
- ./vendor/bin/infection --min-msi=11 --min-covered-msi=79 --threads=4
artifacts:
paths:
- mutation-metric-log.txt
- build/infection-log.json
expire_in: 30 min
mutation:badge:
stage: badges
image: python:3.6.6
image: python:3.9
before_script:
- echo "Python other dependencies installation"
- pip install anybadge
- pip3 install anybadge
- apt update -y
- apt install -y jq
- mkdir badges
- cd badges
script:
- mutation_msi=$(cat ../mutation-metric-log.txt | grep 'Covered Code MSI' | cut -d ' ' -f 13)
- anybadge -l "Mutation" -v $mutation_msi -f mutation_msi.svg -c orange
- mutation_msi=$(cat ../build/infection-log.json | jq .stats.msi)
- msi_color=$(../gitlab-ci/build/./badge-color.sh $mutation_msi)
- anybadge -l "Mutation MSI" -v $mutation_msi -f mutation_msi.svg -c $msi_color
- mutation_mcc=$(cat ../build/infection-log.json | jq .stats.mutationCodeCoverage)
- mcc_color=$(../gitlab-ci/build/./badge-color.sh $mutation_mcc)
- anybadge -l "Mutation MCC" -v $mutation_mcc -f mutation_mcc.svg -c $mcc_color
- mutation_ccmsi=$(cat ../build/infection-log.json | jq .stats.coveredCodeMsi)
- ccmsi_color=$(../gitlab-ci/build/./badge-color.sh $mutation_ccmsi)
- anybadge -l "Mutation CCMSI" -v $mutation_ccmsi -f mutation_ccmsi.svg -c $ccmsi_color
artifacts:
paths:
- badges/
......
#!/usr/bin/env bash
# This script is a helper for the anybadge to set the color based on the number result
# Makes sure that we have a , and not a . decimal number
# shellcheck disable=SC2001
n=$(echo "$1" | sed 's/\./,/g')
if [[ "$n" -ge "0" ]] && [[ "$n" -lt "50" ]]; then
echo 'red'
elif [[ "$n" -ge "50" ]] && [[ "$n" -lt "90" ]]; then
echo 'yellow'
else
echo 'green'
fi
\ No newline at end of file
......@@ -8,7 +8,8 @@
"configDir": ".gitlab-ci\/Tests\/"
},
"logs": {
"text": "build/infection.log"
"text": "build/infection.log",
"json": "build/infection-log.json"
},
"mutators": {
"@default": true,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment