Envoy schema 29 -> DERCapability Non subscribable #345
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: Coverage Comparison | |
| on: | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| coverage_source: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| source_raw: ${{ steps.extract.outputs.raw }} | |
| steps: | |
| - name: Checkout (source branch) | |
| uses: actions/[email protected] | |
| - name: Setup Python | |
| uses: actions/[email protected] | |
| with: | |
| python-version: "3.11" | |
| - name: Install Dependencies | |
| run: | | |
| sudo apt install -y postgresql | |
| pip install --ignore-installed .[dev,test] | |
| pip install pytest-cov pytest-xdist | |
| - name: Coverage (source branch) | |
| run: | | |
| echo "[run]" > .coveragecfg | |
| echo "data_file=.coverage-source" >> .coveragecfg | |
| pytest -n auto --cov=envoy --cov-config=.coveragecfg . | |
| - name: Extract Coverage | |
| id: extract | |
| run: | | |
| echo 'raw<<EOF' >> $GITHUB_OUTPUT | |
| coverage report --data-file=.coverage-source --omit='tests/**' >> $GITHUB_OUTPUT | |
| echo EOF >> $GITHUB_OUTPUT | |
| coverage html --data-file=.coverage-source --omit='tests/**' | |
| - name: Upload Target Coverage HTML Report Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: source-code-coverage-html | |
| path: htmlcov/ | |
| overwrite: true | |
| coverage_target: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| target_raw: ${{ steps.extract.outputs.raw }} | |
| steps: | |
| - name: Checkout (target branch) | |
| uses: actions/[email protected] | |
| with: | |
| ref: ${{ github.base_ref }} | |
| - name: Setup Python | |
| uses: actions/[email protected] | |
| with: | |
| python-version: "3.11" | |
| - name: Install Dependencies | |
| run: | | |
| sudo apt install -y postgresql | |
| pip install --ignore-installed .[dev,test] | |
| pip install pytest-cov pytest-xdist | |
| - name: Coverage (target branch) | |
| run: | | |
| echo "[run]" > .coveragecfg | |
| echo "data_file=.coverage-target" >> .coveragecfg | |
| pytest -n auto --cov=envoy --cov-config=.coveragecfg . | |
| - name: Extract Coverage | |
| id: extract | |
| run: | | |
| echo 'raw<<EOF' >> $GITHUB_OUTPUT | |
| coverage report --data-file=.coverage-target --omit='tests/**' >> $GITHUB_OUTPUT | |
| echo EOF >> $GITHUB_OUTPUT | |
| coverage html --data-file=.coverage-target --omit='tests/**' | |
| - name: Upload Target Coverage HTML Report Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: target-code-coverage-html | |
| path: htmlcov/ | |
| overwrite: true | |
| compare_coverage: | |
| runs-on: ubuntu-latest | |
| needs: [coverage_source, coverage_target] | |
| env: | |
| SOURCE_RAW: ${{ needs.coverage_source.outputs.source_raw }} | |
| TARGET_RAW: ${{ needs.coverage_target.outputs.target_raw }} | |
| ISSUE_NUMBER: ${{ github.event.number }} | |
| steps: | |
| - uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const { SOURCE_RAW, TARGET_RAW, GITHUB_BASE_REF, GITHUB_HEAD_REF, ISSUE_NUMBER } = process.env | |
| // returns dict keyed by file name with code coverage percent integers | |
| function split_coverage(raw) { | |
| let result = {}; | |
| for (let l of raw.split('\n')) { | |
| if (l && l.endsWith('%')) { | |
| let line_parts = l.split(' '); | |
| result[line_parts[0]] = parseInt(line_parts.pop()); | |
| } | |
| } | |
| return result; | |
| } | |
| const source = split_coverage(SOURCE_RAW) | |
| const target = split_coverage(TARGET_RAW) | |
| const source_total_percent = source["TOTAL"] | |
| const target_total_percent = target["TOTAL"] | |
| const file_reductions = [] | |
| for (let [k, target_pc] of Object.entries(target)) { | |
| if (k in source) { | |
| source_pc = source[k] | |
| if (source_pc < target_pc) { | |
| let diff = target_pc - source_pc | |
| file_reductions.push(`|\`${k}\` | π» ${diff}% (${target_pc}% β ${source_pc}%) |`) | |
| } | |
| } | |
| } | |
| const file_adds = [] | |
| for (let [k, source_pc] of Object.entries(source)) { | |
| if (!(k in target)) { | |
| if (source_pc >= target_total_percent) { | |
| file_adds.push(`|\`${k}\` | β Coverage at ${source_pc}% |`) | |
| } else { | |
| file_adds.push(`|\`${k}\` | β οΈ Coverage at ${source_pc}% |`) | |
| } | |
| } | |
| } | |
| let body = '' | |
| if (source_total_percent >= target_total_percent) { | |
| body += `β Code coverage on \`${GITHUB_HEAD_REF}\` is at ${source_total_percent}% (compared to \`${GITHUB_BASE_REF}\` being at ${target_total_percent}%)\n` | |
| } else { | |
| body += `π Code coverage on \`${GITHUB_HEAD_REF}\` has **reduced** to ${source_total_percent}% (compared to \`${GITHUB_BASE_REF}\` being at ${target_total_percent}%)\n` | |
| } | |
| if (file_reductions.length > 0) { | |
| body += "## File Reductions\n" | |
| body += "| File | Details |\n" | |
| body += "| ---- | ------- |\n" | |
| body += file_reductions.join("\n") | |
| } else { | |
| body += "\nπ No files have reduced coverage π\n" | |
| } | |
| if (file_adds.length > 0) { | |
| body += "\n<details>\n" | |
| body += "<summary><h2>Coverage for new files</h2></summary>\n\n" | |
| body += "| File | Details |\n" | |
| body += "| ---- | ------- |\n" | |
| body += file_adds.join("\n") | |
| body += "\n</details>\n" | |
| } | |
| body += "\n<details>\n" | |
| body += "<summary><h2>Full Coverage Report</h2></summary>\n\n" | |
| body += "| File | Details |\n" | |
| body += "| ---- | ------- |\n" | |
| for (let [k, source_pc] of Object.entries(source)) { | |
| if (k in target) { | |
| target_pc = target[k] | |
| if (source_pc < target_pc) { | |
| let diff = target_pc - source_pc | |
| body += `|\`${k}\` | π» ${diff}% (${target_pc}% β ${source_pc}%) |\n` | |
| } else { | |
| body += `|\`${k}\` | β ${target_pc}% β ${source_pc}% |\n` | |
| } | |
| } else { | |
| body += `|\`${k}\` | π ${source_pc}% |\n` | |
| } | |
| } | |
| body += "\n</details>\n" | |
| const fs = require('fs'); | |
| fs.mkdirSync("coverage-report-data/"); | |
| fs.writeFileSync("coverage-report-data/coverage-report.txt", body); | |
| fs.writeFileSync("coverage-report-data/issue-number.txt", ISSUE_NUMBER); | |
| - name: Upload Coverage Report Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: code-coverage-report | |
| path: coverage-report-data/ | |
| overwrite: true |