diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4ab5975..020cf75 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,7 +12,18 @@ jobs: name: 'Lint' steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 + + - name: Get composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ matrix.prefer }}-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer-${{ matrix.prefer }}- - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -20,12 +31,6 @@ jobs: php-version: '8.1' coverage: pcov - - name: Cache dependencies - uses: actions/cache@v1 - with: - path: ~/.composer/cache/files - key: dependencies-composer-${{ hashFiles('composer.json') }}-v2 - - name: Install dependencies run: composer install --no-suggest --no-interaction --verbose @@ -52,16 +57,27 @@ jobs: tests: runs-on: ubuntu-latest - name: 'PHP: ${{ matrix.php }}; PHPUnit: ${{ matrix.phpunit }}; Version: ${{ matrix.dependency-version }}' + name: 'PHP: ${{ matrix.php }}; PHPUnit: ${{ matrix.phpunit }}; Prefer: ${{ matrix.prefer }}' strategy: matrix: php: ['8.1', '8.2'] phpunit: ['^9.0', '^10.0'] - dependency-version: ['prefer-lowest', 'prefer-stable'] + prefer: ['prefer-lowest', 'prefer-stable'] steps: - name: checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 + + - name: Get composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ matrix.prefer }}-php-${{ matrix.php }}-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer-${{ matrix.prefer }}-php-${{ matrix.php }}- - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -69,12 +85,6 @@ jobs: php-version: ${{ matrix.php }} coverage: none - - name: Cache dependencies - uses: actions/cache@v1 - with: - path: ~/.composer/cache/files - key: dependencies-${{ matrix.dependency-version }}-phpunit-${{ matrix.phpunit }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}-v3 - - name: Require the dependency matrix version run: composer require 'phpunit/phpunit:${{ matrix.phpunit }}' --no-update --no-interaction --verbose --no-scripts @@ -83,7 +93,7 @@ jobs: run: cp --force phpunit.9.xml.dist phpunit.xml.dist - name: Install dependencies - run: composer update --${{ matrix.dependency-version }} --no-suggest --no-interaction --verbose --no-scripts + run: composer update --${{ matrix.prefer }} --no-suggest --no-interaction --verbose --no-scripts - name: Check platform requirements run: composer check-platform-reqs --verbose