diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 26617776..760febd2 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -40,9 +40,11 @@ concurrency: cancel-in-progress: true jobs: - build: - name: Build - runs-on: ubuntu-latest + test: + name: Build and E2E Tests + # Pin to ubuntu-22.04 for Playwright compatibility + # ubuntu-latest (24.04) has library version mismatches with Playwright's WebKit dependencies + runs-on: ubuntu-22.04 permissions: contents: read @@ -85,46 +87,27 @@ jobs: echo "| custom-status-block.js | $(du -h build/custom-status-block.js | cut -f1) |" >> $GITHUB_STEP_SUMMARY echo "| calendar-react.js | $(du -h build/calendar-react.js | cut -f1) |" >> $GITHUB_STEP_SUMMARY - - name: Upload build artifacts - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 - with: - name: build-artifacts - path: build/ - retention-days: 1 - - test: - name: E2E Tests - # Pin to ubuntu-22.04 for Playwright compatibility - # ubuntu-latest (24.04) has library version mismatches with Playwright's WebKit dependencies - runs-on: ubuntu-22.04 - needs: build - permissions: - contents: read - - steps: - - name: Checkout code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - persist-credentials: false - - - name: Set up NodeJS 20 - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 - with: - node-version: '20' - cache: npm - - - name: Install dependencies - run: npm ci + - name: Resolve Playwright version + id: playwright-version + run: | + version=$(node -p "require('@playwright/test/package.json').version") + echo "version=${version}" >> "$GITHUB_OUTPUT" - - name: Download build artifacts - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + - name: Cache Playwright browsers + id: playwright-cache + uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 with: - name: build-artifacts - path: build/ + path: ~/.cache/ms-playwright + key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }} - name: Install Playwright browsers and system dependencies + if: steps.playwright-cache.outputs.cache-hit != 'true' run: npx playwright install --with-deps chromium + - name: Install Playwright system dependencies + if: steps.playwright-cache.outputs.cache-hit == 'true' + run: npx playwright install-deps chromium + - name: Install WordPress with wp-env run: npm run wp-env start diff --git a/.github/workflows/js-tests.yml b/.github/workflows/js-tests.yml index 62616ca5..343dabb2 100644 --- a/.github/workflows/js-tests.yml +++ b/.github/workflows/js-tests.yml @@ -53,8 +53,19 @@ jobs: - name: Install dependencies run: npm ci + - name: Cache ESLint and Jest results + uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 + with: + path: | + .eslintcache + node_modules/.cache/jest + key: js-cache-${{ runner.os }}-${{ hashFiles('package-lock.json', 'jest.config.js', '.eslintrc*', 'eslint.config.*') }}-${{ github.sha }} + restore-keys: | + js-cache-${{ runner.os }}-${{ hashFiles('package-lock.json', 'jest.config.js', '.eslintrc*', 'eslint.config.*') }}- + js-cache-${{ runner.os }}- + - name: Run Lint JS - run: npm run lint-js + run: npm run lint-js -- --cache - name: Run Jest tests run: npm run test-jest diff --git a/.github/workflows/php-lint.yml b/.github/workflows/php-lint.yml index 6261f551..01ac88e4 100644 --- a/.github/workflows/php-lint.yml +++ b/.github/workflows/php-lint.yml @@ -49,8 +49,17 @@ jobs: with: composer-options: --prefer-dist --no-progress + - name: Cache PHPCS results + uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 + with: + path: .phpcs-cache + key: phpcs-${{ runner.os }}-${{ hashFiles('.phpcs.xml.dist', 'composer.json') }}-${{ github.sha }} + restore-keys: | + phpcs-${{ runner.os }}-${{ hashFiles('.phpcs.xml.dist', 'composer.json') }}- + phpcs-${{ runner.os }}- + - name: PHP syntax lint run: composer lint-ci | cs2pr - name: PHP coding standards - run: composer cs -- --report=checkstyle | cs2pr + run: composer cs -- --cache=.phpcs-cache --report=checkstyle | cs2pr diff --git a/.gitignore b/.gitignore index 250094d5..e29be333 100644 --- a/.gitignore +++ b/.gitignore @@ -11,5 +11,9 @@ dist/ .phpunit.cache/ artifacts/ +# Tool caches +.phpcs-cache +.eslintcache + # Local wp-env overrides .wp-env.override.json