-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (56 loc) · 2.11 KB
/
pull-request-checks.yml
File metadata and controls
65 lines (56 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: PR Review Workflow Template
# Convert to reusable workflow by changing the trigger
on:
workflow_call:
# Define inputs that can be passed from the caller workflow
inputs:
php-version:
description: "PHP version to use"
required: false
default: "8.1"
type: string
composer-version:
description: "Composer version to use"
required: false
default: "v2"
type: string
jobs:
# Define a single job called 'verify'
verify:
runs-on: ubuntu-latest
steps:
# Step 1: Check out the code from the pull request
- name: 1. Check out repository
uses: actions/checkout@v5
# Step 2: Set up PHP environment
- name: 2. Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.php-version }}
tools: composer:${{ inputs.composer-version }}
# Step 2: Get composer cache directory
- name: 2. Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
# Step 3: Cache Composer dependencies
# This speeds up future builds by not re-downloading dependencies
- name: 3. Cache Composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Create a unique key based on the composer.lock file
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
# Use a fallback key if the lock file hasn't changed
restore-keys: ${{ runner.os }}-composer-
# Step 4: Install dependencies
- name: 4. Install dependencies
run: composer install --prefer-dist
# Step 5: Run required checks
# Each command is a separate step. If any step fails,
# the entire job will fail and mark the pull request.# Step 4: Install dependencies
- name: 5. Run tests (PHPUnit)
run: composer test
- name: 6. Run static analysis (PHPStan)
run: composer code-analyse
- name: 7. Run code style check (PHP-CS-Fixer)
run: composer code-sniff