Skip to content

Commit

Permalink
Build/Test Tools: Check for zero-byte files in themes.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
desrosj committed Oct 6, 2023
1 parent 64b699e commit 987ea9b
Showing 1 changed file with 48 additions and 2 deletions.
50 changes: 48 additions & 2 deletions .github/workflows/test-and-zip-default-themes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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' }}
Expand Down

0 comments on commit 987ea9b

Please sign in to comment.