-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (51 loc) · 1.96 KB
/
reusable-phpcs.yml
File metadata and controls
63 lines (51 loc) · 1.96 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
name: Run PHPCS
on:
workflow_call:
inputs:
php-version:
description: 'PHP version to use'
required: true
type: string
permissions:
contents: read
jobs:
phpcs:
name: PHPCS Coding Standards
runs-on: [public-repo]
container:
image: ubuntu:24.04
timeout-minutes: 20
steps:
- name: Install system dependencies
run: |
apt-get update
apt-get install -y git curl sudo unzip
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
- name: Configure Git for Safe Directory
run: git config --global --add safe.directory "${GITHUB_WORKSPACE}"
- name: Set up PHP
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2.36.0
with:
php-version: ${{ inputs.php-version }}
coverage: none
tools: cs2pr
# This date is used to ensure that the PHPCS cache is cleared at least once every week.
- name: "Get last Monday's date"
id: get-date
run: echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> "$GITHUB_OUTPUT"
- name: Cache PHPCS scan cache
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: tests/_output/phpcs-cache.json
key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-phpcs-cache-${{ hashFiles('**/composer.json', '.phpcs.xml.dist') }}
- name: Install Composer dependencies
uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # v3.1.1
- name: Run PHPCS
id: phpcs
run: composer lint -- --report-full --report-checkstyle=./tests/_output/phpcs-report.xml
- name: Show PHPCS results in PR
if: ${{ always() && steps.phpcs.outcome == 'failure' }}
run: cs2pr ./tests/_output/phpcs-report.xml