Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/actions/composer-update/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Composer update
description: Restores the Composer download cache, runs `composer update` with retries and saves the cache for the resolved dependencies.

inputs:
php-version:
description: PHP version used as part of the cache key
required: true
options:
description: Additional options appended to the `composer update` call
required: false
default: ''
github-token:
description: Token used to authenticate the downloads from GitHub
required: false
default: ${{ github.token }}

runs:
using: composite
steps:
- name: Get composer cache directory
id: composer-cache
shell: bash
run: echo "COMPOSER_CACHE_FILES_DIR=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"

- name: Restore composer cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.composer-cache.outputs.COMPOSER_CACHE_FILES_DIR }}
# Never matches an entry, so the restore always falls back to restore-keys.
key: composer-php-${{ inputs.php-version }}-restore-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
composer-php-${{ inputs.php-version }}-
composer-
- name: Install dependencies
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.github-token }}
COMPOSER_OPTIONS: ${{ inputs.options }}
run: |
if [ -n "$GITHUB_TOKEN" ]; then
composer config --global github-oauth.github.com "$GITHUB_TOKEN"
fi
attempt=1
until composer update --ansi --no-interaction $COMPOSER_OPTIONS; do
if [ "$attempt" -ge 3 ]; then
echo "::error::composer update failed after $attempt attempts."
exit 1
fi
delay=$((attempt * 30))
echo "::warning::composer update failed on attempt $attempt. Retrying in ${delay}s."
sleep "$delay"
attempt=$((attempt + 1))
done
- name: Save composer cache
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.composer-cache.outputs.COMPOSER_CACHE_FILES_DIR }}
key: composer-php-${{ inputs.php-version }}-${{ hashFiles('composer.lock') }}
18 changes: 3 additions & 15 deletions .github/workflows/reusable-coveralls.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,6 @@ jobs:
run: ls -R
working-directory: build/cov

- name: Get composer cache directory
id: composer-cache
run: |
echo "COMPOSER_CACHE_FILES_DIR=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.composer-cache.outputs.COMPOSER_CACHE_FILES_DIR }}
key: composer-php-${{ inputs.php-version }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
composer-php-${{ inputs.php-version }}-
composer-
- name: Cache PHPUnit's static analysis cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
Expand All @@ -60,7 +46,9 @@ jobs:
phpunit-code-coverage-
- name: Install dependencies
run: composer update --ansi
uses: ./.github/actions/composer-update
with:
php-version: ${{ inputs.php-version }}

- name: Merge coverage files
run: |
Expand Down
17 changes: 4 additions & 13 deletions .github/workflows/reusable-phpunit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,18 +188,8 @@ jobs:
- name: Setup global environment variables
id: setup-env
run: |
echo "COMPOSER_CACHE_FILES_DIR=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
echo "ARTIFACT_NAME=${{ inputs.job-id || github.job }}-php-${{ inputs.php-version }}-db-${{ inputs.db-platform || 'none' }}${{ inputs.mysql-version || '' }}" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.setup-env.outputs.COMPOSER_CACHE_FILES_DIR }}
key: composer-php-${{ inputs.php-version }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
composer-php-${{ inputs.php-version }}-
composer-
- name: Cache PHPUnit's static analysis cache
if: ${{ inputs.enable-artifact-upload }}
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
Expand All @@ -210,9 +200,10 @@ jobs:
phpunit-code-coverage-
- name: Install dependencies
run: |
composer config --global github-oauth.github.com ${{ secrets.GITHUB_TOKEN }}
composer update --ansi ${{ inputs.extra-composer-options }}
uses: ./.github/actions/composer-update
with:
php-version: ${{ inputs.php-version }}
options: ${{ inputs.extra-composer-options }}

- name: Compute additional PHPUnit options
id: phpunit-options
Expand Down
17 changes: 4 additions & 13 deletions .github/workflows/reusable-serviceless-phpunit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,8 @@ jobs:
- name: Setup global environment variables
id: setup-env
run: |
echo "COMPOSER_CACHE_FILES_DIR=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
echo "ARTIFACT_NAME=${{ inputs.job-id || github.job }}-php-${{ inputs.php-version }}" >> $GITHUB_OUTPUT
- name: Cache Composer dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.setup-env.outputs.COMPOSER_CACHE_FILES_DIR }}
key: composer-php-${{ inputs.php-version }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
composer-php-${{ inputs.php-version }}-
composer-
- name: Cache PHPUnit's static analysis cache
if: ${{ inputs.enable-artifact-upload }}
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
Expand All @@ -107,9 +97,10 @@ jobs:
phpunit-code-coverage-
- name: Install dependencies
run: |
composer config --global github-oauth.github.com ${{ secrets.GITHUB_TOKEN }}
composer update --ansi ${{ inputs.extra-composer-options }}
uses: ./.github/actions/composer-update
with:
php-version: ${{ inputs.php-version }}
options: ${{ inputs.extra-composer-options }}

- name: Compute additional PHPUnit options
id: phpunit-options
Expand Down
18 changes: 4 additions & 14 deletions .github/workflows/test-coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,11 @@ jobs:
extensions: tokenizer
coverage: none

- name: Get composer cache directory
id: composer-cache
run: echo "COMPOSER_CACHE_FILES_DIR=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.composer-cache.outputs.COMPOSER_CACHE_FILES_DIR }}
key: composer-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
composer-php-${{ matrix.php-version }}-
composer-
- name: Install dependencies
run: composer update --ansi --no-interaction ${{ matrix.composer-option }}
uses: ./.github/actions/composer-update
with:
php-version: ${{ matrix.php-version }}
options: ${{ matrix.composer-option }}

- name: Run lint
run: composer cs
17 changes: 3 additions & 14 deletions .github/workflows/test-phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,6 @@ jobs:
- name: Validate composer.json
run: composer validate --strict

- name: Get composer cache directory
id: composer-cache
run: echo "COMPOSER_CACHE_FILES_DIR=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.composer-cache.outputs.COMPOSER_CACHE_FILES_DIR }}
key: composer-php-8.2-${{ hashFiles('**/composer.json') }}
restore-keys: |
composer-php-8.2-
composer-
- name: Create PHPStan result cache directory
run: mkdir -p build/phpstan

Expand All @@ -91,7 +78,9 @@ jobs:
restore-keys: phpstan-

- name: Install dependencies
run: composer update --ansi --no-interaction
uses: ./.github/actions/composer-update
with:
php-version: '8.2'

- name: Run static analysis
run: composer phpstan:check
Expand Down
30 changes: 12 additions & 18 deletions .github/workflows/test-psalm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,33 +57,27 @@ jobs:
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Get composer cache directory
id: composer-cache
run: echo "COMPOSER_CACHE_FILES_DIR=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache composer dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.composer-cache.outputs.COMPOSER_CACHE_FILES_DIR }}
key: composer-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
composer-php-${{ matrix.php-version }}-
composer-
- name: Create Psalm cache directory
run: mkdir -p build/psalm

- name: Cache Psalm results
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
- name: Restore Psalm results
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: build/psalm
key: psalm-${{ hashFiles('**/*.php', 'psalm*.xml', 'composer.json') }}
restore-keys: psalm-

- name: Install dependencies
run: |
composer require sebastian/diff:^5.0 --ansi --working-dir utils
composer update --ansi --no-interaction
uses: ./.github/actions/composer-update
with:
php-version: ${{ matrix.php-version }}

- name: Run Psalm analysis
run: utils/vendor/bin/psalm

- name: Save Psalm results
if: ${{ github.event_name == 'push' }}
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: build/psalm
key: psalm-${{ hashFiles('**/*.php', 'psalm*.xml', 'composer.json') }}
19 changes: 3 additions & 16 deletions .github/workflows/test-random-execution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,23 +181,10 @@ jobs:
ini-values: opcache.enable_cli=0
coverage: none

- name: Get composer cache directory
id: composer-cache
run: echo "COMPOSER_CACHE_FILES_DIR=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache composer dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.composer-cache.outputs.COMPOSER_CACHE_FILES_DIR }}
key: composer-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
composer-php-${{ matrix.php-version }}-
composer-
- name: Install project dependencies
run: |
composer config --global github-oauth.github.com ${{ secrets.GITHUB_TOKEN }}
composer update --ansi
uses: ./.github/actions/composer-update
with:
php-version: ${{ matrix.php-version }}

- name: Run random test execution verification
run: |
Expand Down
18 changes: 4 additions & 14 deletions .github/workflows/test-rector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,6 @@ jobs:
- name: Validate composer.json
run: composer validate --strict

- name: Get composer cache directory
id: composer-cache
run: echo "COMPOSER_CACHE_FILES_DIR=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.composer-cache.outputs.COMPOSER_CACHE_FILES_DIR }}
key: composer-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
composer-php-${{ matrix.php-version }}-
composer-
- name: Rector Cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
Expand All @@ -90,7 +77,10 @@ jobs:
- run: mkdir -p /tmp/rector

- name: Install dependencies
run: composer update --ansi --no-interaction ${{ matrix.composer-option }}
uses: ./.github/actions/composer-update
with:
php-version: ${{ matrix.php-version }}
options: ${{ matrix.composer-option }}

- name: Run static analysis
run: vendor/bin/rector process --dry-run --no-progress-bar
17 changes: 3 additions & 14 deletions .github/workflows/test-structarmed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,6 @@ jobs:
- name: Validate composer.json
run: composer validate --strict

- name: Get composer cache directory
id: composer-cache
run: echo "COMPOSER_CACHE_FILES_DIR=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.composer-cache.outputs.COMPOSER_CACHE_FILES_DIR }}
key: composer-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
composer-php-${{ matrix.php-version }}-
composer-
- name: Structarmed Cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
Expand All @@ -87,7 +74,9 @@ jobs:
- run: mkdir -p /tmp/structarmed

- name: Install dependencies
run: composer update --ansi --no-interaction
uses: ./.github/actions/composer-update
with:
php-version: ${{ matrix.php-version }}

- name: Run static analysis
run: vendor/bin/structarmed analyze
Loading