Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: 🔨 Build

on:
push:
Expand All @@ -13,6 +13,7 @@ on:
jobs:

build:
name: 🔨 Build and Test
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -22,32 +23,34 @@ jobs:
packages: write

steps:
- name: Checkout
- name: 📥 Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node
- name: 🟢 Setup Node
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install dependencies
- name: 📦 Install Dependencies
run: npm ci

- name: Run tests
- name: 🧪 Run Tests
run: npm test

- name: Build
- name: 🔨 Build
run: npm run build

- name: Publish Delta Coverage
- name: 📈 Publish Delta Coverage
id: render-delta-coverage
uses: ./
with:
summary-report-base-path: 'test/data/'
suppress-check-failures: true

- id: upload-badges
- name: 📤 Upload Badges
id: upload-badges
uses: actions/upload-artifact@v4
with:
name: coverage-gen.svg
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Delta Coverage Action

## 1.4

- Suppressed coverage failures now use `neutral` check run conclusion (gray dash icon) instead of `success`.
PR comment shows `🟡` for suppressed failures, distinguishing them from genuinely passing checks (`🟢`).

## 1.3

- Fixed PR comment status inconsistent with check run conclusion.
Previously the comment re-derived failure status from `failOnViolation` flag and coverage thresholds,
which could disagree with the actual check run conclusion (e.g. when suppression is active or `failOnViolation` is disabled).
Now the comment uses `checkRun.conclusion` directly.

## 1.2

- Migrated from JS composite action to TypeScript Node20 action

## 1.1

- Added custom script to generate extra check run content
Expand Down
63 changes: 63 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# CLAUDE.md

## Project Overview

Delta Coverage Report GitHub Action (Node20). Creates check runs with coverage info from [Delta-Coverage Gradle plugin](https://github.com/gw-kit/delta-coverage-plugin) summary reports, posts PR comments with coverage tables, and generates SVG badges.

## Commands

```bash
npm ci # install dependencies
npm test # vitest + v8 coverage
npm run build # rm -rf dist && ncc bundle → dist/index.js
```

## Architecture

TypeScript Node20 action. Single entry point `src/main.ts` bundled via `@vercel/ncc` into `dist/index.js`.

```
src/
main.ts # Entry point: orchestrates the full pipeline
read-summaries.ts # Aggregates *-summary.json into single JSON
generate-badges.ts # Creates SVG badges from full coverage data
suppression.ts # Checks PR labels + input for failure suppression
create-check-runs.ts # Creates GitHub check runs via REST API
build-comment-body.ts # Builds HTML table for PR comment
pr-comments.ts # Finds/upserts PR comments
types/coverage.ts # Shared types: CoverageSummary, CheckRunResult, etc.
test/
*.test.ts # Vitest tests (54 tests, ~96.5% coverage)
data/ # Fixture JSONs (full-coverage-*, delta-coverage-*)
dist/
index.js # ncc bundle (committed)
```

**Pipeline:** readSummaries → generateBadges → checkSuppression → createCheckRuns → buildCommentBody → upsertComment

**Key conventions:**
- GitHub API adapter interfaces use `any` for params to stay compatible with Octokit types
- `build-comment-body.ts` accepts injectable `env` param for testability (defaults to `process.env`)
- Check run conclusions: `success` (no violations), `neutral` (violations suppressed), `failure` (violations present)
- PR comment status symbols: `🟢` success, `🟡` neutral (suppressed), `🔴` failure
- Tests mock `fs` via `vi.mock('fs', () => ({...}))` factory pattern

## Action Inputs

| Input | Default | Description |
|-------|---------|-------------|
| `title` | `📈 Δelta Coverage Check` | PR comment title (blank = new comment each time) |
| `summary-report-base-path` | `build/reports/coverage-reports/` | Where coverage JSONs are located |
| `suppress-check-failures` | `false` | Ignore failures (auto-true if PR has `suppress-coverage` label) |
| `github-token` | `${{ github.token }}` | GitHub authentication |
| `external-id` | `delta-coverage` | Check run identifier |
| `check-run-extra-render-script` | - | Custom JS function `(view) => string` for extra check run content |

## Required Permissions

```yaml
permissions:
issues: read
pull-requests: write
checks: write
```
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ Also, the action creates a comment in the pull request with links to the check r

## Inputs

- `title` (optional): The title of the comment. Default is `Delta Coverage Check`.
- `summary-report-path`: The path to the Delta-Coverage summary report json file.
- `suppress-check-failures` (optional): Suppress check run failures.
If a PR contains label `suppress-delta-coverage` then the default value is `true`, otherwise `false`.
Can be useful when you want to ignore coverage check failures.
- `github-token` (optional): The GitHub token to use for authentication.

If `title` is not blank then the previous comment generated by this action will be updated with the new report,
otherwise a new comment will be created.
| Input | Required | Default | Description |
|-------|----------|---------|-------------|
| `title` | No | `📈 Δelta Coverage Check` | PR comment title. If not blank, the previous comment is updated; otherwise a new comment is created. |
| `summary-report-base-path` | Yes | `build/reports/coverage-reports/` | Base path for all summary report JSON files. |
| `suppress-check-failures` | No | `false` | Suppress check run failures. Auto-set to `true` if PR has the `suppress-delta-coverage` label. |
| `github-token` | No | `${{ github.token }}` | GitHub token for authentication. |
| `external-id` | No | `delta-coverage` | External identifier for check runs. |
| `check-run-extra-render-script` | No | | Custom JS function `(view) => string` to render additional info in check runs. |

## Outputs

Expand Down
17 changes: 17 additions & 0 deletions dist/build-comment-body.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
interface SummaryBuilder {
addHeading(text: string, level: string): SummaryBuilder;
addRaw(text: string, addEOL?: boolean): SummaryBuilder;
addEOL(): SummaryBuilder;
stringify(): string;
}
export interface BuildCommentBodyParams {
checkRunsContent: string;
commentTitle: string;
commentMarker: string;
core: {
summary: SummaryBuilder;
};
env?: Record<string, string | undefined>;
}
export declare function buildCommentBody(params: BuildCommentBodyParams): string;
export {};
1 change: 1 addition & 0 deletions dist/build-comment-body.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions dist/create-check-runs.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { CoverageSummary, CheckRunResult } from './types/coverage';
export interface GitHubClient {
rest: {
checks: {
create(params: any): Promise<{
data: {
html_url: string | null;
};
}>;
};
};
}
export interface GitHubContext {
repo: {
owner: string;
repo: string;
};
}
export interface CoreLogger {
error(message: string): void;
}
export interface CreateCheckRunsParams {
summaryReportPath: string;
ignoreCoverageFailure: boolean;
core: CoreLogger;
context: GitHubContext;
github: GitHubClient;
headSha: string;
externalId: string;
summaryExtraFun?: (view: CoverageSummary) => string;
}
export declare function createCheckRuns(params: CreateCheckRunsParams): Promise<CheckRunResult[]>;
1 change: 1 addition & 0 deletions dist/create-check-runs.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions dist/generate-badges.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export interface GenerateBadgesParams {
summariesFile: string;
core: {
info(message: string): void;
setOutput(name: string, value: string): void;
};
outputDir?: string;
}
export declare function generateBadges(params: GenerateBadgesParams): void;
1 change: 1 addition & 0 deletions dist/generate-badges.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading