Repository navigation
Blocks: Correctly document the blockName property as being nullable. #139
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test Default Themes & Create ZIPs | |
| on: | |
| push: | |
| branches: | |
| - trunk | |
| - '3.[89]' | |
| - '[4-9].[0-9]' | |
| paths: | |
| # Changing the preferred version of Node.js could affect themes with build processes. | |
| - '.npmrc' | |
| - '.nvmrc' | |
| - '.github/actions/setup-npm/**' | |
| # Changes to any themes with a build script should be confirmed. | |
| - 'src/wp-content/themes/twentynineteen/**' | |
| - 'src/wp-content/themes/twentytwenty/**' | |
| - 'src/wp-content/themes/twentytwentyone/**' | |
| - 'src/wp-content/themes/twentytwentytwo/**' | |
| - 'src/wp-content/themes/twentytwentyfive/**' | |
| - 'src/wp-content/themes/ipsum/**' | |
| # Changes to this workflow file should always verify success. | |
| - '.github/workflows/test-and-zip-default-themes.yml' | |
| pull_request: | |
| branches: | |
| - trunk | |
| - '3.[89]' | |
| - '[4-9].[0-9]' | |
| paths: | |
| # Changing the preferred version of Node.js could affect themes with build processes. | |
| - '.npmrc' | |
| - '.nvmrc' | |
| - '.github/actions/setup-npm/**' | |
| # Changes to any themes with a build script should be confirmed. | |
| - 'src/wp-content/themes/twentynineteen/**' | |
| - 'src/wp-content/themes/twentytwenty/**' | |
| - 'src/wp-content/themes/twentytwentyone/**' | |
| - 'src/wp-content/themes/twentytwentytwo/**' | |
| - 'src/wp-content/themes/twentytwentyfive/**' | |
| - 'src/wp-content/themes/ipsum/**' | |
| # Changes to this workflow file should always verify success. | |
| - '.github/workflows/test-and-zip-default-themes.yml' | |
| workflow_dispatch: | |
| inputs: | |
| branch: | |
| description: 'The branch to create ZIP files from' | |
| required: true | |
| type: string | |
| default: 'trunk' | |
| theme: | |
| description: 'The theme to test and zip' | |
| required: true | |
| type: choice | |
| default: 'all' | |
| options: | |
| - all | |
| - ipsum | |
| - twentytwentyfive | |
| - twentytwentyfour | |
| - twentytwentythree | |
| - twentytwentytwo | |
| - twentytwentyone | |
| - twentytwenty | |
| - twentynineteen | |
| - twentyseventeen | |
| - twentysixteen | |
| - twentyfifteen | |
| - twentyfourteen | |
| - twentythirteen | |
| - twentytwelve | |
| - twentyeleven | |
| - twentyten | |
| # Cancels all previous workflow runs for pull requests that have not completed. | |
| concurrency: | |
| # The concurrency group contains the workflow name and the pull request number for pull requests | |
| # or the commit hash for any other events, plus the selected branch and theme. | |
| group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.sha }}-${{ inputs.branch }}-${{ inputs.theme }} | |
| cancel-in-progress: true | |
| # Disable permissions for all available scopes by default. | |
| # Any needed permissions should be configured at the job level. | |
| permissions: {} | |
| jobs: | |
| # Selects the themes to check, build, and package. | |
| determine-themes: | |
| name: Determine Themes | |
| runs-on: ubuntu-24.04 | |
| permissions: {} | |
| timeout-minutes: 5 | |
| if: | | |
| github.repository == 'WordPress/wordpress-develop' || ( | |
| github.event_name == 'pull_request' && ( | |
| ! github.event.repository.private || | |
| ! github.event.pull_request.draft || | |
| contains( github.event.pull_request.labels.*.name, 'Draft Workflow Runs' ) | |
| ) | |
| ) | |
| outputs: | |
| themes: ${{ steps.set-themes.outputs.themes }} | |
| build_themes: ${{ steps.set-themes.outputs.build_themes }} | |
| has_build_themes: ${{ steps.set-themes.outputs.has_build_themes }} | |
| steps: | |
| - name: Determine themes to test and zip | |
| id: set-themes | |
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | |
| with: | |
| script: | | |
| const allThemes = [ | |
| 'ipsum', | |
| 'twentytwentyfive', | |
| 'twentytwentyfour', | |
| 'twentytwentythree', | |
| 'twentytwentytwo', | |
| 'twentytwentyone', | |
| 'twentytwenty', | |
| 'twentynineteen', | |
| 'twentyseventeen', | |
| 'twentysixteen', | |
| 'twentyfifteen', | |
| 'twentyfourteen', | |
| 'twentythirteen', | |
| 'twentytwelve', | |
| 'twentyeleven', | |
| 'twentyten', | |
| ]; | |
| const buildThemes = [ | |
| 'ipsum', | |
| 'twentytwentyfive', | |
| 'twentytwentytwo', | |
| 'twentytwentyone', | |
| 'twentytwenty', | |
| 'twentynineteen', | |
| ]; | |
| const selected = context.eventName === 'workflow_dispatch' ? ( context.payload.inputs?.theme || 'all' ) : 'all'; | |
| if ( selected !== 'all' && ! allThemes.includes( selected ) ) { | |
| core.setFailed( 'Unknown theme selected.' ); | |
| return; | |
| } | |
| const themes = selected === 'all' ? allThemes : [ selected ]; | |
| const filteredBuildThemes = buildThemes.filter( ( theme ) => themes.includes( theme ) ); | |
| core.setOutput( 'themes', JSON.stringify( themes ) ); | |
| core.setOutput( 'build_themes', JSON.stringify( filteredBuildThemes ) ); | |
| core.setOutput( 'has_build_themes', filteredBuildThemes.length > 0 ); | |
| # Checks for zero-byte files. | |
| # | |
| # Occasionally, binary files such as images and fonts are added to themes incorrectly. | |
| # This checks that all files contain contents. | |
| # | |
| # Performs the following steps: | |
| # - Checks out the repository. | |
| # - Checks for zero-byte (empty) files. | |
| check-for-empty-files: | |
| name: ${{ matrix.theme }} empty file check | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: read | |
| needs: [ determine-themes ] | |
| timeout-minutes: 10 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| theme: ${{ fromJson( needs.determine-themes.outputs.themes ) }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| ref: ${{ github.event_name == 'workflow_dispatch' && inputs.branch || github.ref }} | |
| show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} | |
| persist-credentials: false | |
| - name: Check whether theme exists | |
| id: theme-exists | |
| working-directory: . | |
| run: | | |
| if [[ -d "src/wp-content/themes/${THEME}" ]]; then | |
| echo "exists=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "exists=false" >> "$GITHUB_OUTPUT" | |
| echo "Theme ${THEME} does not exist on the selected branch." | |
| fi | |
| env: | |
| THEME: ${{ matrix.theme }} | |
| - name: Check for zero-byte (empty) files | |
| if: ${{ steps.theme-exists.outputs.exists == 'true' }} | |
| run: | | |
| [[ ! $(find "src/wp-content/themes/${THEME}" -empty) ]] | |
| env: | |
| THEME: ${{ matrix.theme }} | |
| # Tests the build script for themes that have one. | |
| # | |
| # Performs the following steps: | |
| # - Checks out the repository. | |
| # - Sets up Node.js. | |
| # - Installs npm dependencies. | |
| # - Runs the theme build script. | |
| # - Ensures version-controlled files are not modified or deleted. | |
| test-build-scripts: | |
| name: Test ${{ matrix.theme }} build script | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: read | |
| needs: [ determine-themes ] | |
| timeout-minutes: 10 | |
| # Skip this job before expanding an empty build matrix. | |
| if: ${{ needs.determine-themes.outputs.has_build_themes == 'true' }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| theme: ${{ fromJson( needs.determine-themes.outputs.build_themes ) }} | |
| defaults: | |
| run: | |
| working-directory: src/wp-content/themes/${{ matrix.theme }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| ref: ${{ github.event_name == 'workflow_dispatch' && inputs.branch || github.ref }} | |
| show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} | |
| persist-credentials: false | |
| - name: Check whether theme exists | |
| id: theme-exists | |
| working-directory: . | |
| run: | | |
| if [[ -d "src/wp-content/themes/${THEME}" ]]; then | |
| echo "exists=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "exists=false" >> "$GITHUB_OUTPUT" | |
| echo "Theme ${THEME} does not exist on the selected branch." | |
| fi | |
| env: | |
| THEME: ${{ matrix.theme }} | |
| - name: Set up Node.js | |
| if: ${{ steps.theme-exists.outputs.exists == 'true' }} | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version-file: 'src/wp-content/themes/${{ matrix.theme }}/.nvmrc' | |
| package-manager-cache: false | |
| - name: Set up npm | |
| # A workflow_dispatch run can check out a release branch, which lacks the action. | |
| if: ${{ steps.theme-exists.outputs.exists == 'true' && hashFiles('.github/actions/setup-npm/action.yml') != '' }} | |
| uses: ./.github/actions/setup-npm | |
| with: | |
| working-directory: src/wp-content/themes/${{ matrix.theme }} | |
| - name: Install npm dependencies | |
| if: ${{ steps.theme-exists.outputs.exists == 'true' }} | |
| run: npm ci | |
| - name: Build theme | |
| if: ${{ steps.theme-exists.outputs.exists == 'true' }} | |
| run: npm run build | |
| - name: Check for changes to versioned files | |
| id: built-file-check | |
| if: ${{ steps.theme-exists.outputs.exists == 'true' && github.event_name == 'pull_request' }} | |
| run: | | |
| if git diff --quiet; then | |
| echo "uncommitted_changes=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "uncommitted_changes=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Display changes to versioned files | |
| if: ${{ steps.built-file-check.outputs.uncommitted_changes == 'true' }} | |
| run: git diff | |
| - name: Save diff to a file | |
| if: ${{ steps.built-file-check.outputs.uncommitted_changes == 'true' }} | |
| run: git diff > ./changes.diff | |
| # Uploads the diff file as an artifact. | |
| - name: Upload diff file as artifact | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| if: ${{ steps.built-file-check.outputs.uncommitted_changes == 'true' }} | |
| with: | |
| name: pr-built-file-changes | |
| path: src/wp-content/themes/${{ matrix.theme }}/changes.diff | |
| - name: Ensure version-controlled files are not modified or deleted | |
| if: ${{ steps.theme-exists.outputs.exists == 'true' }} | |
| run: git diff --exit-code | |
| # Prepares bundled themes for release. | |
| # | |
| # Performs the following steps: | |
| # - Checks out the repository. | |
| # - Uploads the theme files as a workflow artifact (files uploaded as an artifact are automatically zipped). | |
| bundle-theme: | |
| name: Create ${{ matrix.theme }} ZIP file | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: read | |
| needs: [ determine-themes, check-for-empty-files, test-build-scripts ] | |
| timeout-minutes: 10 | |
| if: | | |
| ! cancelled() && | |
| github.repository == 'WordPress/wordpress-develop' && | |
| needs.determine-themes.result == 'success' && | |
| needs.check-for-empty-files.result == 'success' && | |
| ( needs.test-build-scripts.result == 'success' || needs.test-build-scripts.result == 'skipped' ) | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| theme: ${{ fromJson( needs.determine-themes.outputs.themes ) }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| ref: ${{ github.event_name == 'workflow_dispatch' && inputs.branch || github.ref }} | |
| show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} | |
| persist-credentials: false | |
| - name: Check whether theme exists | |
| id: theme-exists | |
| working-directory: . | |
| run: | | |
| if [[ -d "src/wp-content/themes/${THEME}" ]]; then | |
| echo "exists=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "exists=false" >> "$GITHUB_OUTPUT" | |
| echo "Theme ${THEME} does not exist on the selected branch." | |
| if [[ "${SELECTED_THEME}" != 'all' ]]; then | |
| exit 1 | |
| fi | |
| fi | |
| env: | |
| THEME: ${{ matrix.theme }} | |
| SELECTED_THEME: ${{ github.event_name == 'workflow_dispatch' && inputs.theme || 'all' }} | |
| - name: Set up Node.js for themes needing minification | |
| if: ${{ steps.theme-exists.outputs.exists == 'true' && ( matrix.theme == 'twentytwentytwo' || matrix.theme == 'twentytwentyfive' || matrix.theme == 'ipsum' ) }} | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version-file: 'src/wp-content/themes/${{ matrix.theme }}/.nvmrc' | |
| package-manager-cache: false | |
| - name: Set up npm | |
| # A workflow_dispatch run can check out a release branch, which lacks the action. | |
| if: ${{ steps.theme-exists.outputs.exists == 'true' && ( matrix.theme == 'twentytwentytwo' || matrix.theme == 'twentytwentyfive' || matrix.theme == 'ipsum' ) && hashFiles('.github/actions/setup-npm/action.yml') != '' }} | |
| uses: ./.github/actions/setup-npm | |
| with: | |
| working-directory: src/wp-content/themes/${{ matrix.theme }} | |
| - name: Install npm dependencies | |
| if: ${{ steps.theme-exists.outputs.exists == 'true' && ( matrix.theme == 'twentytwentytwo' || matrix.theme == 'twentytwentyfive' || matrix.theme == 'ipsum' ) }} | |
| run: npm ci | |
| working-directory: src/wp-content/themes/${{ matrix.theme }} | |
| - name: Build theme assets | |
| if: ${{ steps.theme-exists.outputs.exists == 'true' && ( matrix.theme == 'twentytwentytwo' || matrix.theme == 'twentytwentyfive' || matrix.theme == 'ipsum' ) }} | |
| run: npm run build | |
| working-directory: src/wp-content/themes/${{ matrix.theme }} | |
| - name: Upload theme ZIP as an artifact | |
| if: ${{ steps.theme-exists.outputs.exists == 'true' }} | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: ${{ matrix.theme }} | |
| path: | | |
| src/wp-content/themes/${{ matrix.theme }} | |
| !src/wp-content/themes/${{ matrix.theme }}/node_modules | |
| if-no-files-found: error | |
| slack-notifications: | |
| name: Slack Notifications | |
| uses: ./.github/workflows/slack-notifications.yml | |
| permissions: | |
| actions: read | |
| contents: read | |
| needs: [ determine-themes, check-for-empty-files, bundle-theme, test-build-scripts ] | |
| if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }} | |
| with: | |
| calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }} | |
| secrets: | |
| SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }} | |
| SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }} | |
| SLACK_GHA_FIXED_WEBHOOK: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }} | |
| SLACK_GHA_FAILURE_WEBHOOK: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }} | |
| failed-workflow: | |
| name: Failed workflow tasks | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| actions: write | |
| needs: [ slack-notifications ] | |
| if: | | |
| always() && | |
| github.repository == 'WordPress/wordpress-develop' && | |
| github.event_name != 'pull_request' && | |
| github.run_attempt < 2 && | |
| ( | |
| contains( needs.*.result, 'cancelled' ) || | |
| contains( needs.*.result, 'failure' ) | |
| ) | |
| steps: | |
| - name: Dispatch workflow run | |
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | |
| with: | |
| retries: 2 | |
| retry-exempt-status-codes: 418 | |
| script: | | |
| github.rest.actions.createWorkflowDispatch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: 'failed-workflow.yml', | |
| ref: 'trunk', | |
| inputs: { | |
| run_id: `${context.runId}`, | |
| } | |
| }); |