Skip to content

Commit

Permalink
Tests: Share built JavaScript assets across PHP workflows (WordPress#…
Browse files Browse the repository at this point in the history
…60428)

Share the npm run build result across PHP unit test workflows.

The PHP unit tests are one of the slowest parts of the unit tests and are run 19 times for every workflow run. The longest step in the runs is building the same JavaScript assets. By building once and reusing these assets we can save a significant amount of time. Around 1 hour of total CI runner time is saved for every run of the unit-test workflow.

Co-authored-by: sirreal <jonsurrell@git.wordpress.org>
Co-authored-by: desrosj <desrosj@git.wordpress.org>
  • Loading branch information
3 people authored and cbravobernal committed Apr 9, 2024
1 parent 58ed73f commit 73b1371
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,29 @@ jobs:
echo "previous-wordpress-version=${PREVIOUS_WP_VERSION}" >> $GITHUB_OUTPUT
rm versions.json
build-assets:
name: Build JavaScript assets for PHP unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

- name: Setup Node.js and install dependencies
uses: ./.github/setup-node

- name: Run build scripts
run: npm run build

- name: Upload built JavaScript assets
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: build-assets
path: ./build/

test-php:
name: PHP ${{ matrix.php }}${{ matrix.multisite && ' multisite' || '' }}${{ matrix.wordpress != '' && format( ' (WP {0}) ', matrix.wordpress ) || '' }} on ubuntu-latest
needs: compute-previous-wordpress-version
needs: [compute-previous-wordpress-version, build-assets]
runs-on: ubuntu-latest
timeout-minutes: 20
if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }}
Expand Down Expand Up @@ -152,8 +172,11 @@ jobs:
with:
custom-cache-suffix: $(/bin/date -u --date='last Mon' "+%F")

- name: Npm build
run: npm run build
- name: Download built JavaScript assets
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
with:
name: build-assets
path: ./build

- name: Docker debug information
run: |
Expand All @@ -165,7 +188,6 @@ jobs:
node --version
curl --version
git --version
svn --version
locale -a
- name: Start Docker environment
Expand Down

0 comments on commit 73b1371

Please sign in to comment.