Compare commits
2 Commits
c6220f1cfe
...
0b6f18f33c
| Author | SHA1 | Date | |
|---|---|---|---|
| 0b6f18f33c | |||
| 1fb15fc331 |
@@ -199,14 +199,10 @@ jobs:
|
|||||||
# Generate BDD coverage report
|
# Generate BDD coverage report
|
||||||
go tool cover -func=coverage.out > bdd_coverage.txt
|
go tool cover -func=coverage.out > bdd_coverage.txt
|
||||||
|
|
||||||
# Extract BDD coverage percentage
|
# Extract BDD coverage percentage and set as environment variable
|
||||||
BDD_COVERAGE=$(grep "total:" bdd_coverage.txt | grep -oP '\d+\.\d+' | head -1)
|
BDD_COVERAGE=$(grep "total:" bdd_coverage.txt | grep -oP '\d+\.\d+' | head -1)
|
||||||
echo "BDD Coverage: ${BDD_COVERAGE}%"
|
echo "BDD Coverage: ${BDD_COVERAGE}%"
|
||||||
|
echo "DLC_BDD_COVERAGE=${BDD_COVERAGE}%" >> $GITHUB_ENV
|
||||||
# Update BDD coverage badge
|
|
||||||
export PACKAGES_TOKEN="${{ secrets.PACKAGES_TOKEN }}"
|
|
||||||
export GITHUB_REF_NAME="${{ github.ref_name }}"
|
|
||||||
./scripts/ci-update-coverage-badge.sh "$BDD_COVERAGE" "bdd"
|
|
||||||
|
|
||||||
- name: Run unit tests with coverage
|
- name: Run unit tests with coverage
|
||||||
run: |
|
run: |
|
||||||
@@ -217,14 +213,10 @@ jobs:
|
|||||||
# Generate unit coverage report
|
# Generate unit coverage report
|
||||||
go tool cover -func=unit_coverage.out > unit_coverage.txt
|
go tool cover -func=unit_coverage.out > unit_coverage.txt
|
||||||
|
|
||||||
# Extract unit test coverage percentage
|
# Extract unit test coverage percentage and set as environment variable
|
||||||
UNIT_COVERAGE=$(grep "total:" unit_coverage.txt | grep -oP '\d+\.\d+' | head -1)
|
UNIT_COVERAGE=$(grep "total:" unit_coverage.txt | grep -oP '\d+\.\d+' | head -1)
|
||||||
echo "Unit Coverage: ${UNIT_COVERAGE}%"
|
echo "Unit Coverage: ${UNIT_COVERAGE}%"
|
||||||
|
echo "DLC_UNIT_COVERAGE=${UNIT_COVERAGE}%" >> $GITHUB_ENV
|
||||||
# Update unit test coverage badge
|
|
||||||
export PACKAGES_TOKEN="${{ secrets.PACKAGES_TOKEN }}"
|
|
||||||
export GITHUB_REF_NAME="${{ github.ref_name }}"
|
|
||||||
./scripts/ci-update-coverage-badge.sh "$UNIT_COVERAGE" "unit"
|
|
||||||
|
|
||||||
- name: Run go fmt
|
- name: Run go fmt
|
||||||
run: go fmt ./...
|
run: go fmt ./...
|
||||||
@@ -244,6 +236,39 @@ jobs:
|
|||||||
# path: pkg/server/docs/swagger.json
|
# path: pkg/server/docs/swagger.json
|
||||||
# retention-days: 1
|
# retention-days: 1
|
||||||
|
|
||||||
|
# Single badge update step using environment variables (KISS approach)
|
||||||
|
- name: Update all badges (single commit)
|
||||||
|
if: always() && github.ref == 'refs/heads/main' && github.actor != 'ci-bot'
|
||||||
|
run: |
|
||||||
|
echo "🎯 Updating all badges using environment variables..."
|
||||||
|
echo "BDD Coverage: ${DLC_BDD_COVERAGE:-Not set}"
|
||||||
|
echo "Unit Coverage: ${DLC_UNIT_COVERAGE:-Not set}"
|
||||||
|
|
||||||
|
# Extract coverage values (remove % sign)
|
||||||
|
BDD_COV=${DLC_BDD_COVERAGE%"%"}
|
||||||
|
UNIT_COV=${DLC_UNIT_COVERAGE%"%"}
|
||||||
|
|
||||||
|
# Update badges only if values are set
|
||||||
|
if [ -n "$BDD_COV" ] || [ -n "$UNIT_COV" ]; then
|
||||||
|
./scripts/update-all-badges.sh "$BDD_COV" "$UNIT_COV"
|
||||||
|
|
||||||
|
# Configure git
|
||||||
|
git config user.name "CI Bot"
|
||||||
|
git config user.email "ci@arcodange.fr"
|
||||||
|
git add README.md
|
||||||
|
|
||||||
|
# Commit only if there are changes
|
||||||
|
if git commit -m "🤖 chore: update coverage badges [skip ci]"; then
|
||||||
|
echo "✅ Badges updated, committing changes..."
|
||||||
|
git push
|
||||||
|
echo "🎉 Successfully pushed badge updates"
|
||||||
|
else
|
||||||
|
echo "ℹ️ No badge changes to commit"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "⚠️ No coverage data available to update badges"
|
||||||
|
fi
|
||||||
|
|
||||||
# Docker build and push (main branch only)
|
# Docker build and push (main branch only)
|
||||||
- name: Login to Gitea Container Registry
|
- name: Login to Gitea Container Registry
|
||||||
if: github.ref == 'refs/heads/main'
|
if: github.ref == 'refs/heads/main'
|
||||||
|
|||||||
@@ -410,7 +410,15 @@ cmd_get_wiki() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
local endpoint="/repos/$owner/$repo/wiki/page/$page_name"
|
local endpoint="/repos/$owner/$repo/wiki/page/$page_name"
|
||||||
api_request "GET" "$endpoint"
|
local response=$(api_request "GET" "$endpoint")
|
||||||
|
|
||||||
|
# Extract and decode the content_base64 field
|
||||||
|
local content_b64=$(echo "$response" | jq -r '.content_base64')
|
||||||
|
if [[ "$content_b64" != "null" && -n "$content_b64" ]]; then
|
||||||
|
echo "$content_b64" | base64 --decode
|
||||||
|
else
|
||||||
|
echo "$response"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Trigger workflow
|
# Trigger workflow
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
[](https://goreportcard.com/report/github.com/arcodange/dance-lessons-coach)
|
[](https://goreportcard.com/report/github.com/arcodange/dance-lessons-coach)
|
||||||
[](https://gitea.arcodange.fr/arcodange/dance-lessons-coach/releases)
|
[](https://gitea.arcodange.fr/arcodange/dance-lessons-coach/releases)
|
||||||
[](LICENSE)
|
[](LICENSE)
|
||||||
[](https://gitea.arcodange.lab/arcodange/dance-lessons-coach)
|
[](https://gitea.arcodange.lab/arcodange/dance-lessons-coach)
|
||||||
nhttps://img.shields.io/badge/BDD_Coverage-55.9%-yellow?style=flat-square
|
[](https://gitea.arcodange.lab/arcodange/dance-lessons-coach)
|
||||||
|
|
||||||
A Go project demonstrating idiomatic package structure, CLI implementation, and JSON API with Chi router.
|
A Go project demonstrating idiomatic package structure, CLI implementation, and JSON API with Chi router.
|
||||||
=======
|
=======
|
||||||
@@ -105,8 +105,7 @@ echo "DLC_DATABASE_SSL_MODE=disable" >> $GITHUB_ENV
|
|||||||
### Status
|
### Status
|
||||||
|
|
||||||
[](https://gitea.arcodange.fr/arcodange/dance-lessons-coach)
|
[](https://gitea.arcodange.fr/arcodange/dance-lessons-coach)
|
||||||
[](https://gitea.arcodange.lab/arcodange/dance-lessons-coach)
|
|
||||||
nhttps://img.shields.io/badge/BDD_Coverage-55.9%-yellow?style=flat-square
|
|
||||||
=======
|
=======
|
||||||
- ✅ **Linting**: Code quality checks with `go fmt` and `go vet`
|
- ✅ **Linting**: Code quality checks with `go fmt` and `go vet`
|
||||||
- ✅ **Version Management**: Automatic version detection
|
- ✅ **Version Management**: Automatic version detection
|
||||||
|
|||||||
50
scripts/update-all-badges.sh
Executable file
50
scripts/update-all-badges.sh
Executable file
@@ -0,0 +1,50 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Simple script to update coverage badges in README.md
|
||||||
|
# Usage: ./scripts/update-all-badges.sh [bdd_coverage] [unit_coverage]
|
||||||
|
# Both parameters are optional - only updates what's provided
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
BDD_COVERAGE=""
|
||||||
|
UNIT_COVERAGE=""
|
||||||
|
|
||||||
|
# Parse arguments (both optional)
|
||||||
|
if [ -n "$1" ]; then
|
||||||
|
BDD_COVERAGE=$1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$2" ]; then
|
||||||
|
UNIT_COVERAGE=$2
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "🎯 Updating coverage badges..."
|
||||||
|
if [ -n "$BDD_COVERAGE" ]; then
|
||||||
|
echo " BDD: ${BDD_COVERAGE}%"
|
||||||
|
fi
|
||||||
|
if [ -n "$UNIT_COVERAGE" ]; then
|
||||||
|
echo " Unit: ${UNIT_COVERAGE}%"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Update BDD coverage badge if provided
|
||||||
|
if [ -n "$BDD_COVERAGE" ] && grep -q "BDD_Coverage" README.md; then
|
||||||
|
sed -i '' "s/BDD_Coverage-[0-9.]\+-%/BDD_Coverage-${BDD_COVERAGE}-%/g" README.md
|
||||||
|
echo "✅ BDD coverage badge updated to ${BDD_COVERAGE}%"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Update Unit coverage badge if provided
|
||||||
|
if [ -n "$UNIT_COVERAGE" ] && grep -q "Unit_Coverage" README.md; then
|
||||||
|
sed -i '' "s/Unit_Coverage-[0-9.]\+-%/Unit_Coverage-${UNIT_COVERAGE}-%/g" README.md
|
||||||
|
echo "✅ Unit coverage badge updated to ${UNIT_COVERAGE}%"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Update main coverage badge if BDD coverage provided
|
||||||
|
if [ -n "$BDD_COVERAGE" ] && grep -q "coverage-[0-9.]\+-%" README.md; then
|
||||||
|
sed -i '' "s/coverage-[0-9.]\+-%/coverage-${BDD_COVERAGE}-%/g" README.md
|
||||||
|
echo "✅ Main coverage badge updated to ${BDD_COVERAGE}%"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$BDD_COVERAGE" ] && [ -z "$UNIT_COVERAGE" ]; then
|
||||||
|
echo "ℹ️ No coverage values provided - nothing to update"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "🎉 Badge update process completed!"
|
||||||
Reference in New Issue
Block a user