🐛 fix: make ci-update-coverage-badge.sh cross-platform compatible
Some checks failed
CI/CD Pipeline / Build Docker Cache (push) Successful in 9s
CI/CD Pipeline / CI Pipeline (push) Failing after 4m32s

- Add cross-platform sed detection (macOS vs Linux)
- Fixes Unit coverage badge URL typo issue
- Ensures all badge update scripts work in Docker containers

This completes the cross-platform compatibility for all badge scripts.
This commit is contained in:
2026-04-08 16:10:02 +02:00
parent f781bee3ba
commit 1296d62333

View File

@@ -40,18 +40,29 @@ if grep -q "${BADGE_TYPE}_Coverage-${COVERAGE}%" README.md || grep -q "coverage-
exit 0
fi
# Cross-platform sed command
# Detect if we're on macOS (BSD sed) or Linux (GNU sed)
SED_CMD=""
if [[ "$(uname)" == "Darwin" ]]; then
# macOS - requires empty string after -i
SED_CMD="sed -i ''"
else
# Linux - standard GNU sed
SED_CMD="sed -i"
fi
# Update README - handle both old and new badge formats
if [ "$BADGE_TYPE" = "bdd" ] || [ "$BADGE_TYPE" = "unit" ]; then
# For BDD/Unit badges, add them if they don't exist, or update if they do
if grep -q "${BADGE_TYPE}_Coverage" README.md; then
sed -i "s|https://img.shields.io/badge/${BADGE_TYPE}_Coverage-.*-.*?style=flat-square|${BADGE_URL}|" README.md
$SED_CMD "s|https://img.shields.io/badge/${BADGE_TYPE}_Coverage-.*-.*?style=flat-square|${BADGE_URL}|" README.md
else
# Add new badge line after the main coverage badge
sed -i "/coverage-.*-.*?style=flat-square/a\\n${BADGE_URL}" README.md
$SED_CMD "/coverage-.*-.*?style=flat-square/a\\n${BADGE_URL}" README.md
fi
else
# For combined coverage, use the original logic
sed -i "s|https://img.shields.io/badge/coverage-.*-.*?style=flat-square|${BADGE_URL}|" README.md
$SED_CMD "s|https://img.shields.io/badge/coverage-.*-.*?style=flat-square|${BADGE_URL}|" README.md
fi
# Set up git