From 37fa917d7a8766eecec641375e4e7438225a0244 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Wed, 3 Apr 2024 22:11:50 +0200 Subject: [PATCH] Tests: Share built JavaScript assets across PHP workflows (#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 Co-authored-by: desrosj --- .github/workflows/unit-test.yml | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 4282a037113eb..5853f8fcc7a51 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -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' }} @@ -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: | @@ -165,7 +188,6 @@ jobs: node --version curl --version git --version - svn --version locale -a - name: Start Docker environment