Make WordPress Core

Opened 2 days ago

Last modified 14 hours ago

#66405 new enhancement

Build/Test Tools: Allow for the test and zip of a single theme in Test Default Themes & Create ZIPs

Reported by: jeremyfelt Owned by:
Priority: normal Milestone: Awaiting Review
Component: Build/Test Tools Version:
Severity: normal Keywords: has-patch
Cc: Focuses:

Description

The Test Default Themes & Create ZIPs workflow is run manually during a core release that requires one or more default themes to be packaged. In its current state, all default themes are tested and packaged.

In WordPress 7.1.4, only Twenty Twenty had changes. It would be nice if there was an option to select a single theme when running that workflow.

Change History (3)

#1 @abcd95
2 days ago

Took a look at this from a couple of angles, and I think the simplest thing here would be in ​test-and-zip-default-themes.yml, we can add a theme input to workflow_dispatch with type: choice, defaulting to all so pushes, PRs, and full release runs stay unchanged:

  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

Because GitHub Actions does not allow checking matrix.theme inside a job-level if, we can use a quick determine-themes pre-job that returns the JSON matrix for fromJson(), similar to what we already do in ​performance.yml:

  determine-themes:
    name: Determine Themes
    runs-on: ubuntu-24.04
    permissions: {}
    outputs:
      themes: ${{ steps.set-themes.outputs.themes }}
      build_themes: ${{ steps.set-themes.outputs.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 = [ 'twentytwentyfive', 'twentytwentytwo', 'twentytwentyone', 'twentytwenty', 'twentynineteen' ];

            const selected = context.eventName === 'workflow_dispatch' ? '${{ inputs.theme }}' : 'all';
            const filteredThemes = selected === 'all' ? allThemes : [ selected ];
            const filteredBuild = selected === 'all' ? buildThemes : ( buildThemes.includes( selected ) ? [ selected ] : [] );

            core.setOutput( 'themes', JSON.stringify( filteredThemes ) );
            core.setOutput( 'build_themes', JSON.stringify( filteredBuild ) );

Then check-for-empty-files and bundle-theme can simply use:

matrix:
  theme: ${{ fromJson( needs.determine-themes.outputs.themes ) }}

The only thing to keep in mind is that only 5 themes have build scripts. If someone chooses an older theme like Twenty Seventeen, test-build-scripts is skipped, so bundle-theme just needs to check that test-build-scripts was either successful or skipped:

if: ${{ always() && github.repository == 'WordPress/wordpress-develop' && (needs.check-for-empty-files.result == 'success') && (needs.test-build-scripts.result == 'success' || needs.test-build-scripts.result == 'skipped') }}

I think this approach will work and will be a very good candidate, but I have no idea on how to test it.

This ticket was mentioned in ​PR #15196 on ​WordPress/wordpress-develop by ​@abcd95.


29 hours ago
#2

  • Keywords has-patch added

​@lancewillett commented on ​PR #15196:


14 hours ago
#3

@lucatume @adimoldovan could you take a look at this approach before we land it? It adds a single-theme selector for manual runs, keeps all-theme checks for automatic runs, and allows packaging when a selected theme has no build step. Local checks and CI pass; I’m holding this for another review of the workflow and release-packaging behavior.

Note: See TracTickets for help on using tickets.