Skip to content

Commit

Permalink
add code coverage to pipeline (#1745)
Browse files Browse the repository at this point in the history
* add code coverage to pipeline

* exclude migrations

* add codecov badge

---------

Co-authored-by: William Freudenberger <[email protected]>
Co-authored-by: Luis Enrique Muñoz Martín <[email protected]>
  • Loading branch information
3 people authored Apr 2, 2024
1 parent 1a9e385 commit ccb6d3f
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .github/actions/prep-ubuntu/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ runs:

- name: Disable cache on forks and dependabot
if: github.event_name == 'pull_request'
shell: sh
shell: bash
run: |
if [ "${{ github.event.pull_request.head.repo.fork }}" == "true" ] || \
[ "${{ github.actor }}" == "dependabot[bot]" ] || \
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
on:
push:
branches: [main]
pull_request:
name: Code coverage
concurrency:
group: 'codecov-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
permissions:
id-token: write
contents: read
jobs:
codecov:
runs-on: ubuntu-latest-8-cores
if: github.event.pull_request.draft == false || github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@master

- name: Prep build
uses: ./.github/actions/prep-ubuntu
with:
cache: enabled
# Cache needs Google credentials:
GWIP: ${{ secrets.GWIP_SCCACHE }}
GSA: ${{ secrets.GSA_SCCACHE }}

- name: Install Tarpaulin
run: cargo install --locked cargo-tarpaulin

- name: generate codecov reports
env:
RUST_BACKTRACE: 1
run: |
cargo tarpaulin --timeout 300 -e runtime-integration-tests --features fast-runtime \
--exclude-files runtime/*/src/migrations.rs --exclude-files runtime/common/src/migrations \
--exclude-files pallets/rewards/src/migrations/new_instance.rs --exclude-files pallets/block-rewards/src/migrations.rs \
--workspace --exclude-files **/mock.rs **/weights.rs **/weights/* --out xml
# UPLOAD REPORTS (requires cargo 1.70.0)
- name: Upload to codecov.io
if: ${{ always() }}
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
# token: ${{ secrets.CODECOV_TOKEN }}
# files: ./coverage1.xml,./coverage2.xml # optional
# flags: unittests # optional
# name: codecov-umbrella # optional
fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)
44 changes: 0 additions & 44 deletions .github/workflows/xperimental-codecov.yml.commented

This file was deleted.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<div align="center">

[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/centrifuge/centrifuge-chain/build-wasm.yml?label=Actions&logo=github)](https://github.com/centrifuge/centrifuge-chain/actions)
[![codecov](https://codecov.io/gh/centrifuge/centrifuge-chain/graph/badge.svg?token=RXlH3AJMRB)](https://codecov.io/gh/centrifuge/centrifuge-chain)
[![GitHub Release](https://img.shields.io/github/v/release/centrifuge/centrifuge-chain)](https://github.com/centrifuge/centrifuge-chain/releases)
[![Substrate version](https://img.shields.io/badge/Substrate-2.0.0-brightgreen?logo=Parity%20Substrate)](https://substrate.io/)
[![License](https://img.shields.io/github/license/centrifuge/centrifuge-chain?color=green)](https://github.com/centrifuge/centrifuge-chain/blob/main/LICENSE)
Expand Down

0 comments on commit ccb6d3f

Please sign in to comment.