mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-19 22:09:37 +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>
74 lines
2.1 KiB
YAML
74 lines
2.1 KiB
YAML
name: 'CI: E2E Coverage'
|
|
|
|
on:
|
|
workflow_run:
|
|
workflows: ['CI: Tests E2E']
|
|
types:
|
|
- completed
|
|
|
|
concurrency:
|
|
group: e2e-coverage-${{ github.event.workflow_run.head_sha }}
|
|
cancel-in-progress: true
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
merge:
|
|
if: >
|
|
github.repository == 'Comfy-Org/ComfyUI_frontend' &&
|
|
github.event.workflow_run.conclusion == 'success'
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 10
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Setup frontend
|
|
uses: ./.github/actions/setup-frontend
|
|
|
|
- name: Download all shard coverage data
|
|
uses: dawidd6/action-download-artifact@0bd50d53a6d7fb5cb921e607957e9cc12b4ce392 # v12
|
|
with:
|
|
run_id: ${{ github.event.workflow_run.id }}
|
|
name: e2e-coverage-shard-.*
|
|
name_is_regexp: true
|
|
path: temp/coverage-shards
|
|
if_no_artifact_found: warn
|
|
|
|
- name: Install lcov
|
|
run: sudo apt-get install -y -qq lcov
|
|
|
|
- name: Merge shard coverage into single LCOV
|
|
run: |
|
|
mkdir -p coverage/playwright
|
|
LCOV_FILES=$(find temp/coverage-shards -name 'coverage.lcov' -type f)
|
|
if [ -z "$LCOV_FILES" ]; then
|
|
echo "No coverage.lcov files found"
|
|
touch coverage/playwright/coverage.lcov
|
|
exit 0
|
|
fi
|
|
ADD_ARGS=""
|
|
for f in $LCOV_FILES; do ADD_ARGS="$ADD_ARGS -a $f"; done
|
|
lcov $ADD_ARGS -o coverage/playwright/coverage.lcov
|
|
wc -l coverage/playwright/coverage.lcov
|
|
|
|
- name: Upload merged coverage data
|
|
if: always()
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
name: e2e-coverage
|
|
path: coverage/playwright/
|
|
retention-days: 30
|
|
if-no-files-found: warn
|
|
|
|
- name: Upload E2E coverage to Codecov
|
|
if: always()
|
|
uses: codecov/codecov-action@1af58845a975a7985b0beb0cbe6fbbb71a41dbad # v5.5.3
|
|
with:
|
|
files: coverage/playwright/coverage.lcov
|
|
flags: e2e
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
fail_ci_if_error: false
|