-
Notifications
You must be signed in to change notification settings - Fork 341
153 lines (133 loc) · 4.77 KB
/
lint-and-analyse-php.yml
File metadata and controls
153 lines (133 loc) · 4.77 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
150
151
152
153
name: Linters
# If a pull-request is pushed then cancel all previously running jobs related
# to that pull-request
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
on:
push:
branches:
- develop
pull_request:
types: [opened, synchronize, reopened]
branches:
- develop
permissions:
contents: read
jobs:
lint:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-python@v6.2.0
with:
python-version: "3.13"
- run: pip install --upgrade tox
- name: Run commitizen (https://commitizen-tools.github.io/commitizen/)
run: tox -e cz
- name: Run config-check
run: tox -e config-check
- name: Run doc8
run: tox -e doc8
- name: Ensure no merge-commits in the Pull Request (PR)
if: github.event_name == 'pull_request'
run: |
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
echo "GITHUB_BASE_REF: ${GITHUB_BASE_REF}"
echo "HEAD_SHA: ${HEAD_SHA}"
git fetch origin "${GITHUB_BASE_REF}"
MERGE_COMMITS=$(git rev-list --merges origin/${GITHUB_BASE_REF}..${HEAD_SHA})
if [[ -n "${MERGE_COMMITS}" ]]; then
echo "ERROR: The Pull Request (PR) contains a 'merge commit' which is not allowed: ${MERGE_COMMITS}"
exit 1
fi
markdownlint:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: markdownlint-cli2-action
uses: DavidAnson/markdownlint-cli2-action@v22
with:
config: 'docs/.markdownlint.yml'
globs: |
*.md
lint-php-files:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ["8.2", "8.3", "8.4", "8.5"]
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
- name: Install Composer dependencies
uses: ramsey/composer-install@v3
- name: Validate composer.json and composer.lock
run: composer validate --strict
- name: Lint PHP files
run: ./ci/ci-phplint
- name: Cache php-cs-fixer
if: matrix.php-version == '8.2'
uses: actions/cache@v5
with:
path: var/cache/.php-cs-fixer.cache
key: php-cs-fixer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.lock', '.php-cs-fixer.dist.php') }}
restore-keys: |
php-cs-fixer-${{ runner.os }}-${{ matrix.php-version }}-
- name: Check coding-standard (php-cs-fixer)
if: matrix.php-version == '8.2'
run: composer phpcsfixer:lint
analyse-php:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- php-version: "8.5"
stan-label: "base"
composer-script: "phpstan"
stan-cache-dir: "base"
stan-config-file: "phpstan.neon"
- php-version: "8.5"
stan-label: "next"
composer-script: "phpstan_next"
stan-cache-dir: "next"
stan-config-file: "phpstan_next.neon"
name: analyse-php (${{ matrix.stan-label }})
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
- name: Install Composer dependencies
uses: ramsey/composer-install@v3
with:
custom-cache-suffix: ${{ matrix.stan-label }}
- name: Cache PHPStan result cache
uses: actions/cache@v5
with:
path: var/cache/phpstan/${{ matrix.stan-cache-dir }}
key: phpstan-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.stan-cache-dir }}-${{ hashFiles('composer.lock', matrix.stan-config-file) }}
restore-keys: |
phpstan-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.stan-cache-dir }}-
- name: Analyse files with PHPStan
run: |
if ! composer ${{ matrix.composer-script }} -- --error-format=github --no-progress --memory-limit 2G; then
echo "Primary PHPStan run failed. Running debug fallback..."
composer ${{ matrix.composer-script }} -- --debug -vvv --error-format=table --memory-limit 2G || true
exit 1
fi
# - name: Analyse files with Psalm
# # Allow the previous check to fail but not abort
# if: always()
# run: composer psalm -- --shepherd