|
| 1 | +## |
| 2 | +# A reusable workflow that tests the Gutenberg plugin build process when run within a wordpress-develop checkout. |
| 3 | +## |
| 4 | +name: Test the Gutenberg plugin Build Process |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_call: |
| 8 | + inputs: |
| 9 | + os: |
| 10 | + description: 'Operating system to run tests on' |
| 11 | + required: false |
| 12 | + type: 'string' |
| 13 | + default: 'ubuntu-24.04' |
| 14 | + directory: |
| 15 | + description: 'Directory to run WordPress from. Valid values are `src` or `build`' |
| 16 | + required: false |
| 17 | + type: 'string' |
| 18 | + default: 'src' |
| 19 | + |
| 20 | +env: |
| 21 | + GUTENBERG_DIRECTORY: ${{ inputs.directory == 'build' && 'build' || 'src' }}/wp-content/plugins/gutenberg |
| 22 | + PUPPETEER_SKIP_DOWNLOAD: ${{ true }} |
| 23 | + NODE_OPTIONS: '--max-old-space-size=8192' |
| 24 | + |
| 25 | +# Disable permissions for all available scopes by default. |
| 26 | +# Any needed permissions should be configured at the job level. |
| 27 | +permissions: {} |
| 28 | + |
| 29 | +jobs: |
| 30 | + # Verifies that installing npm dependencies and building the Gutenberg plugin works as expected. |
| 31 | + # |
| 32 | + # Performs the following steps: |
| 33 | + # - Checks out the repository. |
| 34 | + # - Checks out the Gutenberg plugin into the plugins directory. |
| 35 | + # - Sets up Node.js. |
| 36 | + # - Logs debug information about the GitHub Action runner. |
| 37 | + # - Installs Gutenberg npm dependencies. |
| 38 | + # - Runs the Gutenberg build process. |
| 39 | + # - Installs Core npm dependencies. |
| 40 | + # - Builds WordPress to run from the relevant location (src or build). |
| 41 | + # - Builds Gutenberg. |
| 42 | + # - Ensures version-controlled files are not modified or deleted. |
| 43 | + build-process-tests: |
| 44 | + name: ${{ contains( inputs.os, 'macos-' ) && 'MacOS' || contains( inputs.os, 'windows-' ) && 'Windows' || 'Linux' }} |
| 45 | + permissions: |
| 46 | + contents: read |
| 47 | + runs-on: ${{ inputs.os }} |
| 48 | + timeout-minutes: 30 |
| 49 | + |
| 50 | + steps: |
| 51 | + - name: Checkout repository |
| 52 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 53 | + with: |
| 54 | + show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} |
| 55 | + persist-credentials: false |
| 56 | + |
| 57 | + - name: Checkout Gutenberg plugin |
| 58 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 59 | + with: |
| 60 | + repository: 'WordPress/gutenberg' |
| 61 | + path: ${{ env.GUTENBERG_DIRECTORY }} |
| 62 | + show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} |
| 63 | + persist-credentials: false |
| 64 | + |
| 65 | + - name: Set up Node.js |
| 66 | + uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0 |
| 67 | + with: |
| 68 | + node-version-file: '.nvmrc' |
| 69 | + cache: npm |
| 70 | + cache-dependency-path: | |
| 71 | + package-lock.json |
| 72 | + ${{ env.GUTENBERG_DIRECTORY }}/package-lock.json |
| 73 | +
|
| 74 | + - name: Log debug information |
| 75 | + run: | |
| 76 | + npm --version |
| 77 | + node --version |
| 78 | + curl --version |
| 79 | + git --version |
| 80 | +
|
| 81 | + - name: Install Gutenberg Dependencies |
| 82 | + run: npm ci |
| 83 | + working-directory: ${{ env.GUTENBERG_DIRECTORY }} |
| 84 | + |
| 85 | + - name: Build Gutenberg |
| 86 | + run: npm run build |
| 87 | + working-directory: ${{ env.GUTENBERG_DIRECTORY }} |
| 88 | + |
| 89 | + - name: Install Core Dependencies |
| 90 | + run: npm ci |
| 91 | + |
| 92 | + - name: Build WordPress to run from ${{ inputs.directory }} |
| 93 | + run: npm run ${{ inputs.directory == 'src' && 'build:dev' || 'build' }} |
| 94 | + |
| 95 | + - name: Run Gutenberg build script after building Core to run from ${{ inputs.directory }} |
| 96 | + run: npm run build |
| 97 | + working-directory: ${{ env.GUTENBERG_DIRECTORY }} |
| 98 | + |
| 99 | + - name: Ensure version-controlled files are not modified or deleted during building |
| 100 | + run: git diff --exit-code |
0 commit comments