### Example GitHub Actions Workflow for Delta Coverage Source: https://github.com/gw-kit/delta-coverage-action/blob/main/README.md This YAML snippet demonstrates how to integrate the Delta Coverage Report GitHub Action into a GitHub Actions workflow. It specifies the job to run on an Ubuntu environment and sets the necessary permissions for the action to interact with issues, pull requests, and checks. ```yaml jobs: build: runs-on: ubuntu-latest permissions: issues: read pull-requests: write checks: write steps: - name: Publish Delta Coverage Report uses: gw-kit/delta-coverage-action@v1 with: github-token: ${{ secrets.GITHUB_TOKEN }} ``` -------------------------------- ### Read Coverage Summaries with TypeScript Source: https://context7.com/gw-kit/delta-coverage-action/llms.txt This TypeScript code snippet demonstrates how to use the `readSummaries` function to read and aggregate coverage summary JSON files. It shows examples for reading both delta coverage (for changed code) and full coverage (for badge generation) reports from a specified base path. ```typescript import { readSummaries } from './read-summaries'; // Read delta coverage summaries (for changed code) const deltaSummariesFile = readSummaries({ isFullCoverageMode: false, baseSummariesPath: 'build/reports/coverage-reports/', }); // Output: 'delta-cov-summaries.json' containing array of CoverageSummary objects // Read full coverage summaries (for badge generation) const fullCovSummariesFile = readSummaries({ isFullCoverageMode: true, baseSummariesPath: 'build/reports/coverage-reports/', }); // Output: 'full-cov-summaries.json' containing array of CoverageSummary objects // Expected file structure in baseSummariesPath: // - delta-coverage-test-summary.json -> included in delta mode // - delta-coverage-functionalTest-summary.json -> included in delta mode // - full-coverage-test-summary.json -> included in full mode // - full-coverage-aggregated-summary.json -> included in full mode ``` -------------------------------- ### Delta Coverage Action Inputs Reference (YAML) Source: https://context7.com/gw-kit/delta-coverage-action/llms.txt This YAML snippet provides a comprehensive reference for all available inputs to the Delta Coverage Action. It details parameters such as the PR comment title, base path for summary reports, suppression of check failures, GitHub token, external ID, and a custom rendering script. ```yaml # Full configuration with all inputs - name: Publish Delta Coverage Report uses: gw-kit/delta-coverage-action@v1 with: # PR comment title - if set, updates existing comment; if blank, creates new title: '📈 Δelta Coverage Check' # Base path where Delta-Coverage plugin writes summary JSON files summary-report-base-path: 'build/reports/coverage-reports/' # Suppress check failures - auto-set to true if PR has 'suppress-coverage' label suppress-check-failures: 'false' # GitHub token for API authentication github-token: ${{ secrets.GITHUB_TOKEN }} # External identifier for check runs external-id: 'delta-coverage' # Custom JS function to render additional info in check runs check-run-extra-render-script: '(view) => `Coverage for ${view.view}: ${view.coverageInfo[0].percents}%`' ``` -------------------------------- ### Configure Full Coverage Report in Gradle (Kotlin DSL) Source: https://github.com/gw-kit/delta-coverage-action/blob/main/README.md This code snippet shows how to enable the generation of a full coverage report within the Delta-Coverage plugin using Gradle's Kotlin DSL. This is a prerequisite for generating coverage badges. ```kotlin deltaCoverageReport { reports { fullCoverageReport = true } } ``` -------------------------------- ### Create GitHub Check Runs for Coverage Views Source: https://context7.com/gw-kit/delta-coverage-action/llms.txt The `createCheckRuns` function generates GitHub check runs for each coverage view. It displays detailed coverage information and determines pass/fail status based on configured coverage thresholds. This function requires GitHub API access and a summary report file. ```typescript import { createCheckRuns } from './create-check-runs'; const checkRuns = await createCheckRuns({ summaryReportPath: 'delta-cov-summaries.json', ignoreCoverageFailure: false, // Set to true to suppress failures core: { error: (msg) => console.error(msg), }, context: { repo: { owner: 'gw-kit', repo: 'delta-coverage-action' }, }, github: octokit, // GitHub API client from @actions/github headSha: 'abc123def456', externalId: 'delta-coverage', summaryExtraFun: (view) => `\n### Additional Info\nView: ${view.view}`, }); // Returns array of CheckRunResult: // [ // { // viewName: 'Test', // verifications: [], // coverageRules: { failOnViolation: true, entitiesRules: {...} }, // url: 'https://github.com/owner/repo/runs/123', // conclusion: 'success', // 'success' | 'failure' | 'neutral' // coverageInfo: [...] // } // ] ``` -------------------------------- ### Configure Delta Coverage Action in GitHub Workflow (YAML) Source: https://context7.com/gw-kit/delta-coverage-action/llms.txt This snippet shows how to integrate the Delta Coverage Action into a GitHub Actions workflow. It defines the trigger, job, and steps, including checking out code, running tests with coverage, and publishing the Delta Coverage Report using the action. ```yaml # .github/workflows/coverage.yml name: Coverage Check on: pull_request: branches: [main] jobs: coverage: runs-on: ubuntu-latest permissions: issues: read pull-requests: write checks: write steps: - uses: actions/checkout@v4 - name: Run tests with coverage run: ./gradlew test deltaCoverageReport - name: Publish Delta Coverage Report uses: gw-kit/delta-coverage-action@v1 with: github-token: ${{ secrets.GITHUB_TOKEN }} title: '📈 Δelta Coverage Check' summary-report-base-path: 'build/reports/coverage-reports/' suppress-check-failures: 'false' external-id: 'delta-coverage' ``` -------------------------------- ### Manage GitHub PR Comments Source: https://context7.com/gw-kit/delta-coverage-action/llms.txt This set of functions (`buildCommentMarker`, `findExistingComment`, `upsertComment`) facilitates the management of comments on GitHub pull requests. It allows for the creation of unique comment markers, searching for existing comments, and updating or creating comments to ensure update-in-place behavior. ```typescript import { buildCommentMarker, findExistingComment, upsertComment } from './pr-comments'; // Build a unique marker for identifying comments const marker = buildCommentMarker('📈 Δelta Coverage Check'); // Output: '' // Find existing comment containing the marker const existingCommentId = await findExistingComment({ github: octokit, context: { issue: { number: 42 }, repo: { owner: 'gw-kit', repo: 'delta-coverage-action' }, }, marker: marker, }); // Output: 12345 (comment ID) or undefined if not found // Create or update comment await upsertComment({ github: octokit, context: { issue: { number: 42 }, repo: { owner: 'gw-kit', repo: 'delta-coverage-action' }, }, existingCommentId: existingCommentId, // undefined = create new, number = update body: '

📈 Δelta Coverage Check

...', }); ``` -------------------------------- ### Build PR Comment Body with Coverage Summary Source: https://context7.com/gw-kit/delta-coverage-action/llms.txt The `buildCommentBody` function constructs the HTML content for a pull request comment. It includes a coverage summary table that displays the status of check runs, expected thresholds, and actual coverage achieved. This function processes an array of check run results. ```typescript import { buildCommentBody } from './build-comment-body'; const checkRuns = [ { viewName: 'Test', verifications: [], coverageRules: { failOnViolation: true, entitiesRules: { INSTRUCTION: { minCoverageRatio: 0.8 }, BRANCH: { minCoverageRatio: 0.5 }, LINE: { minCoverageRatio: 0.8 }, }, }, url: 'https://github.com/owner/repo/runs/123', conclusion: 'success', coverageInfo: [ { coverageEntity: 'INSTRUCTION', covered: 120, total: 150, percents: 80.0 }, { coverageEntity: 'BRANCH', covered: 30, total: 50, percents: 60.0 }, { coverageEntity: 'LINE', covered: 100, total: 120, percents: 83.33 }, ], }, ]; const body = buildCommentBody({ checkRunsContent: JSON.stringify(checkRuns), commentTitle: '📈 Δelta Coverage Check', commentMarker: '', core: { summary: { addHeading: (text, level) => ({ /* chainable */ }), addRaw: (text) => ({ /* chainable */ }), addEOL: () => ({ /* chainable */ }), stringify: () => '...rendered HTML...', }, }, }); // Output: HTML table with coverage info, status indicators (🟢/🔴/🟡), and workflow run link ``` -------------------------------- ### Generate SVG Coverage Badges Source: https://context7.com/gw-kit/delta-coverage-action/llms.txt The `generateBadges` function creates SVG badges for each test view, visualizing line coverage percentages with gradient colors. These badges are suitable for embedding in README files. The function takes a file containing coverage summaries and an optional output directory. ```typescript import { generateBadges } from './generate-badges'; generateBadges({ summariesFile: 'full-cov-summaries.json', core: { info: (msg) => console.log(msg), setOutput: (name, value) => console.log(`::set-output name=${name}::${value}`) }, outputDir: 'badges/', // Optional, defaults to 'badges/' }); // Generates badges in outputDir: // - badges/test.svg // - badges/functionalTest.svg // - badges/aggregated.svg // // Each badge shows view name and LINE coverage percentage with gradient colors // Output: "Generated badge for test at badges/test.svg" ``` -------------------------------- ### Delta Coverage Summary JSON Format Source: https://context7.com/gw-kit/delta-coverage-action/llms.txt This JSON structure represents the format of coverage summary files generated by the Delta-Coverage plugin. It includes details like the view name, report boundary, coverage rules configuration, verifications, and specific coverage metrics for different coverage entities. ```json { "view": "test", "reportBound": "DELTA_REPORT", "coverageRulesConfig": { "failOnViolation": true, "entitiesRules": { "INSTRUCTION": { "minCoverageRatio": 0.8 }, "BRANCH": { "minCoverageRatio": 0.5 }, "LINE": { "minCoverageRatio": 0.8 } } }, "verifications": [], "coverageInfo": [ { "coverageEntity": "INSTRUCTION", "covered": 120, "total": 150, "percents": 80.0 }, { "coverageEntity": "BRANCH", "covered": 30, "total": 50, "percents": 60.0 }, { "coverageEntity": "LINE", "covered": 100, "total": 120, "percents": 83.33 } ] } ``` -------------------------------- ### Check Coverage Failure Suppression Source: https://context7.com/gw-kit/delta-coverage-action/llms.txt The `checkSuppression` function determines if coverage failures should be suppressed. Suppression can be triggered by an input parameter (`suppressByInput`) or by the presence of a specific label ('suppress-coverage') on a pull request. It requires GitHub API access and the pull request number. ```typescript import { checkSuppression } from './suppression'; const suppress = await checkSuppression({ github: octokit, context: { repo: { owner: 'gw-kit', repo: 'delta-coverage-action' }, }, pullNumber: 42, suppressByInput: false, core: { info: (msg) => console.log(msg) }, }); // Returns true if: // - suppressByInput is true, OR // - PR has 'suppress-coverage' label // Output: "Is suppress=false : by label=false, by input=false" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.