-
-
Notifications
You must be signed in to change notification settings - Fork 31
149 lines (131 loc) · 4.85 KB
/
Copy pathphpstan.yml
File metadata and controls
149 lines (131 loc) · 4.85 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: PHPStan
on:
workflow_dispatch:
push:
branches:
- develop
- main
pull_request:
types:
- opened
- synchronize
- ready_for_review
paths:
- 'bin/**'
- 'phpstan/**'
- 'src/**'
- '**.php'
- '.github/workflows/phpstan.yml'
- '.env.dist'
- '.nvmrc'
- '.wp-env.json'
- 'composer.json'
- 'composer.lock'
- 'package-lock.json'
- 'package.json'
- 'phpstan.neon.dist'
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
# The concurrency group contains the workflow name and the branch name for pull requests
# or the commit hash for any other events.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
jobs:
# Runs PHP static analysis tests.
#
# Violations are reported inline with annotations.
#
# Performs the following steps:
# - Checks out the repository.
# - Sets up PHP.
# - Gets last Monday's date (for cache invalidation).
# - Configures caching for PHP static analysis scans.
# - Installs Composer dependencies.
# - Makes Composer packages available globally.
# - Sets up Node.js.
# - Installs npm dependencies.
# - Configures caching for Docker images.
# - Sets up WordPress environment.
# - Starts the WordPress Docker testing environment.
# - Starts the Docker testing environment.
# - Runs PHPStan static analysis (with Pull Request annotations).
# - Saves the PHPStan result cache.
phpstan:
name: Run PHP static analysis
runs-on: ubuntu-24.04
permissions:
contents: read
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
persist-credentials: false
- name: Set up PHP
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
with:
php-version: 8.4
coverage: none
tools: cs2pr
# This date is used to ensure that the PHPCS cache is cleared at least once every week.
# http://man7.org/linux/man-pages/man1/date.1.html
- name: "Get last Monday's date"
id: get-date
run: echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> "$GITHUB_OUTPUT"
- name: Cache PHP Static Analysis scan cache
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: tests/_output # This is defined in the base.neon file.
key: 'phpstan-result-cache-${{ runner.os }}-date-${{ steps.get-date.outputs.date }}'
restore-keys: |
phpstan-result-cache-
- name: Install Composer dependencies
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # v4.0.0
- name: Make Composer packages available globally
run: echo "${PWD}/vendor/bin" >> "$GITHUB_PATH"
- name: Setup Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
cache: 'npm'
node-version-file: '.nvmrc'
- name: Install NPM dependencies
run: npm ci
- name: Create cache directories
run: mkdir -p ~/.wp-env/downloads
- name: Cache WordPress downloads
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/.wp-env/downloads
key: ${{ runner.os }}-wp-env-downloads-${{ hashFiles('.wp-env.json') }}
restore-keys: |
${{ runner.os }}-wp-env-downloads-
- name: Cache WordPress Plugins
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: |
tests/_data/plugins
tests/_data/mu-plugins
key: ${{ runner.os }}-wp-plugins-${{ hashFiles('.wp-env.json', 'bin/_lib.sh') }}
restore-keys: |
${{ runner.os }}-wp-plugins-
- name: Setup .env file
run: |
cp .env.dist .env
echo GF_KEY=${{ secrets.GF_KEY }} >> .env
- name: Start the Docker testing environment
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0
with:
timeout_minutes: 10
max_attempts: 3
command: |
npm run wp-env start -- ${{ secrets.ACTIONS_STEP_DEBUG && '--debug' || '' }}
- name: Run PHP static analysis tests
id: phpstan
run: phpstan analyse -vvv --error-format=checkstyle | cs2pr
- name: Save result cache
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
if: ${{ !cancelled() }}
with:
path: tests/_output
key: 'phpstan-result-cache-${{ runner.os }}-date-${{ steps.get-date.outputs.date }}'