/ .github / workflows / codecov.yml
codecov.yml
 1  name: Code Coverage
 2  on:
 3    schedule:
 4      - cron: '0 15 * * 0'  # Sunday 15:00 UTC (7am or 8am Pacific time)
 5  env:
 6    RUST_BACKTRACE: 0
 7  
 8  jobs:
 9    codecov:
10      name: Run Code Coverage
11      runs-on: ubuntu-latest
12      env:
13        RUSTC_BOOTSTRAP: 1
14      steps:
15        - name: Checkout
16          uses: actions/checkout@v2
17          with:
18            submodules: true
19  
20        - name: Install Rust
21          uses: actions-rs/toolchain@v1
22          with:
23            profile: minimal
24            toolchain: stable
25            override: true
26            components: rustfmt
27  
28        - name: Set up rust-cache
29          uses: Swatinem/rust-cache@v2
30  
31        - name: Test
32          uses: actions-rs/cargo@v1
33          with:
34            command: test
35            # Don't run tests in parallel because codecov with rayon will blow the stack.
36            args: --all --locked --profile ci --features only_testnet,leo-test-framework/no_parallel
37          env:
38            CARGO_INCREMENTAL: "0"
39  
40        - name: Install dependencies for code coverage
41          run: |
42            sudo apt-get update
43            sudo apt-get -y install binutils-dev libcurl4-openssl-dev zlib1g-dev libdw-dev libiberty-dev
44  
45        - name: Generate coverage report
46          run: |
47            wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz
48            tar xzf master.tar.gz
49            cd kcov-master
50            mkdir build && cd build
51            cmake .. && make
52            make install DESTDIR=../../kcov-build
53            cd ../..
54            rm -rf kcov-master
55            for file in target/ci/deps/*-*; do if [[ "$file" != *\.* ]]; then mkdir -p "target/cov/$(basename $file)"; ./kcov-build/usr/local/bin/kcov --exclude-pattern=/.cargo,/usr/lib --exclude-region='@kcov_skip(start):@kcov_skip(end)' --verify "target/cov/$(basename $file)" "$file"; fi done
56  
57        - name: Upload coverage to Codecov
58          uses: codecov/codecov-action@v3
59          with:
60            token: ${{ secrets.CODECOV_TOKEN }}