ci: fix coverage parsing and JSON payload construction
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
801a2c08fb
commit
41523ce6a1
11
.drone.yml
11
.drone.yml
@ -23,9 +23,8 @@ steps:
|
||||
from_secret: gitea_token
|
||||
commands:
|
||||
- apt-get update -qq && apt-get install -y -qq jq curl
|
||||
- cargo tarpaulin --out Json 2>/dev/null
|
||||
- |
|
||||
PCT=$(jq '(.covered / .coverable * 100) | floor' tarpaulin-report.json)
|
||||
PCT=$(cargo tarpaulin 2>&1 | grep -oE '[0-9]+\.[0-9]+% coverage' | cut -d'.' -f1)
|
||||
if [ "$PCT" -ge 80 ]; then COLOR="brightgreen"
|
||||
elif [ "$PCT" -ge 60 ]; then COLOR="yellow"
|
||||
else COLOR="red"; fi
|
||||
@ -37,9 +36,13 @@ steps:
|
||||
| jq -r '.sha // empty')
|
||||
CONTENT=$(base64 -w 0 coverage.svg)
|
||||
if [ -n "$SHA" ]; then
|
||||
PAYLOAD="{\"message\":\"ci: update coverage badge [CI SKIP]\",\"content\":\"$CONTENT\",\"sha\":\"$SHA\",\"branch\":\"master\"}"
|
||||
PAYLOAD=$(jq -n --arg msg "ci: update coverage badge [CI SKIP]" \
|
||||
--arg content "$CONTENT" --arg sha "$SHA" --arg branch "master" \
|
||||
'{message: $msg, content: $content, sha: $sha, branch: $branch}')
|
||||
else
|
||||
PAYLOAD="{\"message\":\"ci: add coverage badge [CI SKIP]\",\"content\":\"$CONTENT\",\"branch\":\"master\"}"
|
||||
PAYLOAD=$(jq -n --arg msg "ci: add coverage badge [CI SKIP]" \
|
||||
--arg content "$CONTENT" --arg branch "master" \
|
||||
'{message: $msg, content: $content, branch: $branch}')
|
||||
fi
|
||||
curl -fsSL -X PUT \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user