ci: Fix mismatched paths on coverage collection #7
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Coverage (Nightly) | |
| on: | |
| schedule: | |
| # Run at 2 AM UTC every day | |
| - cron: '0 2 * * *' | |
| # Allow manual triggers for testing | |
| workflow_dispatch: | |
| # Allow being called from other workflows | |
| workflow_call: | |
| # Run on pull requests for testing | |
| pull_request: | |
| concurrency: | |
| group: coverage-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| compile: | |
| name: Build with Coverage | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Python 3.10 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.10" | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| - name: Install dependencies | |
| run: bash -x .github/scripts/setup.sh | |
| - name: Build with coverage instrumentation | |
| run: | | |
| ./configure --enable-debugbuild --enable-coverage CC=clang | |
| uv run make -j $(nproc) testpack.tar.bz2 | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: cln-coverage-build | |
| path: testpack.tar.bz2 | |
| test: | |
| name: Test (${{ matrix.name }}) | |
| runs-on: ubuntu-22.04 | |
| needs: compile | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: sqlite-1 | |
| db: sqlite3 | |
| pytest_par: 10 | |
| test_group: 1 | |
| test_group_count: 2 | |
| - name: sqlite-2 | |
| db: sqlite3 | |
| pytest_par: 10 | |
| test_group: 2 | |
| test_group_count: 2 | |
| - name: postgres-1 | |
| db: postgres | |
| pytest_par: 10 | |
| test_group: 1 | |
| test_group_count: 2 | |
| - name: postgres-2 | |
| db: postgres | |
| pytest_par: 10 | |
| test_group: 2 | |
| test_group_count: 2 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Python 3.10 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.10" | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| - name: Install dependencies | |
| run: bash -x .github/scripts/setup.sh | |
| - name: Install Bitcoin Core | |
| run: bash -x .github/scripts/install-bitcoind.sh | |
| - name: Download build artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: cln-coverage-build | |
| - name: Unpack build | |
| run: tar -xaf testpack.tar.bz2 | |
| - name: Verify coverage instrumentation | |
| run: | | |
| echo "Checking if binaries are instrumented for coverage..." | |
| if nm lightningd/lightningd | grep -q '__llvm_profile'; then | |
| echo "✓ Binaries appear to be instrumented for coverage" | |
| else | |
| echo "⚠ WARNING: Binaries may not be properly instrumented" | |
| echo "Checking build flags in config.vars:" | |
| grep -E "COVERAGE|CFLAGS" config.vars || echo "No coverage flags found" | |
| fi | |
| - name: Run tests with coverage | |
| env: | |
| TEST_DB_PROVIDER: ${{ matrix.db }} | |
| PYTEST_PAR: ${{ matrix.pytest_par }} | |
| SLOW_MACHINE: 1 | |
| TIMEOUT: 900 | |
| VALGRIND: 0 | |
| run: | | |
| export CLN_COVERAGE_DIR="${{ github.workspace }}/coverage-raw" | |
| mkdir -p "$CLN_COVERAGE_DIR" | |
| echo "CLN_COVERAGE_DIR=$CLN_COVERAGE_DIR" | |
| echo "Running test group ${{ matrix.test_group }} of ${{ matrix.test_group_count }}" | |
| echo "Current directory: $(pwd)" | |
| ls -la | |
| VALGRIND=0 uv run eatmydata pytest tests/ -n ${PYTEST_PAR} -vvv \ | |
| --test-group-count ${{ matrix.test_group_count }} \ | |
| --test-group ${{ matrix.test_group }} | |
| - name: Check coverage files generated | |
| if: always() | |
| run: | | |
| echo "Checking for profraw files in coverage-raw" | |
| find "${{ github.workspace }}/coverage-raw" -name "*.profraw" -ls || echo "No profraw files found" | |
| COUNT=$(find "${{ github.workspace }}/coverage-raw" -name "*.profraw" 2>/dev/null | wc -l) | |
| echo "Total profraw files: $COUNT" | |
| if [ "$COUNT" -eq 0 ]; then | |
| echo "WARNING: No coverage data was generated!" | |
| echo "This might indicate:" | |
| echo " 1. Tests didn't run successfully" | |
| echo " 2. Binaries aren't instrumented" | |
| echo " 3. LLVM_PROFILE_FILE environment variable not set correctly" | |
| fi | |
| - name: Install LLVM tools for merging | |
| if: always() | |
| run: | | |
| wget https://apt.llvm.org/llvm.sh | |
| chmod +x llvm.sh | |
| sudo ./llvm.sh 18 | |
| sudo ln -sf /usr/bin/llvm-profdata-18 /usr/bin/llvm-profdata | |
| - name: Merge coverage data locally | |
| if: always() | |
| run: | | |
| cd ${{ github.workspace }} | |
| echo "Current directory: $(pwd)" | |
| ls -la contrib/coverage/ || echo "contrib/coverage directory not found" | |
| chmod +x contrib/coverage/collect-coverage.sh | |
| mkdir -p coverage | |
| CLN_COVERAGE_DIR="${{ github.workspace }}/coverage-raw" \ | |
| ./contrib/coverage/collect-coverage.sh \ | |
| coverage-raw \ | |
| coverage/${{ matrix.name }}.profdata | |
| echo "Merged profdata size:" | |
| ls -lh coverage/${{ matrix.name }}.profdata || echo "No profdata file created" | |
| # Clean up raw files to save disk space | |
| rm -rf coverage-raw/*.profraw | |
| echo "Cleaned up raw profraw files" | |
| - name: Upload coverage data | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: coverage-merged-${{ matrix.name }} | |
| path: coverage/${{ matrix.name }}.profdata | |
| if-no-files-found: warn | |
| report: | |
| name: Generate Coverage Report | |
| runs-on: ubuntu-22.04 | |
| needs: test | |
| if: always() | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install LLVM tools | |
| run: | | |
| wget https://apt.llvm.org/llvm.sh | |
| chmod +x llvm.sh | |
| sudo ./llvm.sh 18 | |
| sudo ln -sf /usr/bin/llvm-profdata-18 /usr/bin/llvm-profdata | |
| sudo ln -sf /usr/bin/llvm-cov-18 /usr/bin/llvm-cov | |
| - name: Download build artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: cln-coverage-build | |
| - name: Unpack build | |
| run: tar -xaf testpack.tar.bz2 | |
| - name: Download all coverage artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: coverage-merged-* | |
| path: coverage-artifacts | |
| - name: Merge coverage data | |
| run: | | |
| mkdir -p coverage | |
| # Find all .profdata files from test jobs | |
| PROFDATA_FILES=($(find coverage-artifacts -name "*.profdata")) | |
| echo "Found ${#PROFDATA_FILES[@]} profdata files from test jobs:" | |
| printf '%s\n' "${PROFDATA_FILES[@]}" | |
| if [ ${#PROFDATA_FILES[@]} -eq 0 ]; then | |
| echo "ERROR: No coverage data found" | |
| exit 1 | |
| fi | |
| # Merge all pre-aggregated profdata files into final merged.profdata | |
| echo "Merging ${#PROFDATA_FILES[@]} profdata files..." | |
| llvm-profdata merge -sparse "${PROFDATA_FILES[@]}" -o coverage/merged.profdata | |
| echo "Final merged profdata size:" | |
| ls -lh coverage/merged.profdata | |
| - name: Generate HTML report | |
| run: | | |
| cd ${{ github.workspace }} | |
| chmod +x contrib/coverage/generate-coverage-report.sh | |
| ./contrib/coverage/generate-coverage-report.sh | |
| - name: Upload to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: coverage/merged.profdata | |
| flags: integration-tests | |
| name: cln-nightly-coverage | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| fail_ci_if_error: false | |
| - name: Upload HTML report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-html-report | |
| path: coverage/html | |
| retention-days: 90 | |
| - name: Add summary to job | |
| run: | | |
| echo "## Coverage Summary" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| cat coverage/summary.txt >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "📊 Download detailed HTML report from workflow artifacts" >> $GITHUB_STEP_SUMMARY |