diff --git a/.drone.yml b/.drone.yml index 842efba..eecabd4 100644 --- a/.drone.yml +++ b/.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" \