From f47094cbba4e6435fa391373fd27d3bc55efc972 Mon Sep 17 00:00:00 2001 From: Gabriel Radureau Date: Wed, 8 Apr 2026 13:48:06 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20extract=20BDD=20coverage?= =?UTF-8?q?=20directly=20from=20test=20output=20instead=20of=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/ci-cd.yaml | 23 ++++++++--------------- scripts/run-bdd-tests.sh | 2 +- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/.gitea/workflows/ci-cd.yaml b/.gitea/workflows/ci-cd.yaml index bd2a559..2e96fb8 100644 --- a/.gitea/workflows/ci-cd.yaml +++ b/.gitea/workflows/ci-cd.yaml @@ -194,24 +194,17 @@ jobs: export DLC_DATABASE_PASSWORD=postgres export DLC_DATABASE_NAME=dance_lessons_coach_bdd_test export DLC_DATABASE_SSL_MODE=disable - ./scripts/run-bdd-tests.sh + # Run BDD tests and capture output + test_output=$(./scripts/run-bdd-tests.sh 2>&1) + echo "$test_output" - # Debug: Check if coverage file exists - ls -la coverage.out || echo "ERROR: coverage.out not found" - - # Generate BDD coverage report - if [ -f "coverage.out" ]; then - go tool cover -func=coverage.out > bdd_coverage.txt - - # Extract BDD coverage percentage - BDD_COVERAGE=$(grep "total:" bdd_coverage.txt | grep -oP '\d+\.\d+' | head -1) - echo "BDD Coverage: ${BDD_COVERAGE}%" - else - echo "ERROR: coverage.out file not found after BDD tests" - # Try to find any coverage files - find . -name "*.out" -o -name "coverage*" | head -10 + # Extract BDD coverage percentage directly from test output + BDD_COVERAGE=$(echo "$test_output" | grep "coverage:" | grep -oP '\d+\.\d+' | head -1) + if [ -z "$BDD_COVERAGE" ]; then + echo "ERROR: Could not extract BDD coverage from test output" exit 1 fi + echo "BDD Coverage: ${BDD_COVERAGE}%" # Update BDD coverage badge export PACKAGES_TOKEN="${{ secrets.PACKAGES_TOKEN }}" diff --git a/scripts/run-bdd-tests.sh b/scripts/run-bdd-tests.sh index 3289fea..8a31ca6 100755 --- a/scripts/run-bdd-tests.sh +++ b/scripts/run-bdd-tests.sh @@ -95,7 +95,7 @@ else fi # Run tests with proper coverage measurement -test_output=$(go test ./features/... -v -cover -coverpkg=./... -coverprofile=coverage.out 2>&1) +test_output=$(go test ./features/... -v -cover -coverpkg=./... 2>&1) test_exit_code=$? echo "$test_output"