diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b83aa8e..58cc701 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,6 @@ permissions: jobs: detect: name: Detect Changes - # Use `ubuntu-24.04` on public repositories. runs-on: ubuntu-latest if: github.event_name != 'pull_request' || github.event.pull_request.draft == false permissions: @@ -54,22 +53,22 @@ jobs: - 'composer.*' phpcs: - '.github/workflows/ci.yml' - - '.github/workflows/reusable-phpcs.yml' + - '.github/workflows/reusable-phpcs-public.yml' # Update this if using private reusable workflow - '.phpcs.xml.dist' phpstan: - '.github/workflows/ci.yml' - - '.github/workflows/reusable-phpstan.yml' + - '.github/workflows/reusable-phpstan-public.yml' # Update this if using private reusable workflow - 'phpstan.neon.dist' phpunit: - '.github/workflows/ci.yml' - - '.github/workflows/reusable-phpunit.yml' + - '.github/workflows/reusable-phpunit-public.yml' # Update this if using private reusable workflow - 'tests/**/*.php' - 'phpunit.xml.dist' - 'package*.json' - '.wp-env.test.json' js: - '.github/workflows/ci.yml' - - '.github/workflows/reusable-lint-css-js.yml' + - '.github/workflows/reusable-lint-css-js-public.yml' # Update this if using private reusable workflow - '.nvmrc' - '**.cjs' - '**.js' @@ -90,12 +89,12 @@ jobs: - '.stylelint.config.js' e2e: - '.github/workflows/ci.yml' - - '.github/workflows/reusable-e2e.yml' + - '.github/workflows/reusable-e2e-public.yml' # Update this if using private reusable workflow - 'tests/e2e/**/*' - 'playwright.config.ts' jest: - '.github/workflows/ci.yml' - - '.github/workflows/reusable-jest.yml' + - '.github/workflows/reusable-jest-public.yml' # Update this if using private reusable workflow - 'tests/js/**/*' - 'src/**/__tests__/**/*' - 'src/**/*.test.ts' @@ -110,8 +109,8 @@ jobs: name: PHPCS needs: detect if: needs.detect.outputs.php == 'true' || needs.detect.outputs.phpcs == 'true' - uses: ./.github/workflows/reusable-phpcs.yml - # uses: ./.github/workflows/reusable-phpcs-public.yml + uses: ./.github/workflows/reusable-phpcs-public.yml + # uses: ./.github/workflows/reusable-phpcs.yml permissions: contents: read with: @@ -121,8 +120,8 @@ jobs: name: PHPStan needs: detect if: needs.detect.outputs.php == 'true' || needs.detect.outputs.phpstan == 'true' - uses: ./.github/workflows/reusable-phpstan.yml - # uses: ./.github/workflows/reusable-phpstan-public.yml + uses: ./.github/workflows/reusable-phpstan-public.yml + # uses: ./.github/workflows/reusable-phpstan.yml permissions: contents: read with: @@ -132,8 +131,8 @@ jobs: name: CSS/JS Lint needs: detect if: needs.detect.outputs.css == 'true' || needs.detect.outputs.js == 'true' - uses: ./.github/workflows/reusable-lint-css-js.yml - # uses: ./.github/workflows/reusable-lint-css-js-public.yml + uses: ./.github/workflows/reusable-lint-css-js-public.yml + # uses: ./.github/workflows/reusable-lint-css-js.yml permissions: contents: read @@ -141,8 +140,8 @@ jobs: name: Jest Unit Tests needs: detect if: needs.detect.outputs.js == 'true' || needs.detect.outputs.jest == 'true' - uses: ./.github/workflows/reusable-jest.yml - # uses: ./.github/workflows/reusable-jest-public.yml + uses: ./.github/workflows/reusable-jest-public.yml + # uses: ./.github/workflows/reusable-jest.yml permissions: contents: read with: @@ -152,8 +151,8 @@ jobs: name: PHPUnit (PHP ${{ matrix.php }}, WP ${{ matrix.wp }}) needs: [detect, build-plugin-zip] if: needs.detect.outputs.php == 'true' || needs.detect.outputs.phpunit == 'true' - uses: ./.github/workflows/reusable-phpunit.yml - # uses: ./.github/workflows/reusable-phpunit-public.yml + uses: ./.github/workflows/reusable-phpunit-public.yml + # uses: ./.github/workflows/reusable-phpunit.yml permissions: contents: read strategy: @@ -175,11 +174,11 @@ jobs: e2e: name: E2E Tests - # needs: detect - needs: phpunit + needs: [detect, build-plugin-zip] + # needs: phpstan if: needs.detect.outputs.php == 'true' || needs.detect.outputs.e2e == 'true' || needs.detect.outputs.js == 'true' || needs.detect.outputs.css == 'true' - uses: ./.github/workflows/reusable-e2e.yml - # uses: ./.github/workflows/reusable-e2e-public.yml + uses: ./.github/workflows/reusable-e2e-public.yml + # uses: ./.github/workflows/reusable-e2e.yml permissions: contents: read with: @@ -189,8 +188,8 @@ jobs: name: Build Plugin Zip permissions: contents: read - uses: ./.github/workflows/reusable-build.yml - # uses: ./.github/workflows/reusable-build-public.yml + uses: ./.github/workflows/reusable-build-public.yml + # uses: ./.github/workflows/reusable-build.yml with: php-version: '8.2' artifact-name: plugin-skeleton-d-pr${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }} @@ -200,8 +199,8 @@ jobs: name: Playground Preview needs: build-plugin-zip if: github.event_name == 'pull_request' - uses: ./.github/workflows/reusable-wp-playground-pr-preview.yml - # uses: ./.github/workflows/reusable-wp-playground-pr-preview-public.yml + uses: ./.github/workflows/reusable-wp-playground-pr-preview-public.yml + # uses: ./.github/workflows/reusable-wp-playground-pr-preview.yml permissions: actions: read contents: write diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ff22840..dcaea51 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,7 +21,7 @@ jobs: steps: - name: Prepare release id: release - uses: googleapis/release-please-action@5c625bfb5d1ff62eadeeb3772007f7f66fdcf071 + uses: googleapis/release-please-action@5c625bfb5d1ff62eadeeb3772007f7f66fdcf071 # v4.4.1 with: token: ${{ secrets.GITHUB_TOKEN }} config-file: release-please-config.json diff --git a/.github/workflows/test-private-workflows.yml b/.github/workflows/test-private-workflows.yml new file mode 100644 index 0000000..2bbc164 --- /dev/null +++ b/.github/workflows/test-private-workflows.yml @@ -0,0 +1,181 @@ +# These are used by the repository to test the private workflows for the repository. +# Projects using the skeleton should remove this file and update the `ci.yml` workflow. +name: CI (Private Workflows) + +on: + push: + branches: + - main + pull_request: + branches: + - main + - release/** + types: [opened, synchronize, reopened, ready_for_review] + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + detect: + name: Detect Changes + runs-on: ubuntu-24.04 + if: github.event_name != 'pull_request' || github.event.pull_request.draft == false + permissions: + contents: read + pull-requests: read + outputs: + php: ${{ steps.filter.outputs.php }} + phpcs: ${{ steps.filter.outputs.phpcs }} + phpstan: ${{ steps.filter.outputs.phpstan }} + phpunit: ${{ steps.filter.outputs.phpunit }} + js: ${{ steps.filter.outputs.js }} + css: ${{ steps.filter.outputs.css }} + e2e: ${{ steps.filter.outputs.e2e }} + jest: ${{ steps.filter.outputs.jest }} + + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + + - name: Detect file changes + uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1 + id: filter + with: + filters: | + php: + - 'composer.*' + phpcs: + - '.github/workflows/reusable-phpcs.yml' + - '.github/workflows/test-private-workflows.yml' + - '.phpcs.xml.dist' + phpstan: + - '.github/workflows/reusable-phpstan.yml' + - '.github/workflows/test-private-workflows.yml' + - 'phpstan.neon.dist' + phpunit: + - '.github/workflows/reusable-phpunit.yml' + - '.github/workflows/test-private-workflows.yml' + - 'phpunit.xml.dist' + - 'package*.json' + js: + - '.github/workflows/reusable-lint-css-js.yml' + - '.github/workflows/test-private-workflows.yml' + - 'eslint.config.mjs' + - '.nvmrc' + - '.prettierrc.js' + - 'package*.json' + - 'tsconfig*.json' + css: + - '.stylelintignore' + - '.stylelint.config.js*' + e2e: + - '.github/workflows/reusable-e2e.yml' + - '.github/workflows/test-private-workflows.yml' + - 'playwright.config.ts' + jest: + - '.github/workflows/reusable-jest.yml' + - '.github/workflows/test-private-workflows.yml' + - 'jest.config.js' + - 'package*.json' + + phpcs: + name: PHPCS + needs: detect + if: needs.detect.outputs.php == 'true' || needs.detect.outputs.phpcs == 'true' + uses: ./.github/workflows/reusable-phpcs.yml + permissions: + contents: read + with: + php-version: '8.2' + + phpstan: + name: PHPStan + needs: detect + if: needs.detect.outputs.php == 'true' || needs.detect.outputs.phpstan == 'true' + uses: ./.github/workflows/reusable-phpstan.yml + permissions: + contents: read + with: + php-version: '8.2' + + lint-css-js: + name: CSS/JS Lint + needs: detect + if: needs.detect.outputs.css == 'true' || needs.detect.outputs.js == 'true' + uses: ./.github/workflows/reusable-lint-css-js.yml + permissions: + contents: read + + jest: + name: Jest Unit Tests + needs: detect + if: needs.detect.outputs.js == 'true' || needs.detect.outputs.jest == 'true' + uses: ./.github/workflows/reusable-jest.yml + permissions: + contents: read + with: + coverage: true + + phpunit: + name: PHPUnit (PHP ${{ matrix.php }}, WP ${{ matrix.wp }}) + needs: detect + if: needs.detect.outputs.php == 'true' || needs.detect.outputs.phpunit == 'true' + uses: ./.github/workflows/reusable-phpunit.yml + permissions: + contents: read + strategy: + fail-fast: false + matrix: + php: ['8.4'] + wp: ['latest'] + include: + - php: '8.4' + wp: 'latest' + coverage: true + with: + php-version: ${{ matrix.php }} + wp-version: ${{ matrix.wp }} + coverage: ${{ matrix.coverage == true }} + secrets: inherit + + e2e: + name: E2E Tests + needs: detect + if: needs.detect.outputs.php == 'true' || needs.detect.outputs.e2e == 'true' || needs.detect.outputs.js == 'true' || needs.detect.outputs.css == 'true' + uses: ./.github/workflows/reusable-e2e.yml + permissions: + contents: read + with: + php-version: '8.2' + + build-plugin-zip: + name: Build Plugin Zip + permissions: + contents: read + uses: ./.github/workflows/reusable-build.yml + with: + php-version: '8.2' + artifact-name: plugin-skeleton-d-pr-private-${{ github.event.pull_request.head.sha || github.sha }} + + secrets: inherit + + playground-preview: + name: Playground Preview + needs: build-plugin-zip + if: github.event_name == 'pull_request' + uses: ./.github/workflows/reusable-wp-playground-pr-preview.yml + permissions: + actions: read + contents: write + pull-requests: write + with: + run-id: ${{ github.run_id }} + artifact-prefix: 'plugin-skeleton-d-pr-private' + artifact-filename: 'plugin-skeleton-d.zip'