WordPress.org

Make WordPress Core

Changeset 49938


Ignore:
Timestamp:
01/05/2021 07:21:50 PM (11 months ago)
Author:
desrosj
Message:

Build/Test Tools: Simplify Composer package caching.

This simplifies the caching of Composer dependencies in the coding standards and PHP compatibility workflows by using a published action. This combines 3 steps into 1 within these workflows.

Because the Composer implementation within the PHPUnit test workflow is a bit specialized (composer install is run within the Docker container), caching has been left as is in that workflow. However, the cache key has been changed to include the version of PHP being tested. This will prevent incorrect versions of dependencies being present when they are required on jobs other than PHP 8.

Props jrf.
See #50401.

Location:
trunk/.github/workflows
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/.github/workflows/coding-standards.yml

    r49782 r49938  
    1717  # Performs the following steps:
    1818  # - Checks out the repository.
    19   # - Configures caching for Composer.
    2019  # - Sets up PHP.
    2120  # - Logs debug information.
    22   # - Installs Composer dependencies (from cache if possible).
     21  # - Installs Composer dependencies (use cache if possible).
     22  # - Make Composer packages available globally.
    2323  # - Logs PHP_CodeSniffer debug information.
    2424  # - Runs PHPCS on the full codebase with warnings suppressed.
     
    3333      - name: Checkout repository
    3434        uses: actions/checkout@v2
    35 
    36       - name: Get Composer cache directory
    37         id: composer-cache
    38         run: echo "::set-output name=dir::$(composer config cache-files-dir)"
    39 
    40       - name: Set up Composer caching
    41         uses: actions/cache@v2
    42         env:
    43           cache-name: cache-composer-dependencies
    44         with:
    45           path: ${{ steps.composer-cache.outputs.dir }}
    46           key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
    47           restore-keys: |
    48             ${{ runner.os }}-composer-
    4935
    5036      - name: Set up PHP
     
    6147
    6248      - name: Install Composer dependencies
    63         run: |
    64           composer install --prefer-dist --no-suggest --no-progress --no-ansi --no-interaction
    65           echo "${PWD}/vendor/bin" >> $GITHUB_PATH
     49        uses: ramsey/composer-install@v1
     50        with:
     51          composer-options: "--no-progress --no-ansi --no-interaction"
     52
     53      - name: Make Composer packages available globally
     54        run: echo "${PWD}/vendor/bin" >> $GITHUB_PATH
    6655
    6756      - name: Log PHPCS debug information
  • trunk/.github/workflows/php-compatibility.yml

    r49781 r49938  
    1818  # Performs the following steps:
    1919  # - Checks out the repository.
    20   # - Configures caching for Composer.
    2120  # - Sets up PHP.
    2221  # - Logs debug information about the runner container.
    23   # - Installs Composer dependencies (from cache if possible).
     22  # - Installs Composer dependencies (use cache if possible).
     23  # - Make Composer packages available globally.
    2424  # - Logs PHP_CodeSniffer debug information.
    2525  # - Runs the PHP compatibility tests.
     
    3333      - name: Checkout repository
    3434        uses: actions/checkout@v2
    35 
    36       - name: Get Composer cache directory
    37         id: composer-cache
    38         run: echo "::set-output name=dir::$(composer config cache-files-dir)"
    39 
    40       - name: Set up Composer caching
    41         uses: actions/cache@v2
    42         env:
    43           cache-name: cache-composer-dependencies
    44         with:
    45           path: ${{ steps.composer-cache.outputs.dir }}
    46           key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
    47           restore-keys: |
    48             ${{ runner.os }}-composer-
    4935
    5036      - name: Set up PHP
     
    6147
    6248      - name: Install Composer dependencies
    63         run: |
    64           composer install --prefer-dist --no-suggest --no-progress --no-ansi --no-interaction
    65           echo "${PWD}/vendor/bin" >> $GITHUB_PATH
     49        uses: ramsey/composer-install@v1
     50        with:
     51          composer-options: "--no-progress --no-ansi --no-interaction"
     52
     53      - name: Make Composer packages available globally
     54        run: echo "${PWD}/vendor/bin" >> $GITHUB_PATH
    6655
    6756      - name: Log PHPCS debug information
  • trunk/.github/workflows/phpunit-tests.yml

    r49835 r49938  
    192192        with:
    193193          path: ${{ steps.composer-cache.outputs.dir }}
    194           key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
     194          key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
    195195          restore-keys: |
    196             ${{ runner.os }}-composer-
     196            ${{ runner.os }}-php-${{ matrix.php }}-composer-
    197197
    198198      - name: Install Composer dependencies
Note: See TracChangeset for help on using the changeset viewer.