mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 14:30:41 +00:00
## Summary
Adds a GitHub Actions workflow + TypeScript script that posts to Slack
when a merged PR improves unit or E2E test coverage.
## Changes
- **What**: New `coverage-slack-notify.yaml` workflow triggered on push
to main. Compares current coverage against previous baselines, generates
Slack Block Kit payload with progress bars and milestone celebrations,
posts to `#p-frontend-automated-testing`.
- **Script**: `scripts/coverage-slack-notify.ts` — parses lcov files,
computes deltas, detects milestone crossings (every 5%), builds Slack
payload. Pure functions exported for testability.
- **Tests**: 26 unit tests in `scripts/coverage-slack-notify.test.ts`
covering all pure functions including edge cases (malformed lcov, exact
boundaries, zero coverage).
### Security hardening
- All `${{ }}` expressions moved from `run:` blocks to `env:` variables
- `SLACK_BOT_TOKEN` passed via env var, not inline
- Unique heredoc delimiter (timestamp-based) prevents payload injection
- `parseInt` fallback (`|| 0`) guards against malformed lcov
- PR regex anchored to first line of commit message
### Robustness
- `continue-on-error: true` on Slack post step (outage does not fail the
job)
- Baseline save guarded by `steps.unit-tests.outcome == success`
(prevents corrupt baselines on test failure)
- Channel ID commented for maintainability
- Top-level `text` field added for Slack mobile push notifications
- Author linked to GitHub profile instead of bare `@username`
## Review Focus
- Workflow step ordering and conditional logic
- Security of expression handling and secret management
- Slack payload structure and Block Kit formatting
┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-10977-feat-add-Slack-notification-workflow-for-coverage-improvements-33d6d73d3650819c8950f483c83f297c)
by [Unito](https://www.unito.io)
---------
Co-authored-by: GitHub Action <action@github.com>
30 lines
822 B
TypeScript
30 lines
822 B
TypeScript
import { config as dotenvConfig } from 'dotenv'
|
|
import MCR from 'monocart-coverage-reports'
|
|
|
|
import { writePerfReport } from '@e2e/helpers/perfReporter'
|
|
import { restorePath } from '@e2e/utils/backupUtils'
|
|
|
|
dotenvConfig()
|
|
|
|
export default async function globalTeardown() {
|
|
writePerfReport()
|
|
|
|
if (!process.env.CI && process.env.TEST_COMFYUI_DIR) {
|
|
restorePath([process.env.TEST_COMFYUI_DIR, 'user'])
|
|
restorePath([process.env.TEST_COMFYUI_DIR, 'models'])
|
|
}
|
|
|
|
if (process.env.COLLECT_COVERAGE === 'true') {
|
|
const mcr = MCR({
|
|
outputDir: './coverage/playwright',
|
|
reports: [['lcovonly', { file: 'coverage.lcov' }], ['text-summary']],
|
|
sourceFilter: {
|
|
'**/node_modules/**': false,
|
|
'**/browser_tests/**': false,
|
|
'**/*': true
|
|
}
|
|
})
|
|
await mcr.generate()
|
|
}
|
|
}
|