Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Reusable Workflows #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
126 changes: 126 additions & 0 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: 'Coding Standards'

on:
workflow_call:
inputs:
php-version:
description: 'The PHP version to use when running the job'
default: '8.2'
required: false
type: 'string'
composer-root-version:
description: 'The version of the package being tested, in case of circular dependencies.'
required: false
type: 'string'
composer-options:
description: 'Additional flags for the composer install command.'
default: '--prefer-dist'
required: false
type: 'string'

jobs:
coding-standards:
name: 'Coding Standards'
runs-on: 'ubuntu-22.04'

strategy:
matrix:
php-version:
- '${{ inputs.php-version }}'

steps:
- name: 'Checkout'
uses: 'actions/checkout@v3'

- name: 'Install PHP'
uses: 'shivammathur/setup-php@v2'
with:
coverage: 'none'
php-version: '${{ matrix.php-version }}'
tools: 'cs2pr'

- name: 'Set COMPOSER_ROOT_VERSION'
run: |
echo 'COMPOSER_ROOT_VERSION=${{ inputs.composer-root-version }}' >> $GITHUB_ENV
if: '${{ inputs.composer-root-version }}'

- name: 'Install Php_Codesniffer with Composer'
uses: 'ramsey/composer-install@v2'
with:
dependency-versions: 'highest'
composer-options: '${{ inputs.composer-options }} --working-dir=vendor/micro/dev-tools/phpcs'

- name: 'Run PHP_CodeSniffer'
run: 'vendor/bin/phpcs -q --no-colors --report=checkstyle | cs2pr'

mess-detector:
name: 'Mess detector'
runs-on: 'ubuntu-22.04'

strategy:
matrix:
php-version:
- '${{ inputs.php-version }}'

steps:
- name: 'Checkout'
uses: 'actions/checkout@v3'

- name: 'Install PHP'
uses: 'shivammathur/setup-php@v2'
with:
coverage: 'none'
php-version: '${{ matrix.php-version }}'

- name: 'Set COMPOSER_ROOT_VERSION'
run: |
echo 'COMPOSER_ROOT_VERSION=${{ inputs.composer-root-version }}' >> $GITHUB_ENV
if: '${{ inputs.composer-root-version }}'

- name: 'Install MessDetector with Composer'
uses: 'ramsey/composer-install@v2'
with:
dependency-versions: 'highest'
composer-options: '${{ inputs.composer-options }} --working-dir=vendor/micro/dev-tools/phpmd'

- name: 'PHP Mess Detector'
uses: 'php-actions/phpmd@v1'
with:
php_version: '${{ matrix.php-version }}'
path: 'src/'
output: 'github'
vendored_phpmd_path: 'vendor/micro/dev-tools/phpmd/vendor/bin/phpmd'
# ruleset: test/phpmd/ruleset.xml

phpcsfixer:
name: 'PHP Code Style fixer'
runs-on: 'ubuntu-22.04'

strategy:
matrix:
php-version:
- '${{ inputs.php-version }}'

steps:
- name: 'Checkout'
uses: 'actions/checkout@v3'

- name: 'Install PHP'
uses: 'shivammathur/setup-php@v2'
with:
coverage: 'none'
php-version: '${{ matrix.php-version }}'

- name: 'Set COMPOSER_ROOT_VERSION'
run: |
echo 'COMPOSER_ROOT_VERSION=${{ inputs.composer-root-version }}' >> $GITHUB_ENV
if: '${{ inputs.composer-root-version }}'

- name: 'Install PHP Code Style fixer with Composer'
uses: 'ramsey/composer-install@v2'
with:
dependency-versions: 'highest'
composer-options: '${{ inputs.composer-options }} --working-dir=vendor/micro/dev-tools/php-cs-fixer'

- name: 'PHP Code Style fixer'
run: 'vendor/micro/dev-tools/phpmd/vendor/bin/php-cs-fixer fix --verbose --dry-run --using-cache=no'
39 changes: 39 additions & 0 deletions .github/workflows/composer-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: 'Composer Lint'

on:
workflow_call:
inputs:
php-version:
description: 'The PHP version to use when running the job'
default: '8.2'
required: false
type: 'string'

jobs:
composer-lint:
name: 'Composer Lint'
runs-on: 'ubuntu-22.04'

strategy:
matrix:
php-version:
- '${{ inputs.php-version }}'

steps:
- name: 'Checkout'
uses: 'actions/checkout@v3'

- name: 'Install PHP'
uses: 'shivammathur/setup-php@v2'
with:
coverage: 'none'
php-version: '${{ matrix.php-version }}'
tools: composer:v2, composer-normalize:2
env:
COMPOSER_TOKEN: '${{ secrets.GITHUB_TOKEN }}'

- name: 'Composer normalize'
run: 'composer-normalize --dry-run'

- name: 'Composer validate'
run: 'composer validate --strict'
70 changes: 70 additions & 0 deletions .github/workflows/continuous-integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: 'Continuous Integration'

on:
workflow_call:
inputs:
php-versions:
description: 'The PHP versions to use when running the job'
default: '8.2'
required: false
type: 'string'
composer-root-version:
description: 'The version of the package being tested, in case of circular dependencies.'
required: false
type: 'string'
composer-options:
description: 'Additional flags for the composer install command.'
default: '--prefer-dist'
required: false
type: 'string'

env:
fail-fast: true

jobs:
phpunit:
name: 'PHPUnit'
runs-on: 'ubuntu-22.04'

strategy:
matrix:
php-version: '${{ fromJson(inputs.php-versions) }}'
dependencies:
- 'highest'
include:
- php-version: '${{ fromJson(inputs.php-versions)[0] }}'
dependencies: 'lowest'

steps:
- name: 'Checkout'
uses: 'actions/checkout@v3'
with:
fetch-depth: 2

- name: 'Install PHP with PCOV'
uses: 'shivammathur/setup-php@v2'
with:
php-version: '${{ matrix.php-version }}'
coverage: 'pcov'
ini-values: 'zend.assertions=1'

- name: 'Set COMPOSER_ROOT_VERSION'
run: |
echo "COMPOSER_ROOT_VERSION=${{ inputs.composer-root-version }}" >> $GITHUB_ENV
if: '${{ inputs.composer-root-version }}'

- name: 'Install dependencies with Composer'
uses: 'ramsey/composer-install@v2'
with:
dependency-versions: '${{ matrix.dependencies }}'
composer-options: '${{ inputs.composer-options }}'

- name: 'Run PHPUnit'
run: 'vendor/bin/phpunit --coverage-clover=coverage.xml'

- name: 'Upload coverage reports to Codecov'
run: |
# Replace `linux` below with the appropriate OS
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
./codecov -t ${CODECOV_TOKEN}
86 changes: 86 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: 'Static Analysis'

on:
workflow_call:
inputs:
php-version:
description: 'The PHP version to use when running the job'
default: '8.2'
required: false
type: 'string'
composer-root-version:
description: 'The version of the package being tested, in case of circular dependencies.'
required: false
type: 'string'
composer-options:
description: 'Additional flags for the composer install command.'
default: '--prefer-dist'
required: false
type: 'string'

jobs:
phpstan:
name: 'PHPStan'
runs-on: 'ubuntu-22.04'

strategy:
matrix:
php-version:
- '${{ inputs.php-version }}'

steps:
- name: 'Checkout code'
uses: 'actions/checkout@v3'

- name: 'Install PHP'
uses: 'shivammathur/setup-php@v2'
with:
coverage: 'none'
php-version: '${{ matrix.php-version }}'

- name: 'Set COMPOSER_ROOT_VERSION'
run: |
echo 'COMPOSER_ROOT_VERSION=${{ inputs.composer-root-version }}' >> $GITHUB_ENV
if: '${{ inputs.composer-root-version }}'

- name: 'Install PHPStan with Composer'
uses: 'ramsey/composer-install@v2'
with:
dependency-versions: 'highest'
composer-options: '${{ inputs.composer-options }} --working-dir=vendor/micro/dev-tools/phpstan'

- name: 'Run a static analysis with phpstan/phpstan'
run: 'vendor/bin/phpstan analyse'

psalm:
name: 'Psalm'
runs-on: 'ubuntu-22.04'

strategy:
matrix:
php-version:
- '${{ inputs.php-version }}'

steps:
- name: 'Checkout code'
uses: 'actions/checkout@v3'

- name: 'Install PHP'
uses: 'shivammathur/setup-php@v2'
with:
coverage: 'none'
php-version: '${{ matrix.php-version }}'

- name: 'Set COMPOSER_ROOT_VERSION'
run: |
echo 'COMPOSER_ROOT_VERSION=${{ inputs.composer-root-version }}' >> $GITHUB_ENV
if: '${{ inputs.composer-root-version }}'

- name: 'Install Psalm with Composer'
uses: 'ramsey/composer-install@v2'
with:
dependency-versions: 'highest'
composer-options: '${{ inputs.composer-options }} --working-dir=vendor/micro/dev-tools/psalm'

- name: 'Run a static analysis with vimeo/psalm'
run: 'vendor/bin/psalm --show-info=false --stats --output-format=github --threads=$(nproc)'