### 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: '