Skip to content

Commit

Permalink
ci: deduplicate workflows runs (#715)
Browse files Browse the repository at this point in the history
  • Loading branch information
PedroTroller authored Feb 26, 2024
1 parent 4301776 commit 30fd641
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 81 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/bc.yml → .github/workflows/bc-break.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
on: [push, pull_request]
---
name: Roave

on: workflow_call

jobs:
roave_bc_check:
name: BC Check
Expand Down
76 changes: 0 additions & 76 deletions .github/workflows/ci.yml

This file was deleted.

19 changes: 15 additions & 4 deletions .github/workflows/static.yml → .github/workflows/linter.yaml
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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

Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
@@ -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"]'
26 changes: 26 additions & 0 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
@@ -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"]'
84 changes: 84 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ parameters:
count: 3
path: src/Gaufrette/Adapter/Ftp.php

-
message: "#^Property Gaufrette\\\\Adapter\\\\Ftp\\:\\:\\$connection has unknown class FTP\\\\Connection as its type\\.$#"
count: 1
path: src/Gaufrette/Adapter/Ftp.php

-
message: "#^Method Gaufrette\\\\Adapter\\\\Ftp\\:\\:getConnection\\(\\) has invalid return type FTP\\\\Connection\\.$#"
count: 1
path: src/Gaufrette/Adapter/Ftp.php

-
message: "#^Call to function is_resource\\(\\) with string will always evaluate to false\\.$#"
count: 1
Expand Down

0 comments on commit 30fd641

Please sign in to comment.