From c662c77305ecf9988e6c1164f3be4a7e73367e9b Mon Sep 17 00:00:00 2001 From: snomiao Date: Thu, 2 Oct 2025 14:20:48 +0900 Subject: [PATCH] Add Playwright composite action to reduce workflow duplication (#5754) This PR introduces a reusable composite action for Playwright setup to reduce duplication across workflows. ## Changes - Created `.github/actions/setup-playwright/action.yml` composite action that: - Detects or uses provided Playwright version - Caches Playwright browsers with intelligent cache keys - Installs browsers only when cache miss occurs - Installs OS dependencies when cache hit occurs ## Technical Details - **Important:** The composite action requires `shell: bash` for all `run` steps as per [GitHub Actions requirements for composite actions](https://docs.github.com/en/actions/creating-actions/creating-a-composite-action#creating-an-action-metadata-file). This is a mandatory field for composite actions, unlike regular workflow steps. - Updated workflow paths to account for repository checkout locations (some workflows checkout to subdirectories like `ComfyUI_frontend/`) - Uses conditional caching to avoid redundant browser installations ## Benefits - Reduces code duplication across 6 workflow files - Centralizes Playwright caching logic - Consistent browser setup across all workflows - Easier maintenance and updates - Faster CI runs through intelligent caching ## Affected Workflows - `.github/workflows/test-ui.yaml` (2 uses) - `.github/workflows/i18n-custom-nodes.yaml` - `.github/workflows/i18n-node-defs.yaml` - `.github/workflows/i18n.yaml` - `.github/workflows/test-browser-exp.yaml` --------- Co-authored-by: GitHub Action --- .github/actions/setup-playwright/action.yml | 31 +++++++++++++ .github/workflows/tests-ci.yaml | 43 ++----------------- ...ales-for-given-custom-node-repository.yaml | 5 +-- .github/workflows/update-locales.yaml | 12 +----- .../update-node-definitions-locales.yaml | 8 ++-- .../update-playwright-expectations.yaml | 12 +----- src/lib/litegraph/src/LGraphNode.ts | 2 +- 7 files changed, 45 insertions(+), 68 deletions(-) create mode 100644 .github/actions/setup-playwright/action.yml diff --git a/.github/actions/setup-playwright/action.yml b/.github/actions/setup-playwright/action.yml new file mode 100644 index 0000000000..ddd1a76055 --- /dev/null +++ b/.github/actions/setup-playwright/action.yml @@ -0,0 +1,31 @@ +name: Setup Playwright +description: Cache and install Playwright browsers with dependencies +runs: + using: composite + steps: + - name: Detect Playwright version + id: detect-version + shell: bash + working-directory: ComfyUI_frontend + run: | + PLAYWRIGHT_VERSION=$(pnpm ls @playwright/test --json | jq --raw-output '.[0].devDependencies["@playwright/test"].version') + echo "playwright-version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT + + - name: Cache Playwright Browsers + uses: actions/cache@v4 + id: cache-playwright-browsers + with: + path: '~/.cache/ms-playwright' + key: ${{ runner.os }}-playwright-browsers-${{ steps.detect-version.outputs.playwright-version }} + + - name: Install Playwright Browsers + if: steps.cache-playwright-browsers.outputs.cache-hit != 'true' + shell: bash + run: pnpm exec playwright install chromium --with-deps + working-directory: ComfyUI_frontend + + - name: Install Playwright Browsers (operating system dependencies) + if: steps.cache-playwright-browsers.outputs.cache-hit == 'true' + shell: bash + run: pnpm exec playwright install-deps + working-directory: ComfyUI_frontend \ No newline at end of file diff --git a/.github/workflows/tests-ci.yaml b/.github/workflows/tests-ci.yaml index 01b180b4a4..94d0f0b2d6 100644 --- a/.github/workflows/tests-ci.yaml +++ b/.github/workflows/tests-ci.yaml @@ -12,7 +12,6 @@ jobs: runs-on: ubuntu-latest outputs: cache-key: ${{ steps.cache-key.outputs.key }} - playwright-version: ${{ steps.playwright-version.outputs.PLAYWRIGHT_VERSION }} steps: - name: Checkout ComfyUI uses: actions/checkout@v5 @@ -65,12 +64,6 @@ jobs: id: cache-key run: echo "key=$(date +%s)" >> $GITHUB_OUTPUT - - name: Playwright Version - id: playwright-version - run: | - PLAYWRIGHT_VERSION=$(pnpm ls @playwright/test --json | jq --raw-output '.[0].devDependencies["@playwright/test"].version') - echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT - working-directory: ComfyUI_frontend - name: Save cache uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 @@ -123,22 +116,8 @@ jobs: working-directory: ComfyUI - - name: Cache Playwright Browsers - uses: actions/cache@v4 - id: cache-playwright-browsers - with: - path: '~/.cache/ms-playwright' - key: '${{ runner.os }}-playwright-browsers-${{ needs.setup.outputs.playwright-version }}' - - - name: Install Playwright Browsers - if: steps.cache-playwright-browsers.outputs.cache-hit != 'true' - run: pnpm exec playwright install chromium --with-deps - working-directory: ComfyUI_frontend - - - name: Install Playwright Browsers (operating system dependencies) - if: steps.cache-playwright-browsers.outputs.cache-hit == 'true' - run: pnpm exec playwright install-deps - working-directory: ComfyUI_frontend + - name: Setup Playwright + uses: ./ComfyUI_frontend/.github/actions/setup-playwright - name: Start ComfyUI server run: | @@ -202,22 +181,8 @@ jobs: pip install wait-for-it working-directory: ComfyUI - - name: Cache Playwright Browsers - uses: actions/cache@v4 - id: cache-playwright-browsers - with: - path: '~/.cache/ms-playwright' - key: '${{ runner.os }}-playwright-browsers-${{ needs.setup.outputs.playwright-version }}' - - - name: Install Playwright Browsers - if: steps.cache-playwright-browsers.outputs.cache-hit != 'true' - run: pnpm exec playwright install chromium --with-deps - working-directory: ComfyUI_frontend - - - name: Install Playwright Browsers (operating system dependencies) - if: steps.cache-playwright-browsers.outputs.cache-hit == 'true' - run: pnpm exec playwright install-deps - working-directory: ComfyUI_frontend + - name: Setup Playwright + uses: ./ComfyUI_frontend/.github/actions/setup-playwright - name: Start ComfyUI server run: | diff --git a/.github/workflows/update-locales-for-given-custom-node-repository.yaml b/.github/workflows/update-locales-for-given-custom-node-repository.yaml index 74d0267cf2..ec085eab59 100644 --- a/.github/workflows/update-locales-for-given-custom-node-repository.yaml +++ b/.github/workflows/update-locales-for-given-custom-node-repository.yaml @@ -77,9 +77,8 @@ jobs: python main.py --cpu --multi-user & wait-for-it --service 127.0.0.1:8188 -t 600 working-directory: ComfyUI - - name: Install Playwright Browsers - run: pnpm exec playwright install chromium --with-deps - working-directory: ComfyUI_frontend + - name: Setup Playwright + uses: ./ComfyUI_frontend/.github/actions/setup-playwright - name: Start dev server # Run electron dev server as it is a superset of the web dev server # We do want electron specific UIs to be translated. diff --git a/.github/workflows/update-locales.yaml b/.github/workflows/update-locales.yaml index 2871209a1d..3bf939b23f 100644 --- a/.github/workflows/update-locales.yaml +++ b/.github/workflows/update-locales.yaml @@ -26,16 +26,8 @@ jobs: key: i18n-tools-cache-${{ runner.os }}-${{ hashFiles('ComfyUI_frontend/pnpm-lock.yaml') }} restore-keys: | i18n-tools-cache-${{ runner.os }}- - - name: Cache Playwright browsers - uses: actions/cache@v4 - with: - path: ~/.cache/ms-playwright - key: playwright-browsers-${{ runner.os }}-${{ hashFiles('ComfyUI_frontend/pnpm-lock.yaml') }} - restore-keys: | - playwright-browsers-${{ runner.os }}- - - name: Install Playwright Browsers - run: pnpm exec playwright install chromium --with-deps - working-directory: ComfyUI_frontend + - name: Setup Playwright + uses: ./.github/actions/setup-playwright - name: Start dev server # Run electron dev server as it is a superset of the web dev server # We do want electron specific UIs to be translated. diff --git a/.github/workflows/update-node-definitions-locales.yaml b/.github/workflows/update-node-definitions-locales.yaml index 71cb417d4e..b063159ddf 100644 --- a/.github/workflows/update-node-definitions-locales.yaml +++ b/.github/workflows/update-node-definitions-locales.yaml @@ -13,11 +13,9 @@ jobs: update-locales: runs-on: ubuntu-latest steps: - - name: Setup Frontend - uses: ./.github/actions/setup-frontend - - name: Install Playwright Browsers - run: pnpm exec playwright install chromium --with-deps - working-directory: ComfyUI_frontend + - uses: Comfy-Org/ComfyUI_frontend_setup_action@v3 + - name: Setup Playwright + uses: ./.github/actions/setup-playwright - name: Start dev server # Run electron dev server as it is a superset of the web dev server # We do want electron specific UIs to be translated. diff --git a/.github/workflows/update-playwright-expectations.yaml b/.github/workflows/update-playwright-expectations.yaml index 4f643cad8b..c59628f69a 100644 --- a/.github/workflows/update-playwright-expectations.yaml +++ b/.github/workflows/update-playwright-expectations.yaml @@ -14,16 +14,8 @@ jobs: uses: actions/checkout@v5 - name: Setup Frontend uses: ./.github/actions/setup-frontend - - name: Cache Playwright browsers - uses: actions/cache@v4 - with: - path: ~/.cache/ms-playwright - key: playwright-browsers-${{ runner.os }}-${{ hashFiles('ComfyUI_frontend/pnpm-lock.yaml') }} - restore-keys: | - playwright-browsers-${{ runner.os }}- - - name: Install Playwright Browsers - run: pnpm exec playwright install chromium --with-deps - working-directory: ComfyUI_frontend + - name: Setup Playwright + uses: ./.github/actions/setup-playwright - name: Run Playwright tests and update snapshots id: playwright-tests run: pnpm exec playwright test --update-snapshots diff --git a/src/lib/litegraph/src/LGraphNode.ts b/src/lib/litegraph/src/LGraphNode.ts index 52586e4451..557bf03b85 100644 --- a/src/lib/litegraph/src/LGraphNode.ts +++ b/src/lib/litegraph/src/LGraphNode.ts @@ -902,7 +902,7 @@ export class LGraphNode if (this.onSerialize?.(o)) console.warn( - 'node onSerialize shouldn\'t return anything, data should be stored in the object pass in the first parameter' + "node onSerialize shouldn't return anything, data should be stored in the object pass in the first parameter" ) return o