From cc9c2a56745ef4fe08db0b9139ab83faee5f0757 Mon Sep 17 00:00:00 2001 From: Gabriel Radureau Date: Wed, 8 Apr 2026 13:56:29 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor:=20use=20simple?= =?UTF-8?q?=20coverage=20file=20approach=20for=20BDD=20tests=20(KISS=20pri?= =?UTF-8?q?nciple)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/ci-cd.yaml | 15 ++++++--------- scripts/run-bdd-tests.sh | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/.gitea/workflows/ci-cd.yaml b/.gitea/workflows/ci-cd.yaml index 2e96fb8..225fe76 100644 --- a/.gitea/workflows/ci-cd.yaml +++ b/.gitea/workflows/ci-cd.yaml @@ -194,16 +194,13 @@ jobs: export DLC_DATABASE_PASSWORD=postgres export DLC_DATABASE_NAME=dance_lessons_coach_bdd_test export DLC_DATABASE_SSL_MODE=disable - # Run BDD tests and capture output - test_output=$(./scripts/run-bdd-tests.sh 2>&1) - echo "$test_output" + ./scripts/run-bdd-tests.sh - # 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 + # Generate BDD coverage report + 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}%" # Update BDD coverage badge diff --git a/scripts/run-bdd-tests.sh b/scripts/run-bdd-tests.sh index 8a31ca6..3289fea 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=./... 2>&1) +test_output=$(go test ./features/... -v -cover -coverpkg=./... -coverprofile=coverage.out 2>&1) test_exit_code=$? echo "$test_output"