|
| 1 | +name: Code Coverage |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + pages: write |
| 11 | + id-token: write |
| 12 | + |
| 13 | +concurrency: |
| 14 | + group: coverage-${{ github.ref }} |
| 15 | + cancel-in-progress: true |
| 16 | + |
| 17 | +jobs: |
| 18 | + coverage: |
| 19 | + name: Generate Coverage Report |
| 20 | + runs-on: ubuntu-latest |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Checkout |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Install Rust toolchain |
| 27 | + uses: dtolnay/rust-toolchain@stable |
| 28 | + with: |
| 29 | + components: llvm-tools-preview |
| 30 | + |
| 31 | + - name: Setup Rust cache |
| 32 | + uses: Swatinem/rust-cache@v2 |
| 33 | + |
| 34 | + - name: Install cargo-tarpaulin |
| 35 | + uses: taiki-e/install-action@v2 |
| 36 | + with: |
| 37 | + tool: cargo-tarpaulin |
| 38 | + |
| 39 | + - name: Install system dependencies |
| 40 | + run: | |
| 41 | + sudo apt-get update |
| 42 | + sudo apt-get install -y libssl-dev pkg-config |
| 43 | +
|
| 44 | + - name: Run coverage for native-tokio |
| 45 | + run: | |
| 46 | + cargo tarpaulin \ |
| 47 | + --package oo7 \ |
| 48 | + --lib \ |
| 49 | + --features "tracing,tokio" \ |
| 50 | + --ignore-panics \ |
| 51 | + --out Lcov \ |
| 52 | + --output-dir coverage-raw \ |
| 53 | + --lcov-output-path coverage-raw/native-tokio.lcov \ |
| 54 | + -- --skip dbus |
| 55 | +
|
| 56 | + - name: Run coverage for openssl-async-std |
| 57 | + run: | |
| 58 | + cargo tarpaulin \ |
| 59 | + --package oo7 \ |
| 60 | + --lib \ |
| 61 | + --features "tracing,async-std,openssl" \ |
| 62 | + --ignore-panics \ |
| 63 | + --out Lcov \ |
| 64 | + --output-dir coverage-raw \ |
| 65 | + --lcov-output-path coverage-raw/openssl-async-std.lcov \ |
| 66 | + -- --skip dbus |
| 67 | +
|
| 68 | + - name: Install grcov for merging coverage |
| 69 | + uses: taiki-e/install-action@v2 |
| 70 | + with: |
| 71 | + tool: grcov |
| 72 | + |
| 73 | + - name: Merge coverage and generate HTML report |
| 74 | + run: | |
| 75 | + mkdir -p site/coverage |
| 76 | +
|
| 77 | + # Merge LCOV files |
| 78 | + cat coverage-raw/*.lcov > coverage-raw/combined.lcov |
| 79 | +
|
| 80 | + # Generate HTML report with grcov |
| 81 | + grcov coverage-raw/combined.lcov \ |
| 82 | + --binary-path target/debug/ \ |
| 83 | + --source-dir . \ |
| 84 | + --output-type html \ |
| 85 | + --output-path site/coverage \ |
| 86 | + --branch \ |
| 87 | + --ignore-not-existing \ |
| 88 | + --ignore "**/tests/*" \ |
| 89 | + --ignore "**/examples/*" \ |
| 90 | + --ignore "**/target/*" |
| 91 | +
|
| 92 | + - name: Setup Pages |
| 93 | + if: github.ref == 'refs/heads/main' |
| 94 | + uses: actions/configure-pages@v4 |
| 95 | + |
| 96 | + - name: Upload to GitHub Pages |
| 97 | + if: github.ref == 'refs/heads/main' |
| 98 | + uses: actions/upload-pages-artifact@v3 |
| 99 | + with: |
| 100 | + path: site/ |
| 101 | + |
| 102 | + - name: Upload coverage artifacts |
| 103 | + uses: actions/upload-artifact@v4 |
| 104 | + with: |
| 105 | + name: coverage-reports |
| 106 | + path: site/coverage/ |
| 107 | + retention-days: 30 |
| 108 | + |
| 109 | + deploy: |
| 110 | + name: Deploy to GitHub Pages |
| 111 | + runs-on: ubuntu-latest |
| 112 | + needs: coverage |
| 113 | + if: github.ref == 'refs/heads/main' |
| 114 | + |
| 115 | + environment: |
| 116 | + name: github-pages |
| 117 | + url: ${{ steps.deployment.outputs.page_url }}coverage/ |
| 118 | + |
| 119 | + steps: |
| 120 | + - name: Deploy to GitHub Pages |
| 121 | + id: deployment |
| 122 | + uses: actions/deploy-pages@v4 |
0 commit comments