Skip to content
Closed
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
50 changes: 33 additions & 17 deletions .github/workflows/ci-tests-e2e-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
type: string
secrets:
CODECOV_TOKEN:
required: true
required: false
workflow_run:
workflows: ['CI: Tests E2E']
types:
Expand All @@ -32,53 +32,60 @@ permissions:

jobs:
merge:
# Not gated on full success: fail-fast:false means one flaky shard flips the whole run to failure, which would skip merging every other shard's real coverage.
if: >
github.repository == 'Comfy-Org/ComfyUI_frontend' &&
(github.event_name == 'workflow_call' ||
github.event.workflow_run.event != 'pull_request' ||
github.event.workflow_run.head_repository.full_name != github.repository ||
github.event.workflow_run.actor.login == 'dependabot[bot]') &&
github.event.workflow_run.conclusion != 'cancelled'
github.event.workflow_run.conclusion != 'cancelled')
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
has-coverage: ${{ steps.coverage-shards.outputs.has-coverage }}

steps:
- name: Checkout sources for genhtml
- name: Checkout sources for coverage packaging
if: github.event_name == 'workflow_call'
uses: actions/checkout@v7
with:
ref: ${{ inputs.source_sha || github.event.workflow_run.head_sha }}
ref: ${{ inputs.source_sha }}
sparse-checkout: |
src
packages

- name: Download all shard coverage data
if: github.event_name == 'workflow_call'
uses: dawidd6/action-download-artifact@0bd50d53a6d7fb5cb921e607957e9cc12b4ce392 # v12
with:
run_id: ${{ inputs.source_run_id || github.event.workflow_run.id }}
run_id: ${{ inputs.source_run_id }}
name: e2e-coverage-shard-.*
name_is_regexp: true
path: temp/coverage-shards
if_no_artifact_found: warn

- name: Download packaged coverage data
if: github.event_name == 'workflow_run'
uses: dawidd6/action-download-artifact@0bd50d53a6d7fb5cb921e607957e9cc12b4ce392 # v12
with:
run_id: ${{ github.event.workflow_run.id }}
name: e2e-coverage
path: coverage/playwright
if_no_artifact_found: warn

- name: Detect shard coverage data
id: coverage-shards
run: |
if [ -d temp/coverage-shards ] && find temp/coverage-shards -name 'coverage.lcov' -type f | grep -q .; then
if [ -f coverage/playwright/coverage.lcov ] || { [ -d temp/coverage-shards ] && find temp/coverage-shards -name 'coverage.lcov' -type f | grep -q .; }; then
echo "has-coverage=true" >> "$GITHUB_OUTPUT"
else
echo "has-coverage=false" >> "$GITHUB_OUTPUT"
echo "No E2E coverage shard artifacts found; treating this run as skipped." >> "$GITHUB_STEP_SUMMARY"
fi

- name: Install lcov
if: steps.coverage-shards.outputs.has-coverage == 'true'
if: github.event_name == 'workflow_call' && steps.coverage-shards.outputs.has-coverage == 'true'
run: sudo apt-get install -y -qq lcov

- name: Merge shard coverage into single LCOV
if: steps.coverage-shards.outputs.has-coverage == 'true'
if: github.event_name == 'workflow_call' && steps.coverage-shards.outputs.has-coverage == 'true'
run: |
mkdir -p coverage/playwright
LCOV_FILES=$(find temp/coverage-shards -name 'coverage.lcov' -type f)
Expand All @@ -88,7 +95,7 @@ jobs:
wc -l coverage/playwright/coverage.lcov

- name: Validate merged coverage
if: steps.coverage-shards.outputs.has-coverage == 'true'
if: github.event_name == 'workflow_call' && steps.coverage-shards.outputs.has-coverage == 'true'
run: |
MERGED_SF=$(grep -c '^SF:' coverage/playwright/coverage.lcov || echo 0)
MERGED_LH=$(awk -F: '/^LH:/{s+=$2}END{print s+0}' coverage/playwright/coverage.lcov)
Expand All @@ -110,7 +117,7 @@ jobs:
done

- name: Assert coverage was mapped back to source
if: steps.coverage-shards.outputs.has-coverage == 'true'
if: github.event_name == 'workflow_call' && steps.coverage-shards.outputs.has-coverage == 'true'
run: |
MAPPED_SF=$(grep -cE '^SF:(src|packages)/' coverage/playwright/coverage.lcov || true)
echo "Source-mapped files: $MAPPED_SF" >> "$GITHUB_STEP_SUMMARY"
Expand All @@ -120,7 +127,7 @@ jobs:
fi

- name: Strip non-source entries from coverage
if: steps.coverage-shards.outputs.has-coverage == 'true'
if: github.event_name == 'workflow_call' && steps.coverage-shards.outputs.has-coverage == 'true'
run: |
lcov --remove coverage/playwright/coverage.lcov \
'*localhost-8188*' \
Expand All @@ -139,7 +146,7 @@ jobs:
if-no-files-found: warn

- name: Upload E2E coverage to Codecov
if: steps.coverage-shards.outputs.has-coverage == 'true'
if: github.event_name == 'workflow_run' && steps.coverage-shards.outputs.has-coverage == 'true'
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
files: coverage/playwright/coverage.lcov
Expand All @@ -151,7 +158,7 @@ jobs:
fail_ci_if_error: false

- name: Generate HTML coverage report
if: steps.coverage-shards.outputs.has-coverage == 'true'
if: github.event_name == 'workflow_call' && steps.coverage-shards.outputs.has-coverage == 'true'
run: |
genhtml coverage/playwright/coverage.lcov \
-o coverage/html \
Expand All @@ -161,6 +168,15 @@ jobs:
--ignore-errors source,unmapped \
--synthesize-missing

- name: Download packaged HTML report
if: github.event_name == 'workflow_run' && steps.coverage-shards.outputs.has-coverage == 'true'
uses: dawidd6/action-download-artifact@0bd50d53a6d7fb5cb921e607957e9cc12b4ce392 # v12
with:
run_id: ${{ github.event.workflow_run.id }}
name: e2e-coverage-html
path: coverage/html
if_no_artifact_found: warn

- name: Upload HTML report artifact
if: steps.coverage-shards.outputs.has-coverage == 'true'
uses: actions/upload-artifact@v6
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/ci-tests-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,6 @@ jobs:
${{
always() &&
needs.changes.outputs.should-run == 'true' &&
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.fork == false &&
github.event.pull_request.user.login != 'dependabot[bot]' &&
needs.playwright-tests-chromium-sharded.result != 'cancelled'
}}
uses: ./.github/workflows/ci-tests-e2e-coverage.yaml
Expand All @@ -240,7 +237,6 @@ jobs:
source_pr: ${{ format('{0}', github.event.pull_request.number) }}
source_run_id: ${{ format('{0}', github.run_id) }}
source_sha: ${{ github.event.pull_request.head.sha || github.sha }}
secrets: inherit

# Records video only for spec files newly added in this PR, to keep cost bounded.
playwright-video-new-tests:
Expand Down
62 changes: 62 additions & 0 deletions scripts/cicd/e2e-coverage-workflow.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { readFileSync } from 'node:fs'

import { describe, expect, it } from 'vitest'
import { parse } from 'yaml'

type WorkflowStep = {
if?: string
uses?: string
with?: Record<string, string>
}

type Workflow = {
jobs: Record<
string,
{
if?: string
steps?: WorkflowStep[]
with?: Record<string, string>
}
>
}

function readWorkflow(path: string): Workflow {
return parse(readFileSync(path, 'utf8')) as Workflow
}

describe('E2E coverage workflows', () => {
it('packages fork coverage before entering the trusted workflow_run', () => {
const coverageWorkflow = readWorkflow(
'.github/workflows/ci-tests-e2e-coverage.yaml'
)
const e2eWorkflow = readWorkflow('.github/workflows/ci-tests-e2e.yaml')
const coverageSteps = coverageWorkflow.jobs.merge.steps ?? []
const checkout = coverageSteps.find((step) =>
step.uses?.startsWith('actions/checkout@')
)
const download = coverageSteps.find(
(step) => step.with?.name === 'e2e-coverage'
)
const codecov = coverageSteps.find((step) =>
step.uses?.startsWith('codecov/codecov-action@')
)
const packageJob = e2eWorkflow.jobs['upload-e2e-coverage']

expect(checkout?.if).toContain("github.event_name == 'workflow_call'")
expect(download?.if).toContain("github.event_name == 'workflow_run'")
expect(codecov?.if).toContain("github.event_name == 'workflow_run'")
expect(codecov?.with).toMatchObject({
override_branch:
'${{ inputs.source_branch || github.event.workflow_run.head_branch }}',
override_commit:
'${{ inputs.source_sha || github.event.workflow_run.head_sha }}',
override_pr:
'${{ inputs.source_pr || github.event.workflow_run.pull_requests[0].number }}'
})
expect(packageJob.if).not.toContain('fork == false')
expect(packageJob.with).toMatchObject({
source_branch: '${{ github.head_ref || github.ref_name }}',
source_sha: '${{ github.event.pull_request.head.sha || github.sha }}'
})
})
})
12 changes: 12 additions & 0 deletions src/platform/nodeApi/apiSurface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
export const API_MEMBERS: ReadonlySet<string> = new Set([
'Record',
'accelerators',
'add',
'addActionBarButton',
'addBadge',
Expand All @@ -35,6 +36,7 @@ export const API_MEMBERS: ReadonlySet<string> = new Set([
'attrs',
'autoHeight',
'autoQueueMode',
'available',
'backend',
'batch',
'batchCount',
Expand Down Expand Up @@ -64,6 +66,7 @@ export const API_MEMBERS: ReadonlySet<string> = new Set([
'connectedType',
'container',
'context',
'cpu',
'ctrl',
'ctrlKey',
'declare',
Expand Down Expand Up @@ -170,6 +173,9 @@ export const API_MEMBERS: ReadonlySet<string> = new Set([
'max',
'maxHeight',
'maxWidth',
'memory',
'memory_available',
'memory_total',
'menuEvent',
'mergeWidgetConfig',
'message',
Expand All @@ -181,6 +187,7 @@ export const API_MEMBERS: ReadonlySet<string> = new Set([
'minWidth',
'mode',
'modify',
'monitor',
'mount',
'move',
'moveLinksTo',
Expand Down Expand Up @@ -358,27 +365,32 @@ export const API_MEMBERS: ReadonlySet<string> = new Set([
'supports',
'surface',
'surfaceHovered',
'system',
'targetIndex',
'targetNodeId',
'targetSlotId',
'targets',
'temperature_c',
'text',
'textSecondary',
'theme',
'title',
'to',
'tooltip',
'total',
'type',
'typeColor',
'ui',
'unconnectedInputs',
'update',
'url',
'useGrouping',
'utilization_percent',
'value',
'values',
'variant',
'version',
'volumes',
'when',
'widget',
'widgetConfig',
Expand Down
1 change: 1 addition & 0 deletions src/platform/nodeApi/comfyApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ describe('comfy API root', () => {
expect(api().supports('node.fileDrop')).toBe(true)
expect(api().supports('queue.disableAutoQueue')).toBe(true)
expect(api().supports('queue.settings')).toBe(true)
expect(api().supports('system.monitor')).toBe(true)
})

it('returns false for unknown capabilities instead of throwing', () => {
Expand Down
7 changes: 7 additions & 0 deletions src/platform/nodeApi/comfyApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ import { createUiHandle } from './uiHandle'
import { createViewportObserver } from './viewport'
import type { SettingsHandle } from './settingsHandle'
import type { StorageHandle } from './storageHandle'
import { createSystemApi } from './systemHandle'
import type { SystemHandle } from './systemHandle'
import type { UiHandle } from './uiHandle'
import type { NodeHandle } from './nodeHandle'
import { createWorkflowApi } from './workflowHandle'
Expand Down Expand Up @@ -135,6 +137,7 @@ const CAPABILITIES: ReadonlyMap<string, string> = new Map([
['commands', '1.0'],
['backend', '1.0'],
['storage', '1.0'],
['system.monitor', '1.0'],
['ui.sidebarTab', '1.0'],
['viewport.changed', '1.0'],
['interaction.state', '1.0'],
Expand Down Expand Up @@ -220,6 +223,8 @@ export interface Comfy {
* between machines.
*/
readonly storage: StorageHandle
/** Bounded, host-sampled hardware metrics. */
readonly system: SystemHandle
/** The sanctioned slice of app chrome — sidebar tabs. */
readonly ui: UiHandle
/** Commands, their keybindings, and notifications. */
Expand Down Expand Up @@ -346,6 +351,7 @@ function buildMajor(
)
const settings = createSettingsApi()
const storage = createStorageApi()
const system = createSystemApi()
const ui = createUiHandle()
const commands = createCommandsApi()
const backend = createBackendApi()
Expand Down Expand Up @@ -425,6 +431,7 @@ function buildMajor(
graph,
settings,
storage,
system,
ui,
commands,
backend,
Expand Down
Loading
Loading