<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[54699] trunk/.github/workflows/test-and-zip-default-themes.yml: Build/Test Tools: Introduce a workflow for testing and building default themes.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/54699">54699</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/54699","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>desrosj</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2022-10-26 15:06:21 +0000 (Wed, 26 Oct 2022)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Build/Test Tools: Introduce a workflow for testing and building default themes.

This introduces a GitHub Action workflow that performs the following steps for default themes:

- Test installing npm dependencies and running the build script (for relevant themes).
- Create ZIP files for the .org Theme directory and uploads them as workflow artifacts.

The workflow will only run on limited occasions, one of those being when Twenty Nineteen, Twenty Twenty, or Twenty Twenty-One is edited. These are the themes with build scripts that need to be tested for issues.

It can also be manually run through the GitHub Actions UI for occasions when the ZIP files are needed for a release.

Props peterwilsoncc, desrosj
Fixes <a href="https://core.trac.wordpress.org/ticket/56898">#56898</a>.</pre>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkgithubworkflowstestandzipdefaultthemesyml">trunk/.github/workflows/test-and-zip-default-themes.yml</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkgithubworkflowstestandzipdefaultthemesyml"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/.github/workflows/test-and-zip-default-themes.yml</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/.github/workflows/test-and-zip-default-themes.yml                           (rev 0)
+++ trunk/.github/workflows/test-and-zip-default-themes.yml     2022-10-26 15:06:21 UTC (rev 54699)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,184 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+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.
+      - '.nvm'
+      # 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/**'
+      # 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.
+      - '.nvm'
+      # 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/**'
+      # 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'
+
+# Cancels all previous workflow runs for pull requests that have not completed.
+concurrency:
+  # The concurrency group contains the workflow name and the branch name for pull requests
+  # or the commit hash for any other events.
+  group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
+  cancel-in-progress: true
+
+jobs:
+  # Tests the build script for themes that have one.
+  #
+  # Performs the following steps:
+  # - Checks out the repository.
+  # - Installs Node.js (only when theme has a build process)
+  # - Installs npm dependencies (only when theme has a build process)
+  # - Runs the theme build script (only when theme has a build process)
+  # - Ensures version-controlled files are not modified or deleted.
+  test-build-scripts:
+    name: Test ${{ matrix.theme }} build script
+    runs-on: ubuntu-latest
+    timeout-minutes: 10
+    if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
+    strategy:
+      fail-fast: false
+      matrix:
+        theme: [
+            'twentytwentyone',
+            'twentytwenty',
+            'twentynineteen',
+        ]
+
+    defaults:
+      run:
+        working-directory: src/wp-content/themes/${{ matrix.theme }}
+
+    steps:
+      - name: Checkout repository
+        uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
+        with:
+          ref: ${{ github.event_name == 'workflow_dispatch' && inputs.branch || github.ref }}
+
+      - name: Install Node.js
+        uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3.5.1
+        with:
+          node-version-file: '.nvmrc'
+          cache: npm
+          cache-dependency-path: src/wp-content/themes/${{ matrix.theme }}/package-lock.json
+
+      - name: Install npm dependencies
+        run: npm ci
+
+      - name: Build theme
+        run: npm run build
+
+      - name: Ensure version-controlled files are not modified or deleted
+        run: git diff --exit-code
+
+  # Prepares bundled themes for release.
+  #
+  # Performs the following steps:
+  # - Checks out the repository.
+  # - Creates a ZIP file of the theme for wordpress.org.
+  # - Uploads the ZIP file as a workflow artifact.
+  bundle-theme:
+    name: Create ${{ matrix.theme }} ZIP file
+    runs-on: ubuntu-latest
+    needs: [ test-build-scripts ]
+    timeout-minutes: 10
+    if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
+    strategy:
+      fail-fast: false
+      matrix:
+        theme: [
+            'twentytwentythree',
+            'twentytwentytwo',
+            'twentytwentyone',
+            'twentytwenty',
+            'twentynineteen',
+            'twentyseventeen',
+            'twentysixteen',
+            'twentyfifteen',
+            'twentyfourteen',
+            'twentythirteen',
+            'twentytwelve',
+            'twentyeleven',
+            'twentyten'
+        ]
+
+    steps:
+      - name: Checkout repository
+        uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
+        with:
+          ref: ${{ github.event_name == 'workflow_dispatch' && inputs.branch || github.ref }}
+
+      - name: Create theme ZIP file
+        run: zip -r ${{ matrix.theme }}.zip src/wp-content/themes/${{ matrix.theme }} -x "*/node_modules/*"
+
+      - name: Upload theme ZIP as an artifact
+        uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb # v3.1.1
+        with:
+          name: ${{ matrix.theme }}
+          path: ${{ matrix.theme }}.zip
+
+  slack-notifications:
+    name: Slack Notifications
+    uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk
+    needs: [ bundle-theme, test-build-scripts ]
+    if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
+    with:
+      calling_status: ${{ needs.test-build-scripts.result == 'success' && needs.bundle-theme.result == 'success' && 'success' || ( needs.test-build-scripts.result == 'cancelled' || needs.bundle-theme.result == 'cancelled' ) && 'cancelled' || 'failure' }}
+    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-latest
+    needs: [ test-build-scripts, bundle-theme, slack-notifications ]
+    if: |
+      always() &&
+      github.repository == 'WordPress/wordpress-develop' &&
+      github.event_name != 'pull_request' &&
+      github.run_attempt < 2 &&
+      (
+        needs.test-build-scripts.result == 'cancelled' || needs.test-build-scripts.result == 'failure' ||
+        needs.bundle-theme.result == 'cancelled' || needs.bundle-theme.result == 'failure'
+      )
+
+    steps:
+      - name: Dispatch workflow run
+        uses: actions/github-script@100527700e8b29ca817ac0e0dfbfc5e8ff38edda # v6.3.2
+        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: '${{ github.run_id }}'
+              }
+            });
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/.github/workflows/test-and-zip-default-themes.yml
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span></div>

</body>
</html>