Repository navigation
245 lines (207 loc) · 6.46 KB
/
Copy pathci.yaml
File metadata and controls
245 lines (207 loc) · 6.46 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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
name: sysPass CI
on:
push:
tags: ['v*']
pull_request:
branches: [main]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
unit:
name: Unit tests (${{ matrix.php }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['8.4', '8.5']
steps:
- uses: actions/checkout@v7
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: pdo_mysql, gd, ldap, gettext, zip, intl, mbstring
coverage: none
ini-values: zend.assertions=1, memory_limit=-1
- name: Setup locales
uses: ./.github/actions/setup-locales
- name: Install dependencies
uses: ramsey/composer-install@v4
with:
composer-options: --prefer-dist
- name: Run unit tests
run: vendor/bin/phpunit -c tests/phpunit.xml --testsuite unit --no-coverage
integration:
name: Integration tests (${{ matrix.php }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['8.4', '8.5']
services:
db:
image: mariadb:11.8
env:
MARIADB_ROOT_PASSWORD: syspass
MARIADB_DATABASE: syspass
MARIADB_ROOT_HOST: '%'
ports:
- 3306:3306
options: >-
--health-cmd="healthcheck.sh --connect --innodb_initialized"
--health-interval=5s
--health-timeout=5s
--health-retries=20
steps:
- uses: actions/checkout@v7
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: pdo_mysql, gd, ldap, gettext, zip, intl, mbstring
coverage: none
ini-values: zend.assertions=1, memory_limit=-1
- name: Setup locales
uses: ./.github/actions/setup-locales
- name: Install dependencies
uses: ramsey/composer-install@v4
with:
composer-options: --prefer-dist
- name: Load schema
run: mysql -h 127.0.0.1 -P 3306 -u root -psyspass syspass < schemas/dbstructure.sql
- name: Run integration tests
env:
DB_SERVER: 127.0.0.1
DB_NAME: syspass
DB_USER: root
DB_PASS: syspass
DB_PORT: 3306
run: vendor/bin/phpunit -c tests/phpunit.xml --testsuite integration --no-coverage
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
extensions: pdo_mysql, gd, ldap, gettext, zip, intl, mbstring
coverage: none
- uses: actions/setup-node@v7
with:
node-version: 'lts/*'
cache: 'npm'
- name: Install dependencies
uses: ramsey/composer-install@v4
with:
composer-options: --prefer-dist
- name: Install npm dependencies
run: npm ci
- name: Create .env for PHPStan bootstrap
run: echo "DEBUG=false" > .env
- name: PHPStan
run: vendor/bin/phpstan analyse --level 6 --error-format=github src
- name: PHPCS
run: composer phpcs
- name: Verify vendor JS bundle is current
run: npm run build:js && git diff --exit-code public/vendor/js/
e2e:
name: E2E tests (Playwright)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 'lts/*'
cache: 'npm'
- name: Install npm dependencies
run: npm ci
- name: Install Playwright browsers
run: npx playwright install --with-deps chromium
- name: Start the app stack
run: docker compose up --build -d
- name: Wait for the app to respond
run: |
for i in $(seq 1 30); do
if curl -sf -o /dev/null "http://localhost:8090/index.php?r=install/index"; then
echo "App is up after $((i * 3))s."
exit 0
fi
sleep 3
done
echo "App did not become ready within 90s." >&2
docker compose logs
exit 1
- name: Run Playwright e2e suite
run: npm run test:e2e
- name: Dump app logs on failure
if: failure()
run: docker compose logs
- name: Upload Playwright report
if: failure()
uses: actions/upload-artifact@v7
with:
name: playwright-report
path: |
playwright-report/
test-results/
if-no-files-found: ignore
retention-days: 7
build-image:
name: Build image
needs: [unit, integration]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v7
- uses: docker/login-action@v4.8.0
if: github.event_name == 'push'
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@v6
id: meta
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha,prefix=
type=semver,pattern={{version}}
type=raw,value=latest,enable={{is_default_branch}}
- uses: docker/build-push-action@v7
with:
context: .
file: docker/Dockerfile
push: ${{ github.event_name == 'push' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
release:
name: Release
needs: build-image
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v7
- name: Extract changelog section for this version
run: |
version="${GITHUB_REF_NAME#v}"
awk -v start="## [$version]" '
substr($0, 1, length(start)) == start { flag = 1; next }
flag && substr($0, 1, 4) == "## [" { exit }
flag { print }
' CHANGELOG.md > release-notes.md
if [ ! -s release-notes.md ]; then
echo "See CHANGELOG.md for details." > release-notes.md
fi
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "$GITHUB_REF_NAME" \
--repo "$GITHUB_REPOSITORY" \
--title "$GITHUB_REF_NAME" \
--notes-file release-notes.md \
--verify-tag