Skip to content

[git-hooks] Make packaged hooks canonical (#92) #303

[git-hooks] Make packaged hooks canonical (#92)

[git-hooks] Make packaged hooks canonical (#92) #303

Workflow file for this run

name: Run PHPUnit Tests
on:
workflow_call:
inputs:
min-coverage:
description: Minimum line coverage percentage enforced by dev-tools tests.
required: false
type: number
default: 80
workflow_dispatch:
inputs:
min-coverage:
description: Minimum line coverage percentage enforced by dev-tools tests.
required: false
type: number
default: 80
pull_request:
paths:
- 'src/**'
- 'tests/**'
- 'composer.json'
- 'composer.lock'
- '.github/workflows/tests.yml'
push:
branches: [ "main" ]
permissions:
contents: read
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
tests:
name: Run Tests
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [ '8.3', '8.4', '8.5' ]
steps:
- uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: pcov, pcntl
coverage: pcov
- name: Cache Composer dependencies
uses: actions/cache@v5
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Mark workspace as safe for git
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Install dependencies
env:
COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ github.token }}"} }'
COMPOSER_CACHE_DIR: /tmp/composer-cache
COMPOSER_ROOT_VERSION: dev-main
run: composer install --prefer-dist --no-progress --no-interaction --no-plugins --no-scripts
- name: Composer Audit
env:
COMPOSER_ROOT_VERSION: dev-main
run: composer audit
- name: Resolve minimum coverage
id: minimum-coverage
run: echo "value=${INPUT_MIN_COVERAGE:-80}" >> "$GITHUB_OUTPUT"
env:
INPUT_MIN_COVERAGE: ${{ inputs.min-coverage }}
- name: Run PHPUnit tests
env:
COMPOSER_ROOT_VERSION: dev-main
run: composer dev-tools tests -- --coverage=public/coverage --min-coverage=${{ steps.minimum-coverage.outputs.value }}