From 987ea9bbf80abe3945d2cb117ef64f36f02dc560 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Fri, 6 Oct 2023 12:45:43 +0000 Subject: [PATCH] Build/Test Tools: Check for zero-byte files in themes. Because the contents of binary files are not included in patches by default, occasionally empty versions of these files are committed on accident. This is the most commonly happens within default themes because they usually contain image and font files. This adds a job to the theme related GitHub Action workflow that checks for the presence of zero-byte files so that these instances are caught more easily. Props costdev, hellofromTonya, luminuu, onemaggie. Fixes #59527. git-svn-id: https://develop.svn.wordpress.org/trunk@56792 602fd350-edb4-49c9-b593-d223f7449a82 --- .../workflows/test-and-zip-default-themes.yml | 50 ++++++++++++++++++- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-and-zip-default-themes.yml b/.github/workflows/test-and-zip-default-themes.yml index 4ff226438fd4a..a3a354595ec91 100644 --- a/.github/workflows/test-and-zip-default-themes.yml +++ b/.github/workflows/test-and-zip-default-themes.yml @@ -49,6 +49,52 @@ concurrency: permissions: {} jobs: + # 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-latest + permissions: + contents: read + timeout-minutes: 10 + if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} + strategy: + fail-fast: false + matrix: + theme: [ + 'twentytwentyfour', + 'twentytwentythree', + 'twentytwentytwo', + 'twentytwentyone', + 'twentytwenty', + 'twentynineteen', + 'twentyseventeen', + 'twentysixteen', + 'twentyfifteen', + 'twentyfourteen', + 'twentythirteen', + 'twentytwelve', + 'twentyeleven', + 'twentyten' + ] + + steps: + - name: Checkout repository + uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + with: + ref: ${{ github.event_name == 'workflow_dispatch' && inputs.branch || github.ref }} + show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} + + - name: Check for zero-byte (empty) files + run: | + [[ ! $(find src/wp-content/themes/${{ matrix.theme }} -empty) ]] + # Tests the build script for themes that have one. # # Performs the following steps: @@ -110,7 +156,7 @@ jobs: runs-on: ubuntu-latest permissions: contents: read - needs: [ test-build-scripts ] + needs: [ check-for-empty-files, test-build-scripts ] timeout-minutes: 10 if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} strategy: @@ -153,7 +199,7 @@ jobs: permissions: actions: read contents: read - needs: [ bundle-theme, test-build-scripts ] + needs: [ 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' }}