From 4d1216d35a3e9525a19dbd8a8d5e722c870c0c79 Mon Sep 17 00:00:00 2001 From: dshukertjr Date: Tue, 25 Mar 2025 01:54:32 +0900 Subject: [PATCH 1/3] Add debug commands --- .github/workflows/coverage.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 8f32fe19..672fae4e 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -13,6 +13,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch all history for proper source code mapping - uses: subosito/flutter-action@v2 with: @@ -89,8 +91,36 @@ jobs: run: | dart pub global run combine_coverage:combine_coverage --repo-path="./" --output-directory="coverage" + - name: Prepare coverage for Coveralls + run: | + # Make sure source file paths are correct in the LCOV file + echo "LCOV file contents (first few lines):" + head -n 20 ./coverage/lcov.info + + # Check if source files exist in the expected locations + grep -A 1 "SF:" ./coverage/lcov.info | head -n 10 + + # Verify file paths in the repository + find . -type f -name "*.dart" | head -n 10 + + # If needed, fix paths by ensuring they're relative to the workspace instead of absolute + # This pattern replaces absolute paths and ensures paths are relative to repo root + sed -i -E 's|SF:(/[^/]+)*?/packages/|SF:packages/|g' ./coverage/lcov.info + + echo "Updated LCOV file contents (first few lines):" + head -n 20 ./coverage/lcov.info + + # Create a list of source files that are referenced in the LCOV file + echo "Creating list of source files referenced in LCOV" + grep "SF:" ./coverage/lcov.info | sed 's/SF://' | sort > source_files.txt + echo "First 10 source files referenced:" + head -n 10 source_files.txt + - name: Upload combined coverage report uses: coverallsapp/github-action@v2 with: github-token: ${{ secrets.GITHUB_TOKEN }} path-to-lcov: ./coverage/lcov.info + base-path: ${{ github.workspace }} + flag-name: Unit + debug: true From 86f5f95fa8526b8ffdfd957098533dc12bf349fe Mon Sep 17 00:00:00 2001 From: dshukertjr Date: Tue, 25 Mar 2025 02:17:41 +0900 Subject: [PATCH 2/3] update base path --- .github/workflows/coverage.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 672fae4e..f804aea6 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -121,6 +121,4 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} path-to-lcov: ./coverage/lcov.info - base-path: ${{ github.workspace }} flag-name: Unit - debug: true From 8c4552536aab90481349d2e4e4a9dd50a8081acf Mon Sep 17 00:00:00 2001 From: dshukertjr Date: Wed, 26 Mar 2025 00:17:01 +0900 Subject: [PATCH 3/3] check source file location within workflow --- .github/workflows/coverage.yml | 72 ++++++++++++++++++++++++++-------- 1 file changed, 56 insertions(+), 16 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index f804aea6..e366c2e1 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -13,8 +13,6 @@ jobs: steps: - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Fetch all history for proper source code mapping - uses: subosito/flutter-action@v2 with: @@ -94,27 +92,69 @@ jobs: - name: Prepare coverage for Coveralls run: | # Make sure source file paths are correct in the LCOV file - echo "LCOV file contents (first few lines):" + echo "Original LCOV file contents (first few lines):" head -n 20 ./coverage/lcov.info - # Check if source files exist in the expected locations - grep -A 1 "SF:" ./coverage/lcov.info | head -n 10 + # Check current paths in LCOV file + echo "Original source file paths in LCOV:" + grep -e "^SF:" ./coverage/lcov.info | head -n 10 + + # First, ensure all paths are correctly pointing to package sources + # This specifically fixes paths for combined package coverage + # Replace paths like "lib/file.dart" with "packages/package_name/lib/file.dart" + cp ./coverage/lcov.info ./coverage/lcov.info.bak - # Verify file paths in the repository - find . -type f -name "*.dart" | head -n 10 + # Extract package names from LCOV + echo "Extracting package names from LCOV..." + PACKAGES=$(grep -e "^SF:" ./coverage/lcov.info | grep -o "packages/[^/]*" | sort -u) + echo "Found packages: $PACKAGES" - # If needed, fix paths by ensuring they're relative to the workspace instead of absolute - # This pattern replaces absolute paths and ensures paths are relative to repo root - sed -i -E 's|SF:(/[^/]+)*?/packages/|SF:packages/|g' ./coverage/lcov.info + # Fix paths that are missing the correct package prefix + echo "Normalizing paths in LCOV file..." + while IFS= read -r line; do + if [[ "$line" =~ ^SF: ]]; then + path="${line#SF:}" + # If the path doesn't start with "packages/" and isn't a relative path + if [[ ! "$path" == packages/* && ! "$path" == ./packages/* && "$path" == lib/* ]]; then + # Look for the right package for this file + for pkg in $PACKAGES; do + pkg_name="${pkg#packages/}" + if grep -q "^SF:$pkg/lib" ./coverage/lcov.info; then + # Add the correct package prefix to the path + echo "SF:$pkg/$path" >> ./coverage/lcov.info.fixed + continue 2 + fi + done + # If we can't determine the package, just keep the original line + echo "$line" >> ./coverage/lcov.info.fixed + else + # Path already has package prefix or is relative, keep as is + echo "$line" >> ./coverage/lcov.info.fixed + fi + else + # Non-SF lines, copy as is + echo "$line" >> ./coverage/lcov.info.fixed + fi + done < ./coverage/lcov.info - echo "Updated LCOV file contents (first few lines):" + # Replace the original with the fixed version + mv ./coverage/lcov.info.fixed ./coverage/lcov.info + + # Ensure all paths start with ./ + sed -i 's|^SF:packages/|SF:./packages/|g' ./coverage/lcov.info + sed -i 's|^SF:\([^.]\)|SF:./\1|g' ./coverage/lcov.info + + echo "Final LCOV file contents (first few lines):" head -n 20 ./coverage/lcov.info - # Create a list of source files that are referenced in the LCOV file - echo "Creating list of source files referenced in LCOV" - grep "SF:" ./coverage/lcov.info | sed 's/SF://' | sort > source_files.txt - echo "First 10 source files referenced:" - head -n 10 source_files.txt + echo "Final source file paths in LCOV:" + grep -e "^SF:" ./coverage/lcov.info | head -n 10 + + # Verify existence of the referenced source files + echo "Verifying existence of source files..." + for file in $(grep -e "^SF:" ./coverage/lcov.info | sed 's/^SF://' | head -n 10); do + echo "Checking $file: $(test -f "$file" && echo "FOUND" || echo "NOT FOUND")" + done - name: Upload combined coverage report uses: coverallsapp/github-action@v2