From 2e6bf4896e3949da499e06e151abc7cf1a5a34a2 Mon Sep 17 00:00:00 2001 From: snomiao Date: Thu, 14 Aug 2025 13:45:29 +0000 Subject: [PATCH] [feat] Add comprehensive caching to CI/CD workflows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add ESLint cache (.eslintcache) to auto-fix and fork PR workflows - Add npm cache to all Node.js setup steps across workflows - Add Vite build cache (node_modules/.vite) to improve build performance - Add Playwright browser cache with version-specific keys - Optimize test-ui, vitest, release, and auto-fix workflows 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/workflows/auto-fix-and-update.yaml | 29 +++++++++++++++++----- .github/workflows/release.yaml | 9 +++++++ .github/workflows/test-ui.yaml | 26 +++++++++++++++++++ .github/workflows/vitest.yaml | 9 +++++++ 4 files changed, 67 insertions(+), 6 deletions(-) diff --git a/.github/workflows/auto-fix-and-update.yaml b/.github/workflows/auto-fix-and-update.yaml index 7a2901e34..7b202264e 100644 --- a/.github/workflows/auto-fix-and-update.yaml +++ b/.github/workflows/auto-fix-and-update.yaml @@ -18,7 +18,16 @@ jobs: - name: Setup ComfyUI Frontend and Backend uses: Comfy-Org/ComfyUI_frontend_setup_action@v2.3 - # Step 1: Run lint and format fixes + # Step 1: Cache ESLint for better performance + - name: Cache ESLint + uses: actions/cache@v4 + with: + path: ComfyUI_frontend/.eslintcache + key: ${{ runner.os }}-eslint-${{ hashFiles('ComfyUI_frontend/eslint.config.js', 'ComfyUI_frontend/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-eslint- + + # Step 2: Run lint and format fixes - name: Run ESLint with auto-fix run: npm run lint:fix working-directory: ComfyUI_frontend @@ -27,7 +36,7 @@ jobs: run: npm run format working-directory: ComfyUI_frontend - # Step 2: Update locales (only if there are relevant changes) + # Step 3: Update locales (only if there are relevant changes) - name: Check if locale updates needed id: check-locale-changes run: | @@ -63,7 +72,7 @@ jobs: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} working-directory: ComfyUI_frontend - # Step 3: Check for any changes from both lint-format and locale updates + # Step 4: Check for any changes from both lint-format and locale updates - name: Check for changes id: verify-changed-files run: | @@ -77,7 +86,7 @@ jobs: fi working-directory: ComfyUI_frontend - # Step 4: Commit all changes in a single commit + # Step 5: Commit all changes in a single commit - name: Commit auto-fixes and locale updates if: steps.verify-changed-files.outputs.changed == 'true' run: | @@ -94,7 +103,7 @@ jobs: git push origin HEAD:${{ github.head_ref }} working-directory: ComfyUI_frontend - # Step 5: Run final validation + # Step 6: Run final validation - name: Final validation run: | npm run lint @@ -102,7 +111,7 @@ jobs: npm run knip working-directory: ComfyUI_frontend - # Step 6: Comment on PR about what was fixed + # Step 7: Comment on PR about what was fixed - name: Comment on PR about auto-fixes if: steps.verify-changed-files.outputs.changed == 'true' uses: actions/github-script@v7 @@ -149,6 +158,14 @@ jobs: - name: Install dependencies run: npm ci + - name: Cache ESLint + uses: actions/cache@v4 + with: + path: .eslintcache + key: ${{ runner.os }}-eslint-fork-${{ hashFiles('eslint.config.js', 'package-lock.json') }} + restore-keys: | + ${{ runner.os }}-eslint-fork- + - name: Check linting and formatting id: check-lint-format run: | diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 55c088163..0f7fb02ee 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -22,6 +22,7 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 'lts/*' + cache: 'npm' - name: Get current version id: current_version run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT @@ -34,6 +35,13 @@ jobs: else echo "is_prerelease=false" >> $GITHUB_OUTPUT fi + - name: Cache Vite build + uses: actions/cache@v4 + with: + path: node_modules/.vite + key: ${{ runner.os }}-vite-release-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.os }}-vite-release- - name: Build project env: SENTRY_DSN: ${{ secrets.SENTRY_DSN }} @@ -117,6 +125,7 @@ jobs: with: node-version: 'lts/*' registry-url: https://registry.npmjs.org + cache: 'npm' - run: npm ci - run: npm run build:types - name: Publish package diff --git a/.github/workflows/test-ui.yaml b/.github/workflows/test-ui.yaml index 39411ade3..23df92a82 100644 --- a/.github/workflows/test-ui.yaml +++ b/.github/workflows/test-ui.yaml @@ -35,6 +35,16 @@ jobs: - uses: actions/setup-node@v4 with: node-version: lts/* + cache: 'npm' + cache-dependency-path: ComfyUI_frontend/package-lock.json + + - name: Cache Vite build + uses: actions/cache@v4 + with: + path: ComfyUI_frontend/node_modules/.vite + key: ${{ runner.os }}-vite-build-${{ hashFiles('ComfyUI_frontend/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-vite-build- - name: Build ComfyUI_frontend run: | @@ -92,7 +102,23 @@ jobs: wait-for-it --service 127.0.0.1:8188 -t 600 working-directory: ComfyUI + - name: Get Playwright version + id: playwright-version + run: echo "version=$(npm list @playwright/test --depth=0 --json | jq -r '.dependencies["@playwright/test"].version')" >> $GITHUB_OUTPUT + working-directory: ComfyUI_frontend + + - name: Cache Playwright browsers + uses: actions/cache@v4 + id: playwright-cache + with: + path: ~/.cache/ms-playwright + key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}-chromium + restore-keys: | + ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}- + ${{ runner.os }}-playwright- + - name: Install Playwright Browsers + if: steps.playwright-cache.outputs.cache-hit != 'true' run: npx playwright install chromium --with-deps working-directory: ComfyUI_frontend diff --git a/.github/workflows/vitest.yaml b/.github/workflows/vitest.yaml index 788b6aba4..5561f2231 100644 --- a/.github/workflows/vitest.yaml +++ b/.github/workflows/vitest.yaml @@ -17,10 +17,19 @@ jobs: uses: actions/setup-node@v4 with: node-version: 'lts/*' + cache: 'npm' - name: Install dependencies run: npm ci + - name: Cache Vite + uses: actions/cache@v4 + with: + path: node_modules/.vite + key: ${{ runner.os }}-vite-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.os }}-vite- + - name: Run Vitest tests run: | npm run test:component