Enhance CI pipeline and documentation
- Update Drone CI configuration to include triggers for push and tag events. - Improve test coverage commands and add coverage checks. - Introduce release notes generation and packaging steps in the CI pipeline. - Add comprehensive release documentation and a checklist for the release process. - Implement tests for GELF logging functionality. - Update dependencies in go.mod and go.sum for better compatibility. - Add scripts for checking coverage and generating release notes.
This commit is contained in:
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
# Check test coverage against minimum threshold.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
COVERAGE_FILE="${1:-.build/coverage.out}"
|
||||
MIN_COVERAGE="${2:-80}"
|
||||
|
||||
if [ ! -f "$COVERAGE_FILE" ]; then
|
||||
echo "Error: coverage file not found: $COVERAGE_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extract total coverage percentage from go tool cover output.
|
||||
COVERAGE=$(go tool cover -func "$COVERAGE_FILE" | awk '/^total:/ { match($0, /[0-9.]+%/); print substr($0, RSTART, RLENGTH-1) }')
|
||||
|
||||
if [ -z "$COVERAGE" ]; then
|
||||
echo "Error: failed to parse coverage from $COVERAGE_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Total coverage: ${COVERAGE}%"
|
||||
|
||||
# Compare as integer part to keep shell arithmetic simple and portable.
|
||||
COVERAGE_INT=${COVERAGE%.*}
|
||||
|
||||
if [ "$COVERAGE_INT" -lt "$MIN_COVERAGE" ]; then
|
||||
echo "Coverage ${COVERAGE}% is below minimum ${MIN_COVERAGE}%"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Coverage check passed"
|
||||
Executable
+70
@@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
# Generate release notes from commits since the previous tag.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
CURRENT_TAG="${1:-${DRONE_TAG:-}}"
|
||||
OUTPUT_FILE="${2:-.build/release-notes.md}"
|
||||
|
||||
if [ -z "$CURRENT_TAG" ]; then
|
||||
echo "Error: current tag not provided"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PREVIOUS_TAG=$(git describe --tags --abbrev=0 "$CURRENT_TAG"^ 2>/dev/null || echo "")
|
||||
|
||||
mkdir -p "$(dirname "$OUTPUT_FILE")"
|
||||
|
||||
{
|
||||
echo "# Release $CURRENT_TAG"
|
||||
echo
|
||||
|
||||
if [ -n "$PREVIOUS_TAG" ]; then
|
||||
echo "Changes since $PREVIOUS_TAG:"
|
||||
echo
|
||||
|
||||
git log "$PREVIOUS_TAG..$CURRENT_TAG" --pretty=format:"%s" | while read -r commit; do
|
||||
if [[ $commit =~ ^([a-z]+)(\(.+\))?:\ (.+)$ ]]; then
|
||||
TYPE="${BASH_REMATCH[1]}"
|
||||
SCOPE="${BASH_REMATCH[2]}"
|
||||
MESSAGE="${BASH_REMATCH[3]}"
|
||||
|
||||
case "$TYPE" in
|
||||
feat)
|
||||
echo "- Feature${SCOPE}: $MESSAGE" ;;
|
||||
fix)
|
||||
echo "- Fix${SCOPE}: $MESSAGE" ;;
|
||||
docs)
|
||||
echo "- Docs${SCOPE}: $MESSAGE" ;;
|
||||
ci)
|
||||
echo "- CI${SCOPE}: $MESSAGE" ;;
|
||||
test)
|
||||
echo "- Test${SCOPE}: $MESSAGE" ;;
|
||||
refactor)
|
||||
echo "- Refactor${SCOPE}: $MESSAGE" ;;
|
||||
perf)
|
||||
echo "- Performance${SCOPE}: $MESSAGE" ;;
|
||||
*)
|
||||
echo "- $commit" ;;
|
||||
esac
|
||||
else
|
||||
echo "- $commit"
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "Initial release"
|
||||
echo
|
||||
git log "$CURRENT_TAG" --pretty=format:"- %s" | head -20
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "---"
|
||||
if [ -n "$PREVIOUS_TAG" ]; then
|
||||
echo "See all changes: https://scm.yoorie.de/git/go-lib/gelf/compare/$PREVIOUS_TAG...$CURRENT_TAG"
|
||||
else
|
||||
echo "See all changes: https://scm.yoorie.de/git/go-lib/gelf/releases/tag/$CURRENT_TAG"
|
||||
fi
|
||||
} > "$OUTPUT_FILE"
|
||||
|
||||
echo "Release notes generated: $OUTPUT_FILE"
|
||||
cat "$OUTPUT_FILE"
|
||||
Reference in New Issue
Block a user