-
-
Notifications
You must be signed in to change notification settings - Fork 190
196 lines (167 loc) · 6.14 KB
/
Copy pathbackend.yml
File metadata and controls
196 lines (167 loc) · 6.14 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# To upgrade pinned actions: Use https://github.com/mheap/pin-github-action
name: CI - Backend
env:
OS: &os ubuntu-24.04
TIMEOUT: &timeout 5
COVERAGE_PHP: "8.4"
SHOULD_RUN: &should-run >-
github.event_name == 'workflow_dispatch' ||
github.event_name == 'workflow_call' ||
github.repository == 'getkirby/kirby' ||
github.repository_owner != 'getkirby'
on:
# only the long-lived base branches run on push, so that their caches
# are seeded for the pull requests targeting them; feature/fix branches
# are covered by the pull_request event instead, which can restore caches
# from its base branch and keeps the same commit from running twice
push:
branches:
- "main"
- "develop-patch"
- "develop-minor"
- "v*/develop"
paths: &backend-paths
- "**"
- "!.github/**"
- ".github/actions/setup-php/**"
- ".github/workflows/backend.yml"
- "!.tx/**"
- "!.vscode/**"
- "!assets/**"
- "!panel/**"
- "!scripts/**"
pull_request:
paths: *backend-paths
workflow_call:
workflow_dispatch:
concurrency:
group: backend-${{ github.ref }}
cancel-in-progress: true
jobs:
# ======================== Unit Tests ========================
tests:
name: "Unit Tests - PHP ${{ matrix.php }}"
if: *should-run
runs-on: *os
timeout-minutes: *timeout
strategy:
fail-fast: true
matrix:
php: ["8.3", "8.4", "8.5"]
services:
redis:
image: redis:7
ports:
- 6379:6379
memcached:
image: memcached:latest
ports:
- 11211:11211
steps:
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
with:
fetch-depth: 2
- name: Install system locales and imagemagick
uses: awalsh128/cache-apt-pkgs-action@553a35bb8ebd9fcabcb1c9451aa4c98e1b4ca8a9 # v1.6.3
with:
packages: locales-all imagemagick
version: 1
execute_install_scripts: true
- name: Ensure ImageMagick aliases exist
run: |
if ! command -v convert > /dev/null; then
sudo ln -sf /usr/bin/convert-im6.q16 /usr/bin/convert
sudo ln -sf /usr/bin/identify-im6.q16 /usr/bin/identify
fi
convert -version | head -1
- name: Setup PHP environment
uses: ./.github/actions/setup-php
with:
php: ${{ matrix.php }}
ini: 'apc.enabled=1, apc.enable_cli=1, pcov.directory=., pcov.exclude="~(vendor|tests)~"'
coverage: ${{ matrix.php == env.COVERAGE_PHP && 'pcov' || 'none' }}
- name: Check Composer platform requirements
run: composer check-platform-reqs
- name: Cache PHPUnit results
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ./.phpunit.cache
key: phpunit-${{ matrix.php }}-${{ hashFiles('composer.lock') }}
restore-keys: |
phpunit-${{ matrix.php }}-
phpunit-
- name: Run PHPUnit tests
if: matrix.php != env.COVERAGE_PHP
run: composer run test -- --configuration phpunit.ci.xml --processes 4
- name: Run PHPUnit tests with coverage
if: matrix.php == env.COVERAGE_PHP
run: composer run test -- --configuration phpunit.ci.xml --processes 4 --coverage-clover ${{ github.workspace }}/clover.xml --exclude-source-from-xml-coverage
- name: Upload coverage results to Codecov
if: matrix.php == env.COVERAGE_PHP
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7
with:
# for better reliability if the GitHub API is down
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
files: ${{ github.workspace }}/clover.xml
disable_search: true
flags: backend
env_vars: PHP
env:
PHP: ${{ matrix.php }}
# ======================== Code Quality ========================
analysis:
name: "Code Quality"
if: *should-run
runs-on: *os
timeout-minutes: *timeout
env:
php: 8.3
steps:
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- name: Preparations
run: mkdir -p sarif
- name: Setup PHP environment
uses: ./.github/actions/setup-php
with:
php: ${{ env.php }}
tools: composer-normalize:2.52.0
- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Cache Psalm analysis data
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ~/.cache/psalm
key: psalm-${{ env.php }}-${{ hashFiles('composer.lock') }}
restore-keys: |
psalm-${{ env.php }}-
psalm-
- name: Validate composer.json/composer.lock
run: composer run analyze:composer
- name: Ensure that composer.json is normalized
env:
GITHUB_TOKEN: ""
run: composer-normalize --dry-run
- name: Check for unused Composer dependencies
run: composer run analyze:composer:unused
- name: Statically analyze using Psalm
id: psalm
run: composer run analyze:psalm -- --output-format=github --php-version=${{ env.php }} --report=sarif/psalm.sarif --report-show-info=false --force-jit
- name: Upload code scanning results to GitHub
if: github.repository == 'getkirby/kirby' && steps.psalm.outcome == 'success'
uses: github/codeql-action/upload-sarif@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4
with:
sarif_file: sarif
- name: Cache PHP-CS-Fixer data
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ./.php-cs-fixer.cache
key: php-cs-fixer-${{ hashFiles('.php-cs-fixer.dist.php') }}
restore-keys: |
php-cs-fixer-
- name: Run PHP-CS-Fixer to catch PHP coding style violations
run: composer run fix -- --diff --dry-run