Improve fungible token coverage #1
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: "test coverage" | ||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| paths-ignore: | ||
| - "**.md" | ||
| pull_request: | ||
| paths-ignore: | ||
| - "**.md" | ||
| workflow_dispatch: | ||
| # If new code is pushed to a PR branch, then cancel in progress workflows for | ||
| # that PR. Ensures that we don't waste CI time, and returns results quicker. | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
| env: | ||
| # Not needed in CI, should make things a bit faster | ||
| CARGO_INCREMENTAL: 0 | ||
| CARGO_TERM_COLOR: always | ||
| # Remove unnecessary WASM build artifacts | ||
| WASM_BUILD_CLEAN_TARGET: 1 | ||
| # stripping symbols and optimizing for binary size | ||
| RUSTFLAGS: -C strip=symbols -C opt-level=s | ||
| # Enable sscache | ||
| RUSTC_WRAPPER: "sccache" | ||
| SCCACHE_GHA_ENABLED: "true" | ||
| SCCACHE_CACHE_SIZE: "50GB" | ||
| jobs: | ||
| test-coverage: | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: | ||
| - ubuntu-latest | ||
| runs-on: ${{ matrix.os }} | ||
| steps: | ||
| - name: git checkout | ||
| uses: actions/checkout@v4 | ||
| - name: Run sccache | ||
| uses: mozilla-actions/sccache-action@v0.0.4 | ||
| - name: install rust toolchain | ||
| uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
| with: | ||
| toolchain: stable | ||
| components: llvm-tools-preview | ||
| target: wasm32-unknown-unknown | ||
| - name: Install cargo-llvm-cov | ||
| uses: taiki-e/install-action@v2 | ||
| with: | ||
| tool: cargo-llvm-cov | ||
| - name: Generate code coverage report | ||
| run: | | ||
| cargo llvm-cov --workspace --lcov --output-path lcov.info --ignore-filename-regex "test\.rs" --fail-under-lines 90 | ||
| - name: Generate detailed text coverage report | ||
| run: | | ||
| cargo llvm-cov --text --ignore-filename-regex "test\.rs" --package stellar-fungible > coverage-report.txt | ||
| echo "Coverage report generated at coverage-report.txt" | ||
| # Extract branch coverage and verify threshold | ||
| if grep -q "TOTAL.*branches" coverage-report.txt; then | ||
| BRANCH_COVERAGE=$(grep "TOTAL.*branches" coverage-report.txt | awk '{print $NF}' | sed 's/%//') | ||
| echo "Branch coverage: $BRANCH_COVERAGE%" | ||
| if (( $(echo "$BRANCH_COVERAGE < 85" | bc -l) )); then | ||
| echo "::error::Branch coverage $BRANCH_COVERAGE% is below the target of 85%" | ||
| echo "Uncovered branches:" | ||
| cat coverage-report.txt | grep -B 1 "\^" || echo "No specific uncovered branches found!" | ||
| exit 1 | ||
| else | ||
| echo "Branch coverage meets target: $BRANCH_COVERAGE% ≥ 85%" | ||
| fi | ||
| else | ||
| echo "Branch coverage information not available in this version of cargo-llvm-cov" | ||
| BRANCH_COVERAGE="Not available" | ||
| fi | ||
| # Create a job summary with coverage stats | ||
| echo "## Coverage Summary" >> $GITHUB_STEP_SUMMARY | ||
| echo "📊 **Coverage Report for stellar-fungible**" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| LINE_COVERAGE=$(grep "TOTAL.*lines" coverage-report.txt | awk '{print $NF}') | ||
| echo "- Line coverage: $LINE_COVERAGE" >> $GITHUB_STEP_SUMMARY | ||
| echo "- Branch coverage: $BRANCH_COVERAGE%" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "Files with uncovered lines:" >> $GITHUB_STEP_SUMMARY | ||
| echo '```' >> $GITHUB_STEP_SUMMARY | ||
| grep -B 1 "\^" coverage-report.txt | grep -v -- "^--$" | head -20 >> $GITHUB_STEP_SUMMARY || echo "No uncovered lines found!" >> $GITHUB_STEP_SUMMARY | ||
| echo '```' >> $GITHUB_STEP_SUMMARY | ||
| - name: Upload coverage report artifact | ||
| uses: actions/upload-artifact@v3 | ||
| with: | ||
| name: coverage-report | ||
| path: | | ||
| coverage-report.txt | ||
| lcov.info | ||
| retention-days: 14 | ||
| - name: Upload coverage report to Codecov | ||
| # Only run if the Codecov token is configured | ||
| if: ${{ secrets.CODECOV_TOKEN != '' }} | ||
|
Check failure on line 111 in .github/workflows/coverage.yml
|
||
| continue-on-error: true # Don't fail the workflow if Codecov upload fails | ||
| uses: codecov/codecov-action@v3 | ||
| with: | ||
| token: ${{ secrets.CODECOV_TOKEN }} | ||
| files: lcov.info | ||
| fail_ci_if_error: false # Don't fail even if the Codecov upload fails | ||