From 32b11b1f97e25d61475593257b8ab56b1de485a9 Mon Sep 17 00:00:00 2001 From: Gabriel Radureau Date: Wed, 8 Apr 2026 13:13:36 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor:=20simplify=20cov?= =?UTF-8?q?erage=20measurement=20using=20separate=20output=20files=20(KISS?= =?UTF-8?q?=20principle)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/ci-cd.yaml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.gitea/workflows/ci-cd.yaml b/.gitea/workflows/ci-cd.yaml index ecb9b40..225fe76 100644 --- a/.gitea/workflows/ci-cd.yaml +++ b/.gitea/workflows/ci-cd.yaml @@ -194,13 +194,13 @@ 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" + # Generate BDD coverage report + go tool cover -func=coverage.out > bdd_coverage.txt - # Extract BDD coverage percentage from the output - BDD_COVERAGE=$(echo "$test_output" | grep "coverage:" | grep -oP '\d+\.\d+' | head -1) + # 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 @@ -212,10 +212,13 @@ jobs: run: | echo "Running unit tests with PostgreSQL service..." # Run unit tests excluding BDD tests (already run above) - go test ./pkg/... ./cmd/... -coverprofile=coverage.out -v && go tool cover -func=coverage.out > coverage.txt + go test ./pkg/... ./cmd/... -coverprofile=unit_coverage.out -v + + # Generate unit coverage report + go tool cover -func=unit_coverage.out > unit_coverage.txt # Extract unit test coverage percentage - UNIT_COVERAGE=$(grep "total:" 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}%" # Update unit test coverage badge