Make WordPress Core


Ignore:
Timestamp:
05/17/2024 05:41:40 PM (18 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/php-compatibility.yml

    r57757 r58165  
    4141
    4242jobs:
    43 
    4443  # Runs PHP compatibility testing.
    45   #
    46   # Violations are reported inline with annotations.
    47   #
    48   # Performs the following steps:
    49   # - Checks out the repository.
    50   # - Sets up PHP.
    51   # - Logs debug information.
    52   # - Configures caching for PHP compatibility scans.
    53   # - Installs Composer dependencies.
    54   # - Make Composer packages available globally.
    55   # - Runs the PHP compatibility tests.
    56   # - Generate a report for displaying issues as pull request annotations.
    57   # - Ensures version-controlled files are not modified or deleted.
    5844  php-compatibility:
    5945    name: Check PHP compatibility
    60     runs-on: ubuntu-latest
     46    uses: WordPress/wordpress-develop/.github/workflows/reusable-php-compatibility.yml@trunk
    6147    permissions:
    6248      contents: read
    63     timeout-minutes: 20
    6449    if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
    65 
    66     steps:
    67       - name: Checkout repository
    68         uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
    69         with:
    70           show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
    71 
    72       - name: Set up PHP
    73         uses: shivammathur/setup-php@a4e22b60bbb9c1021113f2860347b0759f66fe5d # v2.30.0
    74         with:
    75           php-version: '7.4'
    76           coverage: none
    77           tools: cs2pr
    78 
    79       - name: Log debug information
    80         run: |
    81           composer --version
    82 
    83       # This date is used to ensure that the PHP compatibility cache is cleared at least once every week.
    84       # http://man7.org/linux/man-pages/man1/date.1.html
    85       - name: "Get last Monday's date"
    86         id: get-date
    87         run: echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> $GITHUB_OUTPUT
    88 
    89       - name: Cache PHP compatibility scan cache
    90         uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1
    91         with:
    92           path: .cache/phpcompat.json
    93           key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-phpcompat-cache-${{ hashFiles('**/composer.json', 'phpcompat.xml.dist') }}
    94 
    95       # Since Composer dependencies are installed using `composer update` and no lock file is in version control,
    96       # passing a custom cache suffix ensures that the cache is flushed at least once per week.
    97       - name: Install Composer dependencies
    98         uses: ramsey/composer-install@57532f8be5bda426838819c5ee9afb8af389d51a # v3.0.0
    99         with:
    100           custom-cache-suffix: ${{ steps.get-date.outputs.date }}
    101 
    102       - name: Make Composer packages available globally
    103         run: echo "${PWD}/vendor/bin" >> $GITHUB_PATH
    104 
    105       - name: Run PHP compatibility tests
    106         id: phpcs
    107         run: phpcs --standard=phpcompat.xml.dist --report-full --report-checkstyle=./.cache/phpcs-compat-report.xml
    108 
    109       - name: Show PHPCompatibility results in PR
    110         if: ${{ always() && steps.phpcs.outcome == 'failure' }}
    111         run: cs2pr ./.cache/phpcs-compat-report.xml
    112 
    113       - name: Ensure version-controlled files are not modified or deleted
    114         run: git diff --exit-code
    11550
    11651  slack-notifications:
Note: See TracChangeset for help on using the changeset viewer.