Make WordPress Core


Ignore:
Timestamp:
05/17/2024 05:41:40 PM (12 months ago)
Author:
desrosj
Message:

Build/Test Tools: Convert GitHub action workflows into reusable ones.

With a few exceptions, GitHub Actions workflows run using the version of the workflow file present in the commit SHA or Git ref for the triggering event. This is useful for maintaining different versions of a workflow file.

In the case of WordPress where there are currently 25+ branches that could potentially receive a security fix, it creates a huge maintenance burden. When 3rd party actions are updated or features are deprecated on GitHub Actions, the required changes need to be backported to all of those branches. This takes considerable time and effort.

This change converts Core’s workflow files to reusable ones. This allows the same workflow to be used for all (or most) branches, allowing the described maintenance updates to be made once in trunk.

To keep track of which files are reusable vs. those that are responsible for holding the strategy matrix for that branch, reusable workflows are now prefixed with reusable-.

Props johnbillion, swissspidy, jorbin, desrosj.
Fixes #61213.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/.github/workflows/end-to-end-tests.yml

    r57918 r58165  
    3737jobs:
    3838  # Runs the end-to-end test suite.
    39   #
    40   # Performs the following steps:
    41   # - Sets environment variables.
    42   # - Checks out the repository.
    43   # - Sets up Node.js.
    44   # - Logs debug information about the GitHub Action runner.
    45   # - Installs npm dependencies.
    46   # - Install Playwright browsers.
    47   # - Builds WordPress to run from the `build` directory.
    48   # - Starts the WordPress Docker container.
    49   # - Logs the running Docker containers.
    50   # - Logs Docker debug information (about both the Docker installation within the runner and the WordPress container).
    51   # - Install WordPress within the Docker container.
    52   # - Install Gutenberg.
    53   # - Run the E2E tests.
    54   # - Ensures version-controlled files are not modified or deleted.
    5539  e2e-tests:
    56     name: E2E Tests with SCRIPT_DEBUG ${{ matrix.LOCAL_SCRIPT_DEBUG && 'enabled' || 'disabled' }}
    57     runs-on: ubuntu-latest
     40    name: Test with SCRIPT_DEBUG ${{ matrix.LOCAL_SCRIPT_DEBUG && 'enabled' || 'disabled' }}
     41    uses: WordPress/wordpress-develop/.github/workflows/reusable-end-to-end-tests.yml@trunk
    5842    permissions:
    5943      contents: read
    60     timeout-minutes: 20
    6144    if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
    6245    strategy:
     
    6447      matrix:
    6548        LOCAL_SCRIPT_DEBUG: [ true, false ]
    66 
    67     steps:
    68       - name: Configure environment variables
    69         run: |
    70           echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV
    71           echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV
    72 
    73       - name: Checkout repository
    74         uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
    75         with:
    76           show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
    77 
    78       - name: Set up Node.js
    79         uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
    80         with:
    81           node-version-file: '.nvmrc'
    82           cache: npm
    83 
    84       - name: Log debug information
    85         run: |
    86           npm --version
    87           node --version
    88           curl --version
    89           git --version
    90           locale -a
    91 
    92       - name: Install npm Dependencies
    93         run: npm ci
    94 
    95       - name: Install Playwright browsers
    96         run: npx playwright install --with-deps
    97 
    98       - name: Build WordPress
    99         run: npm run build
    100 
    101       - name: Start Docker environment
    102         run: |
    103           npm run env:start
    104 
    105       - name: Log running Docker containers
    106         run: docker ps -a
    107 
    108       - name: Docker debug information
    109         run: |
    110           docker -v
    111           docker compose run --rm mysql mysql --version
    112           docker compose run --rm php php --version
    113           docker compose run --rm php php -m
    114           docker compose run --rm php php -i
    115           docker compose run --rm php locale -a
    116 
    117       - name: Install WordPress
    118         env:
    119           LOCAL_SCRIPT_DEBUG: ${{ matrix.LOCAL_SCRIPT_DEBUG }}
    120         run: npm run env:install
    121 
    122       - name: Install Gutenberg
    123         run: npm run env:cli -- plugin install gutenberg --path=/var/www/${{ env.LOCAL_DIR }}
    124 
    125       - name: Run E2E tests
    126         run: npm run test:e2e
    127 
    128       - name: Archive debug artifacts (screenshots, HTML snapshots)
    129         uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
    130         if: always()
    131         with:
    132             name: failures-artifacts${{ matrix.LOCAL_SCRIPT_DEBUG && '-SCRIPT_DEBUG' || '' }}-${{ github.run_id }}
    133             path: artifacts
    134             if-no-files-found: ignore
    135 
    136       - name: Ensure version-controlled files are not modified or deleted
    137         run: git diff --exit-code
     49    with:
     50      LOCAL_SCRIPT_DEBUG: ${{ matrix.LOCAL_SCRIPT_DEBUG }}
    13851
    13952  slack-notifications:
Note: See TracChangeset for help on using the changeset viewer.