diff --git a/.github/workflows/e2e-and-js-tests.yml b/.github/workflows/e2e-tests.yml similarity index 81% rename from .github/workflows/e2e-and-js-tests.yml rename to .github/workflows/e2e-tests.yml index ba3a1f17..ca78870c 100644 --- a/.github/workflows/e2e-and-js-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -1,11 +1,36 @@ -name: E2E and JS tests +name: E2E Tests on: - pull_request: push: - branches-ignore: - - develop - - main + paths: + - '**.js' + - '**.jsx' + - '**.ts' + - '**.tsx' + - '**.scss' + - '**.css' + - 'package.json' + - 'package-lock.json' + - 'webpack.config.js' + - '.wp-env.json' + - 'tests/e2e/**' + - '.github/workflows/e2e-tests.yml' + pull_request: + branches: [develop, main] + paths: + - '**.js' + - '**.jsx' + - '**.ts' + - '**.tsx' + - '**.scss' + - '**.css' + - 'package.json' + - 'package-lock.json' + - 'webpack.config.js' + - '.wp-env.json' + - 'tests/e2e/**' + - '.github/workflows/e2e-tests.yml' + workflow_dispatch: # Disable all permissions by default; grant minimal permissions per job permissions: {} @@ -16,7 +41,7 @@ concurrency: jobs: build: - name: Build and Lint + name: Build runs-on: ubuntu-latest permissions: contents: read @@ -60,9 +85,6 @@ 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: Run Lint JS - run: npm run lint-js - - name: Upload build artifacts uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 with: @@ -71,7 +93,7 @@ jobs: retention-days: 1 test: - name: E2E and Jest tests + 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 @@ -106,5 +128,5 @@ jobs: - name: Install WordPress with wp-env run: npm run wp-env start - - name: Run tests - run: npm run test + - name: Run E2E tests + run: npm run test-e2e diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 57480671..67a804a7 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -1,11 +1,24 @@ name: Integration Tests on: - pull_request: push: - branches-ignore: - - develop - - main + paths: + - '**.php' + - 'composer.json' + - 'composer.lock' + - 'phpunit.xml.dist' + - '.wp-env.json' + - '.github/workflows/integration.yml' + pull_request: + branches: [develop, main] + paths: + - '**.php' + - 'composer.json' + - 'composer.lock' + - 'phpunit.xml.dist' + - '.wp-env.json' + - '.github/workflows/integration.yml' + workflow_dispatch: # Disable all permissions by default; grant minimal permissions per job permissions: {} diff --git a/.github/workflows/js-tests.yml b/.github/workflows/js-tests.yml new file mode 100644 index 00000000..f185470f --- /dev/null +++ b/.github/workflows/js-tests.yml @@ -0,0 +1,60 @@ +name: JS Tests + +on: + push: + paths: + - '**.js' + - '**.jsx' + - '**.ts' + - '**.tsx' + - 'package.json' + - 'package-lock.json' + - 'jest.config.js' + - '.github/workflows/js-tests.yml' + pull_request: + branches: [develop, main] + paths: + - '**.js' + - '**.jsx' + - '**.ts' + - '**.tsx' + - 'package.json' + - 'package-lock.json' + - 'jest.config.js' + - '.github/workflows/js-tests.yml' + workflow_dispatch: + +# Disable all permissions by default; grant minimal permissions per job +permissions: {} + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + lint-and-test: + name: Lint and Jest Tests + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Checkout code + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Set up NodeJS 20 + uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 + with: + node-version: '20' + cache: npm + + - name: Install dependencies + run: npm ci + + - name: Run Lint JS + run: npm run lint-js + + - name: Run Jest tests + run: npm run test-jest diff --git a/.github/workflows/php-lint.yml b/.github/workflows/php-lint.yml index c609c23b..ac1ded3e 100644 --- a/.github/workflows/php-lint.yml +++ b/.github/workflows/php-lint.yml @@ -1,11 +1,22 @@ name: PHP Lint on: - pull_request: push: - branches-ignore: - - develop - - main + paths: + - '**.php' + - 'composer.json' + - 'composer.lock' + - '.phpcs.xml.dist' + - '.github/workflows/php-lint.yml' + pull_request: + branches: [develop, main] + paths: + - '**.php' + - 'composer.json' + - 'composer.lock' + - '.phpcs.xml.dist' + - '.github/workflows/php-lint.yml' + workflow_dispatch: # Disable all permissions by default; grant minimal permissions per job permissions: {}