refactor: reorganize GitHub Actions for better reusability

This refactoring improves the CI/CD workflow structure by:

- Split the monolithic setup-frontend action into two focused actions:
  - setup-frontend: Now only handles frontend dependency installation and building
  - setup-comfyui-server: New action for ComfyUI server setup and launch

- Simplified workflow structure with better separation of concerns:
  - Frontend and server setup are now independent and reusable
  - Each action has clearer responsibilities and inputs
  - Removed duplicate setup code across workflows

- Improved tests-ci.yaml workflow:
  - Uses cache/save and cache/restore for the entire workspace
  - Test jobs now restore cached build instead of rebuilding
  - Reduced redundant setup steps in each test shard
  - Better parallelization with faster test execution

- Updated all locale update workflows to use new action structure
- Made setup-playwright a standalone reusable action

Benefits:
- Faster CI runs by reducing redundant builds
- More maintainable with DRY principle
- Easier to debug individual components
- Better action reusability across workflows
This commit is contained in:
snomiao
2025-10-06 23:10:02 +00:00
parent c56fff0b8b
commit c1649426a9
8 changed files with 201 additions and 311 deletions

View File

@@ -0,0 +1,50 @@
name: Setup ComfyUI Server
description: 'Setup ComfyUI server for continuous integration (with ComfyUI_devtools node installed)'
inputs:
extra_server_params:
description: 'Additional parameters to pass to ComfyUI server'
required: false
default: ''
launch_server:
description: 'Whether to launch the server after setup'
required: false
default: 'true'
runs:
using: 'composite'
steps:
# Note: this workflow assume frontend repo is checked out and is built in ../dist
# Checkout ComfyUI repo, install the dev_tools node and start server
- name: Checkout ComfyUI
uses: actions/checkout@v5
with:
repository: 'comfyanonymous/ComfyUI'
path: 'ComfyUI'
- name: Install ComfyUI_devtools from frontend repo
shell: bash
run: |
mkdir -p ComfyUI/custom_nodes/ComfyUI_devtools
cp -r ./tools/devtools/* ComfyUI/custom_nodes/ComfyUI_devtools/
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install Python requirements
shell: bash
working-directory: ComfyUI
run: |
python -m pip install --upgrade pip
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
pip install -r requirements.txt
pip install wait-for-it
- name: Start ComfyUI server
if: ${{ inputs.launch_server == 'true' }}
shell: bash
working-directory: ComfyUI
run: |
python main.py --cpu --multi-user --front-end-root ../dist ${{ inputs.extra_server_params }} &
wait-for-it --service 127.0.0.1:8188 -t 600

View File

@@ -1,30 +1,16 @@
name: Setup Frontend name: Build ComfyUI Frontend
description: 'Setup ComfyUI frontend development environment' description: 'Install dependencies and build ComfyUI_frontend'
inputs: inputs:
extra_server_params: build_frontend:
description: 'Additional parameters to pass to ComfyUI server' description: 'Whether to build the frontend'
required: false required: false
default: '' default: 'true'
runs: runs:
using: 'composite' using: 'composite'
steps: steps:
- name: Checkout ComfyUI # Note: this workflow assume frontend repo is checked out in the root of the workspace
uses: actions/checkout@v5
with:
repository: 'comfyanonymous/ComfyUI'
path: 'ComfyUI'
- name: Checkout ComfyUI_frontend
uses: actions/checkout@v5
with:
path: 'ComfyUI_frontend'
- name: Copy ComfyUI_devtools from frontend repo
shell: bash
run: |
mkdir -p ComfyUI/custom_nodes/ComfyUI_devtools
cp -r ComfyUI_frontend/tools/devtools/* ComfyUI/custom_nodes/ComfyUI_devtools/
# Install pnpm, Node.js, build frontend
- name: Install pnpm - name: Install pnpm
uses: pnpm/action-setup@v4 uses: pnpm/action-setup@v4
with: with:
@@ -35,32 +21,13 @@ runs:
with: with:
node-version: 'lts/*' node-version: 'lts/*'
cache: 'pnpm' cache: 'pnpm'
cache-dependency-path: 'ComfyUI_frontend/pnpm-lock.yaml' cache-dependency-path: './pnpm-lock.yaml'
- name: Setup Python - name: Install dependencies
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install Python requirements
shell: bash shell: bash
working-directory: ComfyUI run: pnpm install --frozen-lockfile
run: |
python -m pip install --upgrade pip
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
pip install -r requirements.txt
pip install wait-for-it
- name: Build & Install ComfyUI_frontend - name: Build ComfyUI_frontend if needed
if: ${{ inputs.build_frontend == 'true' }}
shell: bash shell: bash
working-directory: ComfyUI_frontend run: pnpm build
run: |
pnpm install --frozen-lockfile
pnpm build
- name: Start ComfyUI server
shell: bash
working-directory: ComfyUI
run: |
python main.py --cpu --multi-user --front-end-root ../ComfyUI_frontend/dist ${{ inputs.extra_server_params }} &
wait-for-it --service 127.0.0.1:8188 -t 600

View File

@@ -6,7 +6,6 @@ runs:
- name: Detect Playwright version - name: Detect Playwright version
id: detect-version id: detect-version
shell: bash shell: bash
working-directory: ComfyUI_frontend
run: | run: |
PLAYWRIGHT_VERSION=$(pnpm ls @playwright/test --json | jq --raw-output '.[0].devDependencies["@playwright/test"].version') PLAYWRIGHT_VERSION=$(pnpm ls @playwright/test --json | jq --raw-output '.[0].devDependencies["@playwright/test"].version')
echo "playwright-version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT echo "playwright-version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT
@@ -22,10 +21,20 @@ runs:
if: steps.cache-playwright-browsers.outputs.cache-hit != 'true' if: steps.cache-playwright-browsers.outputs.cache-hit != 'true'
shell: bash shell: bash
run: pnpm exec playwright install chromium --with-deps run: pnpm exec playwright install chromium --with-deps
working-directory: ComfyUI_frontend
- name: Install Playwright Browsers (operating system dependencies) - name: Install Playwright Browsers (operating system dependencies)
if: steps.cache-playwright-browsers.outputs.cache-hit == 'true' if: steps.cache-playwright-browsers.outputs.cache-hit == 'true'
shell: bash shell: bash
run: pnpm exec playwright install-deps run: pnpm exec playwright install-deps
working-directory: ComfyUI_frontend
- name: Cache tool outputs
uses: actions/cache@v4
with:
path: |
./.cache
./tsconfig.tsbuildinfo
key: playwright-setup-cache-${{ runner.os }}-${{ hashFiles('./pnpm-lock.yaml') }}-${{ hashFiles('./src/**/*.{ts,vue,js}', './*.config.*') }}
restore-keys: |
playwright-setup-cache-${{ runner.os }}-${{ hashFiles('./pnpm-lock.yaml') }}-
playwright-setup-cache-${{ runner.os }}-
playwright-tools-cache-${{ runner.os }}-

View File

@@ -13,63 +13,27 @@ jobs:
outputs: outputs:
cache-key: ${{ steps.cache-key.outputs.key }} cache-key: ${{ steps.cache-key.outputs.key }}
steps: steps:
- name: Checkout ComfyUI - name: Checkout repository
uses: actions/checkout@v5 uses: actions/checkout@v5
# Setup Test Environment, build frontend but do not start server yet
- name: Setup ComfyUI server
uses: ./.github/actions/setup-comfyui-server
with: with:
repository: 'comfyanonymous/ComfyUI' launch_server: 'false'
path: 'ComfyUI' - name: Setup frontend
ref: master uses: ./.github/actions/setup-frontend
- name: Setup Playwright
- name: Checkout ComfyUI_frontend uses: ./.github/actions/setup-playwright # Setup Playwright and cache browsers
uses: actions/checkout@v5
with:
path: 'ComfyUI_frontend'
- name: Copy ComfyUI_devtools from frontend repo
run: |
mkdir -p ComfyUI/custom_nodes/ComfyUI_devtools
cp -r ComfyUI_frontend/tools/devtools/* ComfyUI/custom_nodes/ComfyUI_devtools/
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: 'pnpm'
cache-dependency-path: 'ComfyUI_frontend/pnpm-lock.yaml'
- name: Cache tool outputs
uses: actions/cache@v4
with:
path: |
ComfyUI_frontend/.cache
ComfyUI_frontend/tsconfig.tsbuildinfo
key: playwright-setup-cache-${{ runner.os }}-${{ hashFiles('ComfyUI_frontend/pnpm-lock.yaml') }}-${{ hashFiles('ComfyUI_frontend/src/**/*.{ts,vue,js}', 'ComfyUI_frontend/*.config.*') }}
restore-keys: |
playwright-setup-cache-${{ runner.os }}-${{ hashFiles('ComfyUI_frontend/pnpm-lock.yaml') }}-
playwright-setup-cache-${{ runner.os }}-
playwright-tools-cache-${{ runner.os }}-
- name: Build ComfyUI_frontend
run: |
pnpm install --frozen-lockfile
pnpm build
working-directory: ComfyUI_frontend
# Save the entire workspace as cache for later test jobs to restore
- name: Generate cache key - name: Generate cache key
id: cache-key id: cache-key
run: echo "key=$(date +%s)" >> $GITHUB_OUTPUT run: echo "key=$(date +%s)" >> $GITHUB_OUTPUT
- name: Save cache - name: Save cache
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684
with: with:
path: | path: .
ComfyUI
ComfyUI_frontend
key: comfyui-setup-${{ steps.cache-key.outputs.key }} key: comfyui-setup-${{ steps.cache-key.outputs.key }}
# Sharded chromium tests # Sharded chromium tests
@@ -84,54 +48,35 @@ jobs:
shardIndex: [1, 2, 3, 4, 5, 6, 7, 8] shardIndex: [1, 2, 3, 4, 5, 6, 7, 8]
shardTotal: [8] shardTotal: [8]
steps: steps:
# download built frontend repo from setup job
- name: Wait for cache propagation - name: Wait for cache propagation
run: sleep 10 run: sleep 10
- name: Restore cached setup - name: Restore cached setup
uses: actions/cache/restore@v4 uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684
with: with:
fail-on-cache-miss: true fail-on-cache-miss: true
path: | path: .
ComfyUI
ComfyUI_frontend
key: comfyui-setup-${{ needs.setup.outputs.cache-key }} key: comfyui-setup-${{ needs.setup.outputs.cache-key }}
- name: Install pnpm # Setup Test Environment for this runner, start server, use cached built frontend ./dist from 'setup' job
uses: pnpm/action-setup@v4 - name: Setup ComfyUI server
uses: ./.github/actions/setup-comfyui-server
- name: Setup nodejs, pnpm, reuse built frontend
uses: ./.github/actions/setup-frontend
with: with:
version: 10 build_frontend: 'false'
- uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
- name: Install requirements
run: |
python -m pip install --upgrade pip
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
pip install -r requirements.txt
pip install wait-for-it
working-directory: ComfyUI
- name: Setup Playwright - name: Setup Playwright
uses: ./ComfyUI_frontend/.github/actions/setup-playwright uses: ./.github/actions/setup-playwright
- name: Start ComfyUI server
run: |
python main.py --cpu --multi-user --front-end-root ../ComfyUI_frontend/dist &
wait-for-it --service 127.0.0.1:8188 -t 600
working-directory: ComfyUI
# Run sharded tests and upload sharded reports
- name: Run Playwright tests (Shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }}) - name: Run Playwright tests (Shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }})
id: playwright id: playwright
run: pnpm exec playwright test --project=chromium --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} --reporter=blob run: pnpm exec playwright test --project=chromium --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} --reporter=blob
working-directory: ComfyUI_frontend
env: env:
PLAYWRIGHT_BLOB_OUTPUT_DIR: ../blob-report PLAYWRIGHT_BLOB_OUTPUT_DIR: ../blob-report
- uses: actions/upload-artifact@v4 - name: Upload blob report
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }} if: ${{ !cancelled() }}
with: with:
name: blob-report-chromium-${{ matrix.shardIndex }} name: blob-report-chromium-${{ matrix.shardIndex }}
@@ -150,45 +95,27 @@ jobs:
matrix: matrix:
browser: [chromium-2x, chromium-0.5x, mobile-chrome] browser: [chromium-2x, chromium-0.5x, mobile-chrome]
steps: steps:
# download built frontend repo from setup job
- name: Wait for cache propagation - name: Wait for cache propagation
run: sleep 10 run: sleep 10
- name: Restore cached setup - name: Restore cached setup
uses: actions/cache/restore@v4 uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684
with: with:
fail-on-cache-miss: true fail-on-cache-miss: true
path: | path: .
ComfyUI
ComfyUI_frontend
key: comfyui-setup-${{ needs.setup.outputs.cache-key }} key: comfyui-setup-${{ needs.setup.outputs.cache-key }}
- name: Install pnpm # Setup Test Environment for this runner, start server, use cached built frontend ./dist from 'setup' job
uses: pnpm/action-setup@v4 - name: Setup ComfyUI server
uses: ./.github/actions/setup-comfyui-server
- name: Setup nodejs, pnpm, reuse built frontend
uses: ./.github/actions/setup-frontend
with: with:
version: 10 build_frontend: 'false'
- uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
- name: Install requirements
run: |
python -m pip install --upgrade pip
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
pip install -r requirements.txt
pip install wait-for-it
working-directory: ComfyUI
- name: Setup Playwright - name: Setup Playwright
uses: ./ComfyUI_frontend/.github/actions/setup-playwright uses: ./.github/actions/setup-playwright
- name: Start ComfyUI server
run: |
python main.py --cpu --multi-user --front-end-root ../ComfyUI_frontend/dist &
wait-for-it --service 127.0.0.1:8188 -t 600
working-directory: ComfyUI
# Run tests and upload reports
- name: Run Playwright tests (${{ matrix.browser }}) - name: Run Playwright tests (${{ matrix.browser }})
id: playwright id: playwright
run: | run: |
@@ -198,13 +125,13 @@ jobs:
--reporter=list \ --reporter=list \
--reporter=html \ --reporter=html \
--reporter=json --reporter=json
working-directory: ComfyUI_frontend
- uses: actions/upload-artifact@v4 - name: Upload Playwright report
uses: actions/upload-artifact@v4
if: always() if: always()
with: with:
name: playwright-report-${{ matrix.browser }} name: playwright-report-${{ matrix.browser }}
path: ComfyUI_frontend/playwright-report/ path: ./playwright-report/
retention-days: 30 retention-days: 30
# Merge sharded test reports # Merge sharded test reports
@@ -213,31 +140,21 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: ${{ !cancelled() }} if: ${{ !cancelled() }}
steps: steps:
- name: Checkout ComfyUI_frontend - name: Checkout repository
uses: actions/checkout@v5 uses: actions/checkout@v5
with:
path: 'ComfyUI_frontend'
- name: Install pnpm # Setup Test Environment, we only need playwright here
uses: pnpm/action-setup@v4 - name: Setup frontend
uses: ./.github/actions/setup-frontend
with: with:
version: 10 build_frontend: 'false'
- name: Setup Playwright
- uses: actions/setup-node@v4 uses: ./.github/actions/setup-playwright
with:
node-version: lts/*
cache: 'pnpm'
cache-dependency-path: 'ComfyUI_frontend/pnpm-lock.yaml'
- name: Install dependencies
run: |
pnpm install --frozen-lockfile
working-directory: ComfyUI_frontend
- name: Download blob reports - name: Download blob reports
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
path: ComfyUI_frontend/all-blob-reports path: ./all-blob-reports
pattern: blob-report-chromium-* pattern: blob-report-chromium-*
merge-multiple: true merge-multiple: true
@@ -248,13 +165,12 @@ jobs:
# Generate JSON report separately with explicit output path # Generate JSON report separately with explicit output path
PLAYWRIGHT_JSON_OUTPUT_NAME=playwright-report/report.json \ PLAYWRIGHT_JSON_OUTPUT_NAME=playwright-report/report.json \
pnpm exec playwright merge-reports --reporter=json ./all-blob-reports pnpm exec playwright merge-reports --reporter=json ./all-blob-reports
working-directory: ComfyUI_frontend
- name: Upload HTML report - name: Upload HTML report
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: playwright-report-chromium name: playwright-report-chromium
path: ComfyUI_frontend/playwright-report/ path: ./playwright-report/
retention-days: 30 retention-days: 30
#### BEGIN Deployment and commenting (non-forked PRs only) #### BEGIN Deployment and commenting (non-forked PRs only)
@@ -270,11 +186,11 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v5 uses: actions/checkout@v5
- name: Get start time - name: Get start time
id: start-time id: start-time
run: echo "time=$(date -u '+%m/%d/%Y, %I:%M:%S %p')" >> $GITHUB_OUTPUT run: echo "time=$(date -u '+%m/%d/%Y, %I:%M:%S %p')" >> $GITHUB_OUTPUT
- name: Post starting comment - name: Post starting comment
env: env:
GITHUB_TOKEN: ${{ github.token }} GITHUB_TOKEN: ${{ github.token }}
@@ -285,7 +201,7 @@ jobs:
"${{ github.head_ref }}" \ "${{ github.head_ref }}" \
"starting" \ "starting" \
"${{ steps.start-time.outputs.time }}" "${{ steps.start-time.outputs.time }}"
# Deploy and comment for non-forked PRs only # Deploy and comment for non-forked PRs only
deploy-and-comment: deploy-and-comment:
needs: [playwright-tests, merge-reports] needs: [playwright-tests, merge-reports]
@@ -297,23 +213,20 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v5 uses: actions/checkout@v5
- name: Download all playwright reports - name: Download all playwright reports
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
pattern: playwright-report-* pattern: playwright-report-*
path: reports path: reports
- name: Make deployment script executable
run: chmod +x scripts/cicd/pr-playwright-deploy-and-comment.sh
- name: Deploy reports and comment on PR - name: Deploy reports and comment on PR
env: env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
GITHUB_TOKEN: ${{ github.token }} GITHUB_TOKEN: ${{ github.token }}
run: | run: |
./scripts/cicd/pr-playwright-deploy-and-comment.sh \ bash ./scripts/cicd/pr-playwright-deploy-and-comment.sh \
"${{ github.event.pull_request.number }}" \ "${{ github.event.pull_request.number }}" \
"${{ github.head_ref }}" \ "${{ github.head_ref }}" \
"completed" "completed"

View File

@@ -21,90 +21,64 @@ jobs:
update-locales: update-locales:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout ComfyUI - name: Checkout repository
uses: actions/checkout@v5 uses: actions/checkout@v5
# Setup playwright environment with custom node repository
- name: Setup ComfyUI Server (without launching)
uses: ./.github/actions/setup-comfyui-server
with: with:
repository: comfyanonymous/ComfyUI launch_server: 'false'
path: ComfyUI - name: Setup frontend
ref: master uses: ./.github/actions/setup-frontend
- name: Checkout ComfyUI_frontend - name: Setup Playwright
uses: actions/checkout@v5 uses: ./.github/actions/setup-playwright
with:
repository: Comfy-Org/ComfyUI_frontend # Install the custom node repository
path: ComfyUI_frontend
- name: Copy ComfyUI_devtools from frontend repo
run: |
mkdir -p ComfyUI/custom_nodes/ComfyUI_devtools
cp -r ComfyUI_frontend/tools/devtools/* ComfyUI/custom_nodes/ComfyUI_devtools/
- name: Checkout custom node repository - name: Checkout custom node repository
uses: actions/checkout@v5 uses: actions/checkout@v5
with: with:
repository: ${{ inputs.owner }}/${{ inputs.repository }} repository: ${{ inputs.owner }}/${{ inputs.repository }}
path: 'ComfyUI/custom_nodes/${{ inputs.repository }}' path: 'ComfyUI/custom_nodes/${{ inputs.repository }}'
- name: Install pnpm - name: Install custom node Python requirements
uses: pnpm/action-setup@v4 working-directory: ComfyUI/custom_nodes/${{ inputs.repository }}
with:
version: 10
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: 'pnpm'
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install ComfyUI requirements
run: |
python -m pip install --upgrade pip
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
pip install -r requirements.txt
pip install wait-for-it
working-directory: ComfyUI
- name: Install custom node requirements
run: | run: |
if [ -f "requirements.txt" ]; then if [ -f "requirements.txt" ]; then
pip install -r requirements.txt pip install -r requirements.txt
fi fi
working-directory: ComfyUI/custom_nodes/${{ inputs.repository }}
- name: Build & Install ComfyUI_frontend # Start ComfyUI Server
run: | - name: Start ComfyUI Server
pnpm install --frozen-lockfile shell: bash
pnpm build
rm -rf ../ComfyUI/web/*
mv dist/* ../ComfyUI/web/
working-directory: ComfyUI_frontend
- name: Start ComfyUI server
run: |
python main.py --cpu --multi-user &
wait-for-it --service 127.0.0.1:8188 -t 600
working-directory: ComfyUI working-directory: ComfyUI
- name: Setup Playwright run: |
uses: ./ComfyUI_frontend/.github/actions/setup-playwright python main.py --cpu --multi-user --front-end-root ../dist --custom-node-path ../ComfyUI/custom_nodes/${{ inputs.repository }} &
wait-for-it --service
- name: Start dev server - name: Start dev server
# Run electron dev server as it is a superset of the web 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. # We do want electron specific UIs to be translated.
run: pnpm dev:electron & run: pnpm dev:electron &
working-directory: ComfyUI_frontend
- name: Capture base i18n - name: Capture base i18n
run: pnpm exec tsx scripts/diff-i18n capture run: pnpm exec tsx scripts/diff-i18n capture
working-directory: ComfyUI_frontend
- name: Update en.json - name: Update en.json
run: pnpm collect-i18n run: pnpm collect-i18n
env: env:
PLAYWRIGHT_TEST_URL: http://localhost:5173 PLAYWRIGHT_TEST_URL: http://localhost:5173
working-directory: ComfyUI_frontend
- name: Update translations - name: Update translations
run: pnpm locale run: pnpm locale
env: env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
working-directory: ComfyUI_frontend
- name: Diff base vs updated i18n - name: Diff base vs updated i18n
run: pnpm exec tsx scripts/diff-i18n diff run: pnpm exec tsx scripts/diff-i18n diff
working-directory: ComfyUI_frontend
- name: Update i18n in custom node repository - name: Update i18n in custom node repository
run: | run: |
LOCALE_DIR=ComfyUI/custom_nodes/${{ inputs.repository }}/locales/ LOCALE_DIR=ComfyUI/custom_nodes/${{ inputs.repository }}/locales/
install -d "$LOCALE_DIR" install -d "$LOCALE_DIR"
cp -rf ComfyUI_frontend/temp/diff/* "$LOCALE_DIR" cp -rf ComfyUI_frontend/temp/diff/* "$LOCALE_DIR"
# Git ops for pushing changes and creating PR
- name: Check and create fork of custom node repository - name: Check and create fork of custom node repository
run: | run: |
# Try to fork the repository # Try to fork the repository

View File

@@ -16,36 +16,29 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v5 uses: actions/checkout@v5
- name: Setup Frontend # Setup playwright environment
- name: Setup ComfyUI Server
uses: ./.github/actions/setup-comfyui-server
- name: Setup ComfyUI Frontend
uses: ./.github/actions/setup-frontend uses: ./.github/actions/setup-frontend
- name: Cache tool outputs
uses: actions/cache@v4
with:
path: |
ComfyUI_frontend/.cache
ComfyUI_frontend/.cache
key: i18n-tools-cache-${{ runner.os }}-${{ hashFiles('ComfyUI_frontend/pnpm-lock.yaml') }}
restore-keys: |
i18n-tools-cache-${{ runner.os }}-
- name: Setup Playwright - name: Setup Playwright
uses: ./.github/actions/setup-playwright uses: ./.github/actions/setup-playwright
- name: Start dev server - name: Start dev server
# Run electron dev server as it is a superset of the web 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. # We do want electron specific UIs to be translated.
run: pnpm dev:electron & run: pnpm dev:electron &
working-directory: ComfyUI_frontend
# Update locales, collect new strings and update translations using OpenAI, then commit changes
- name: Update en.json - name: Update en.json
run: pnpm collect-i18n run: pnpm collect-i18n
env: env:
PLAYWRIGHT_TEST_URL: http://localhost:5173 PLAYWRIGHT_TEST_URL: http://localhost:5173
working-directory: ComfyUI_frontend
- name: Update translations - name: Update translations
run: pnpm locale run: pnpm locale
env: env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
working-directory: ComfyUI_frontend
- name: Commit updated locales - name: Commit updated locales
run: | run: |
git config --global user.name 'github-actions' git config --global user.name 'github-actions'
@@ -59,4 +52,3 @@ jobs:
git add src/locales/ git add src/locales/
git diff --staged --quiet || git commit -m "Update locales [skip ci]" git diff --staged --quiet || git commit -m "Update locales [skip ci]"
git push origin HEAD:${{ github.head_ref }} git push origin HEAD:${{ github.head_ref }}
working-directory: ComfyUI_frontend

View File

@@ -13,24 +13,28 @@ jobs:
update-locales: update-locales:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: Comfy-Org/ComfyUI_frontend_setup_action@v3 - name: Checkout repository
uses: actions/checkout@v5
# Setup playwright environment
- name: Setup ComfyUI Server (and start)
uses: ./.github/actions/setup-comfyui-server
- name: Setup frontend
uses: ./.github/actions/setup-frontend
- name: Setup Playwright - name: Setup Playwright
uses: ./.github/actions/setup-playwright uses: ./.github/actions/setup-playwright
- name: Start dev server - name: Start dev server
# Run electron dev server as it is a superset of the web 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. # We do want electron specific UIs to be translated.
run: pnpm dev:electron & run: pnpm dev:electron &
working-directory: ComfyUI_frontend
- name: Update en.json - name: Update en.json
run: pnpm collect-i18n -- scripts/collect-i18n-node-defs.ts run: pnpm collect-i18n -- scripts/collect-i18n-node-defs.ts
env: env:
PLAYWRIGHT_TEST_URL: http://localhost:5173 PLAYWRIGHT_TEST_URL: http://localhost:5173
working-directory: ComfyUI_frontend
- name: Update translations - name: Update translations
run: pnpm locale run: pnpm locale
env: env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
working-directory: ComfyUI_frontend
- name: Create Pull Request - name: Create Pull Request
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e
with: with:

View File

@@ -3,58 +3,39 @@ name: Update Playwright Expectations
on: on:
pull_request: pull_request:
types: [labeled] types: [ labeled ]
issue_comment:
types: [created]
jobs: jobs:
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: > if: github.event.label.name == 'New Browser Test Expectations'
( github.event_name == 'pull_request' && github.event.label.name == 'New Browser Test Expectations' ) ||
( github.event.issue.pull_request &&
github.event_name == 'issue_comment' &&
(
github.event.comment.author_association == 'OWNER' ||
github.event.comment.author_association == 'MEMBER' ||
github.event.comment.author_association == 'COLLABORATOR'
) &&
startsWith(github.event.comment.body, '/update-playwright') )
steps: steps:
- name: Initial Checkout - name: Checkout workflow repo
uses: actions/checkout@v5 uses: actions/checkout@v5
- name: Pull Request Checkout - name: Setup ComfyUI Server
run: gh pr checkout ${{ github.event.issue.number }} uses: ./.github/actions/setup-comfyui-server
if: github.event.issue.pull_request && github.event_name == 'issue_comment' - name: Setup Playwright
env: uses: ./.github/actions/setup-playwright
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Run Playwright tests and update snapshots
- name: Setup Frontend id: playwright-tests
uses: ./.github/actions/setup-frontend run: pnpm exec playwright test --update-snapshots
- name: Setup Playwright continue-on-error: true
uses: ./.github/actions/setup-playwright - uses: actions/upload-artifact@v4
- name: Run Playwright tests and update snapshots if: always()
id: playwright-tests with:
run: pnpm exec playwright test --update-snapshots name: playwright-report
continue-on-error: true path: ./playwright-report/
working-directory: ComfyUI_frontend retention-days: 30
- uses: actions/upload-artifact@v4 - name: Debugging info
if: always() run: |
with: echo "Branch: ${{ github.head_ref }}"
name: playwright-report git status
path: ComfyUI_frontend/playwright-report/ - name: Commit updated expectations
retention-days: 30 run: |
- name: Debugging info git config --global user.name 'github-actions'
run: | git config --global user.email 'github-actions@github.com'
echo "PR: ${{ github.event.issue.number }}" git fetch origin ${{ github.head_ref }}
git status git checkout -B ${{ github.head_ref }} origin/${{ github.head_ref }}
working-directory: ComfyUI_frontend git add browser_tests
- name: Commit updated expectations git commit -m "[automated] Update test expectations"
run: | git push origin HEAD:${{ github.head_ref }}
git config --global user.name 'github-actions'
git config --global user.email 'github-actions@github.com'
git add browser_tests
git diff --cached --quiet || git commit -m "[automated] Update test expectations"
git push
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: ComfyUI_frontend