From a6514c7cab8f1478292593385fad2faae49fb543 Mon Sep 17 00:00:00 2001 From: PedroTroller Date: Mon, 26 Feb 2024 15:26:16 +0100 Subject: [PATCH] ci: deduplicate workflows runs --- .github/workflows/{bc.yml => bc-break.yaml} | 5 +- .github/workflows/ci.yml | 76 ----------------- .github/workflows/{static.yml => linter.yaml} | 19 ++++- .github/workflows/pull-request.yaml | 23 +++++ .github/workflows/push.yaml | 26 ++++++ .github/workflows/test.yaml | 84 +++++++++++++++++++ 6 files changed, 152 insertions(+), 81 deletions(-) rename .github/workflows/{bc.yml => bc-break.yaml} (93%) delete mode 100644 .github/workflows/ci.yml rename .github/workflows/{static.yml => linter.yaml} (80%) create mode 100644 .github/workflows/pull-request.yaml create mode 100644 .github/workflows/push.yaml create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/bc.yml b/.github/workflows/bc-break.yaml similarity index 93% rename from .github/workflows/bc.yml rename to .github/workflows/bc-break.yaml index 26296d5b..d07fc8b7 100644 --- a/.github/workflows/bc.yml +++ b/.github/workflows/bc-break.yaml @@ -1,5 +1,8 @@ -on: [push, pull_request] +--- name: Roave + +on: workflow_call + jobs: roave_bc_check: name: BC Check diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 525ddc52..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,76 +0,0 @@ -name: Tests -on: [push, pull_request] - -jobs: - - build: - name: Build - runs-on: ubuntu-latest - strategy: - max-parallel: 10 - matrix: - php: ['8.0', '8.1', '8.2'] - - steps: - - name: Set up PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - coverage: none - tools: flex - - - name: Checkout code - uses: actions/checkout@v2 - - - name: Download dependencies - run: | - composer update --no-interaction --prefer-dist --optimize-autoloader --prefer-stable - - - name: Remove PHPSpec adapter tests - run: make remove-phpspec - - - name: PHPSpec - run: php vendor/bin/phpspec run -fpretty --verbose - - - name: PHPUnit - run: php vendor/bin/phpunit - - adapter: - name: Adapter - runs-on: ubuntu-latest - strategy: - max-parallel: 10 - matrix: - run: - - { php: '8.2', packages: 'async-aws/simple-s3:^1.0', phpspec: 'spec/Gaufrette/Adapter/AsyncAwsS3Spec.php' } - - { php: '8.2', packages: 'aws/aws-sdk-php:^3.158', phpspec: 'spec/Gaufrette/Adapter/AwsS3Spec.php' } - - { php: '8.2', packages: 'google/apiclient:^2.12', phpspec: 'spec/Gaufrette/Adapter/GoogleCloudStorageSpec.php' } - - { php: '8.2', packages: 'doctrine/dbal:^2.3', phpspec: 'spec/Gaufrette/Adapter/DoctrineDbalSpec.php' } - - { php: '8.2', packages: 'doctrine/dbal:^3.4', phpspec: 'spec/Gaufrette/Adapter/DoctrineDbalSpec.php' } - - { php: '8.2', packages: 'league/flysystem:^1.0', phpspec: 'spec/Gaufrette/Adapter/FlysystemSpec.php' } - - { php: '8.2', packages: 'microsoft/azure-storage-blob:^1.0', phpspec: 'spec/Gaufrette/Adapter/AzureBlobStore' } - - { php: '8.2', packages: 'mongodb/mongodb:^1.1', phpspec: 'spec/Gaufrette/Adapter/GridFSSpec.php' } - - { php: '8.2', packages: 'phpseclib/phpseclib:^2.0', phpspec: 'spec/Gaufrette/Adapter/PhpseclibSftpSpec.php' } - - steps: - - name: Set up PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.run.php }} - coverage: none - tools: flex - - - name: Checkout code - uses: actions/checkout@v2 - - - name: Download dependencies - run: | - composer req ${{ matrix.run.packages }} --no-update - composer update --no-interaction --prefer-dist --optimize-autoloader --prefer-stable - - - name: PHPSpec - if: ${{ matrix.run.phpspec }} - run: php vendor/bin/phpspec run -fpretty --verbose ${{ matrix.run.phpspec }} - - - name: PHPUnit - run: php vendor/bin/phpunit diff --git a/.github/workflows/static.yml b/.github/workflows/linter.yaml similarity index 80% rename from .github/workflows/static.yml rename to .github/workflows/linter.yaml index 83c47ba3..95e90e6e 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/linter.yaml @@ -1,16 +1,27 @@ -on: [push, pull_request] -name: Static analysis +--- +name: Linters + +on: + workflow_call: + inputs: + PHP_VERSIONS: + type: string + required: true jobs: + phpstan: name: PHPStan runs-on: ubuntu-latest + strategy: + matrix: + php: ${{ fromJson(inputs.PHP_VERSIONS) }} steps: - name: Set up PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.2' + php-version: ${{ matrix.php }} extensions: mongo, mbstring, fileinfo tools: composer:v2 @@ -37,7 +48,7 @@ jobs: - name: Set up PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.0' + php-version: ${{ fromJson(inputs.PHP_VERSIONS)[0] }} extensions: mongo, mbstring, fileinfo tools: composer:v2 diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml new file mode 100644 index 00000000..9c6a3be1 --- /dev/null +++ b/.github/workflows/pull-request.yaml @@ -0,0 +1,23 @@ +--- +name: Pull-Request + +on: pull_request + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + bc-break: + uses: ./.github/workflows/bc-break.yaml + + test: + uses: ./.github/workflows/test.yaml + with: + PHP_VERSIONS: '["8.0", "8.1", "8.2"]' + LAST_VERSION: '8.2' + + linter: + uses: ./.github/workflows/linter.yaml + with: + PHP_VERSIONS: '["8.0", "8.1", "8.2"]' diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml new file mode 100644 index 00000000..b00d6182 --- /dev/null +++ b/.github/workflows/push.yaml @@ -0,0 +1,26 @@ +--- +name: Push + +on: + push: + branches: + - master + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false + +jobs: + bc-break: + uses: ./.github/workflows/bc-break.yaml + + test: + uses: ./.github/workflows/test.yaml + with: + PHP_VERSIONS: '["8.0", "8.1", "8.2"]' + LAST_VERSION: '8.2' + + linter: + uses: ./.github/workflows/linter.yaml + with: + PHP_VERSIONS: '["8.0", "8.1", "8.2"]' diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 00000000..6940568f --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,84 @@ +--- +name: Tests + +on: + workflow_call: + inputs: + PHP_VERSIONS: + type: string + required: true + LAST_VERSION: + type: string + required: true + +jobs: + + build: + name: Build + runs-on: ubuntu-latest + strategy: + matrix: + php: ${{ fromJson(inputs.PHP_VERSIONS) }} + + steps: + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + tools: flex + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Download dependencies + run: | + composer update --no-interaction --prefer-dist --optimize-autoloader --prefer-stable + + - name: Remove PHPSpec adapter tests + run: make remove-phpspec + + - name: PHPSpec + run: php vendor/bin/phpspec run -fpretty --verbose + + - name: PHPUnit + run: php vendor/bin/phpunit + + adapter: + name: Adapter + runs-on: ubuntu-latest + strategy: + matrix: + include: + - { php: '${{ inputs.LAST_VERSION }}', package: 'async-aws/simple-s3:^1.0', phpspec: 'spec/Gaufrette/Adapter/AsyncAwsS3Spec.php' } + - { php: '${{ inputs.LAST_VERSION }}', package: 'aws/aws-sdk-php:^3.158', phpspec: 'spec/Gaufrette/Adapter/AwsS3Spec.php' } + - { php: '${{ inputs.LAST_VERSION }}', package: 'google/apiclient:^2.12', phpspec: 'spec/Gaufrette/Adapter/GoogleCloudStorageSpec.php' } + - { php: '${{ inputs.LAST_VERSION }}', package: 'doctrine/dbal:^2.3', phpspec: 'spec/Gaufrette/Adapter/DoctrineDbalSpec.php' } + - { php: '${{ inputs.LAST_VERSION }}', package: 'doctrine/dbal:^3.4', phpspec: 'spec/Gaufrette/Adapter/DoctrineDbalSpec.php' } + - { php: '${{ inputs.LAST_VERSION }}', package: 'league/flysystem:^1.0', phpspec: 'spec/Gaufrette/Adapter/FlysystemSpec.php' } + - { php: '${{ inputs.LAST_VERSION }}', package: 'microsoft/azure-storage-blob:^1.0', phpspec: 'spec/Gaufrette/Adapter/AzureBlobStore' } + - { php: '${{ inputs.LAST_VERSION }}', package: 'mongodb/mongodb:^1.1', phpspec: 'spec/Gaufrette/Adapter/GridFSSpec.php' } + - { php: '${{ inputs.LAST_VERSION }}', package: 'phpseclib/phpseclib:^2.0', phpspec: 'spec/Gaufrette/Adapter/PhpseclibSftpSpec.php' } + + steps: + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + tools: flex + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Download dependencies + run: | + composer req ${{ matrix.package }} --no-update + composer update --no-interaction --prefer-dist --optimize-autoloader --prefer-stable + + - name: PHPSpec + if: ${{ matrix.phpspec }} + run: php vendor/bin/phpspec run -fpretty --verbose ${{ matrix.phpspec }} + + - name: PHPUnit + run: php vendor/bin/phpunit