|  | 
|  | 1 | +name: Code Coverage | 
|  | 2 | + | 
|  | 3 | +on: | 
|  | 4 | +  push: | 
|  | 5 | +    branches: [ | 
|  | 6 | +      "master", | 
|  | 7 | +      "test_ci" | 
|  | 8 | +    ] | 
|  | 9 | +  pull_request: | 
|  | 10 | + | 
|  | 11 | +env: | 
|  | 12 | +  CARGO_TERM_COLOR: always | 
|  | 13 | + | 
|  | 14 | +jobs: | 
|  | 15 | +  coverage: | 
|  | 16 | +    name: Code Coverage | 
|  | 17 | +    runs-on: ubuntu-latest | 
|  | 18 | +    env: | 
|  | 19 | +      RUSTFLAGS: "-Cinstrument-coverage" | 
|  | 20 | +      RUSTDOCFLAGS: "-Cinstrument-coverage" | 
|  | 21 | +      LLVM_PROFILE_FILE: "./target/coverage/%p-%m.profraw" | 
|  | 22 | + | 
|  | 23 | +    steps: | 
|  | 24 | +      - name: Checkout | 
|  | 25 | +        uses: actions/checkout@v4 | 
|  | 26 | +        with: | 
|  | 27 | +          persist-credentials: false | 
|  | 28 | +      - name: Install lcov tools | 
|  | 29 | +        run: sudo apt-get install lcov -y | 
|  | 30 | +      - name: Install Rust toolchain | 
|  | 31 | +        uses: dtolnay/rust-toolchain@v1 | 
|  | 32 | +        with: | 
|  | 33 | +            toolchain: stable | 
|  | 34 | +            components: llvm-tools-preview | 
|  | 35 | +      - name: Rust Cache | 
|  | 36 | + | 
|  | 37 | +      - name: Install grcov | 
|  | 38 | +        run: if [[ ! -e ~/.cargo/bin/grcov ]]; then cargo install grcov; fi | 
|  | 39 | +      - name: Test | 
|  | 40 | +        run: cargo test --all-features | 
|  | 41 | +      - name: Make coverage directory | 
|  | 42 | +        run: mkdir target/debug/coverage | 
|  | 43 | +      - name: Run grcov | 
|  | 44 | +        run: grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore '/*' --ignore '**/tests/**' --ignore '**/examples/**' -o ./target/debug/coverage/lcov.info | 
|  | 45 | +      - name: Generate HTML report | 
|  | 46 | +        run: genhtml -o coverage-report -s --highlight --ignore-errors source --legend ./target/debug/coverage/lcov.info | 
|  | 47 | +      # - name: Coveralls upload | 
|  | 48 | +      #   uses: coverallsapp/github-action@master | 
|  | 49 | +      #   with: | 
|  | 50 | +      #     github-token: ${{ secrets.GITHUB_TOKEN }} | 
|  | 51 | +      # - name: Upload artifact | 
|  | 52 | +      #   uses: actions/upload-artifact@v4 | 
|  | 53 | +      #   with: | 
|  | 54 | +      #     name: coverage-report | 
|  | 55 | +      #     path: coverage-report | 
0 commit comments