Skip to content

Conversation

@gluecksmelodie
Copy link
Collaborator

@gluecksmelodie gluecksmelodie commented Oct 29, 2025

Overview

Sets up code coverage collection and reporting for both Core (Stencil) and Angular packages in CI.

What's Included

Core Package

  • ✅ Coverage collection with Jest
  • ✅ Coverage artifacts uploaded (30 day retention)
  • ✅ Coverage summary displayed in GitHub Actions workflow
  • ✅ PR comments with diff (overall) coverage using lcov-reporter-action

Angular Package

  • ✅ Coverage collection with Karma
  • ✅ Coverage artifacts uploaded (30 day retention)
  • ✅ Coverage summary displayed in GitHub Actions workflow
  • ✅ PR comments with diff (overall) coverage using lcov-reporter-action
  • ✅ Fixed all failing tests (6 catalyst + 2 catalyst-demo = 8 passing)
  • ✅ ChromeHeadless configured for CI compatibility
  • ✅ karma-spec-reporter for better test output
  • ✅ All 3 projects tested (catalyst, catalyst-formly, catalyst-demo)

Security

  • Added minimal permissions (contents: read, pull-requests: write) following principle of least privilege
  • Addresses GitHub Advanced Security bot recommendation

Notes

  • Unfortunately, the coverage only considers unit tests, not e2e tests, as Stencil's E2E tests run in a browser via Puppeteer, so they don't contribute to Jest coverage. The more modern approach would be to use Playwright for e2e tests which supports coverage natively.
  • Coverage thresholds intentionally omitted for initial setup - can be added later once baseline is established
  • PR comments show the overall coverage diff for now so that we can see the coverage baseline in this PR
    • Can be adjusted later with filter-changed-files: true to only consider changed files
  • Both workflows include project-specific titles in coverage reports

What's Not Included

  • ❌ Enforcing a certain coverage threshold on PRs. I think a separate service is required for that (e.g. Codecov)

suppressPassed: false,
suppressSkipped: true,
showSpecTiming: false,
failFast: false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haiilo values detected :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! karma config file is so much better now

collectCoverage: true,
coverageDirectory: 'coverage',
coverageReporters: ['text', 'lcov', 'html', 'json-summary'],
coveragePathIgnorePatterns: ['/node_modules/', '/.stencil/', '/dist/', '/www/', '/loader/']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to use collectCoverageFrom in addition? for example only ts and tsx files

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good one! I added that so that test and type files are explicitly excluded from coverage.

This is from Copilot:

This gives cleaner coverage metrics focusing only on production code, not test files. You can tell your colleague this is a good suggestion and I've added it with the standard exclusion patterns for test files and type definitions.

😆

- name: Build dependencies
run: |
pnpm run build:tokens
pnpm run build:core
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you might also need to add

pnpm run build:angular
pnpm run build:angular-formly

to make tests work

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that was missing indeed :)

@gluecksmelodie gluecksmelodie changed the title ci(core): set up and report code coverage in CI ci(core): report code coverage in CI Oct 29, 2025
@haiilo haiilo deleted a comment from github-actions bot Oct 29, 2025
@gluecksmelodie gluecksmelodie marked this pull request as ready for review October 29, 2025 14:58
@glushkova91 glushkova91 mentioned this pull request Dec 5, 2025
anastasiia_glushkova added 5 commits December 8, 2025 08:51
# Conflicts:
#	.github/workflows/angular.yml
#	angular/package.json
#	angular/projects/catalyst-demo/karma.conf.js
#	angular/projects/catalyst-formly/karma.conf.js
#	angular/projects/catalyst/karma.conf.js
#	angular/projects/catalyst/src/lib/datetime/datetime.component.spec.ts
#	angular/projects/catalyst/src/lib/dialog/dialog.component.spec.ts
#	angular/projects/catalyst/src/lib/dialog/dialog.service.spec.ts
#	pnpm-lock.yaml
# Conflicts:
#	pnpm-lock.yaml
@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

LCOV of commit f88c2e0 during Core #1890

Summary coverage rate:
  lines......: 50.8% (1117 of 2198 lines)
  functions..: 43.6% (316 of 724 functions)
  branches...: no data found

Files changed coverage rate: n/a

⛔ The code coverage is too low: 50.82. Expected at least 70.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

Core Coverage Report

Coverage after merging ci/coverage-reporter into main will be
50.82%
Coverage Report for Changed Files
FileStmtsBranchesFuncsLinesUncovered Lines

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

Angular Coverage Report

Coverage after merging ci/coverage-reporter into main will be
25.26%
Coverage Report for Changed Files
FileStmtsBranchesFuncsLinesUncovered Lines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants