-
Notifications
You must be signed in to change notification settings - Fork 1
348 lines (289 loc) · 12 KB
/
Copy pathci.yml
File metadata and controls
348 lines (289 loc) · 12 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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
name: CI
on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
workflow_dispatch:
schedule:
- cron: "0 0 * * *" # Every day at midnight
env:
COMPOSER_HOME: ${{ github.workspace }}/.cache/composer
DEFAULT_PHP_VERSION: '8.1'
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
php-checks:
name: php checks
if: github.event_name != 'schedule'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
with:
php-version: ${{ env.DEFAULT_PHP_VERSION }}
tools: composer:72a8f8e653710e18d83e5dd531eb5a71fc3223e6 # v2.9.5
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .cache/composer
key: composer-${{ hashFiles('composer.json') }}
- run: composer install
- name: codeStyle
run: make test-php-style
- name: phpStan
run: make test-php-phpstan
- name: phpPhan
run: make test-php-phan
php-unit-tests:
name: php unit tests (${{ matrix.php-version }}-with-coverage)
if: github.event_name != 'schedule'
runs-on: ubuntu-latest
needs: php-checks
strategy:
fail-fast: false
matrix:
php-version : ['8.1', '8.2', '8.3']
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
with:
php-version: ${{ matrix.php-version }}
tools: composer:72a8f8e653710e18d83e5dd531eb5a71fc3223e6 # v2.9.5
coverage: xdebug
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .cache/composer
key: composer-${{ hashFiles('composer.json') }}
- run: composer install
- name: unitTests-${{ matrix.php-version }}
run: make test-php-unit
- name: coverage rename
run: mv tests/output/clover.xml tests/output/clover-php-unit-${{ matrix.php-version }}.xml
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: coverage-unitTests-${{ matrix.php-version }}
path: tests/output/clover-php-unit-${{ matrix.php-version }}.xml
retention-days: 1
build-ocis:
name: buildOcis
runs-on: ubuntu-latest
needs: php-checks
if: always() && (success() || github.event_name == 'schedule')
strategy:
fail-fast: false
matrix:
branch: ['master', 'stable']
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: get ocis commit ID
run: |
source .ci.env
if [ "${{ github.event_name }}" = "schedule" ]; then
echo "Nightly run, fetching latest commit based on branch"
if [ "${{ matrix.branch }}" = "master" ]; then
REF=master
else
REF=stable-8.0
fi
LATEST_OCIS_COMMIT=$(curl -s "https://api.github.com/repos/owncloud/ocis/commits?sha=$REF" | jq -r '.[0].sha')
if [ -z "$LATEST_OCIS_COMMIT" ]; then
echo "Failed to fetch latest commit for $REF"
exit 1
fi
echo "OCIS_COMMIT=$LATEST_OCIS_COMMIT" >> "$GITHUB_ENV"
echo "OCIS_REF=$REF" >> "$GITHUB_ENV"
elif [ "${{ matrix.branch }}" = "master" ]; then
echo "OCIS_COMMIT=$OCIS_COMMITID" >> "$GITHUB_ENV"
echo "OCIS_REF=$OCIS_BRANCH" >> "$GITHUB_ENV"
else
echo "OCIS_COMMIT=$OCIS_STABLE_COMMITID" >> "$GITHUB_ENV"
echo "OCIS_REF=$OCIS_STABLE_BRANCH" >> "$GITHUB_ENV"
fi
- name: cache ocis
id: ocis-cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
${{ github.workspace }}/ocis
${{ github.workspace }}/ociswrapper
key: ocis-bin-${{ matrix.branch }}-${{ env.OCIS_COMMIT }}
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
if: steps.ocis-cache.outputs.cache-hit != 'true'
with:
go-version: '1.25'
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
if: steps.ocis-cache.outputs.cache-hit != 'true'
with:
node-version: '20'
- name: install pnpm
if: steps.ocis-cache.outputs.cache-hit != 'true'
run: npm install -g pnpm@9.15.9
- name: clone ocis ${{ matrix.branch }}
if: steps.ocis-cache.outputs.cache-hit != 'true'
run: |
git clone -b "$OCIS_REF" --single-branch https://github.com/owncloud/ocis.git repo_ocis
cd repo_ocis
git checkout "$OCIS_COMMIT"
- name: generate ocis ${{ matrix.branch }}
if: steps.ocis-cache.outputs.cache-hit != 'true'
working-directory: repo_ocis
run: make ci-node-generate
- name: build ocis ${{ matrix.branch }}
if: steps.ocis-cache.outputs.cache-hit != 'true'
working-directory: repo_ocis/ocis
run: |
make build
cp bin/ocis ${{ github.workspace }}
- name: build ociswrapper
if: steps.ocis-cache.outputs.cache-hit != 'true'
run: |
make -C repo_ocis/tests/ociswrapper build
cp repo_ocis/tests/ociswrapper/bin/ociswrapper ${{ github.workspace }}/
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ocis-bin-${{ matrix.branch }}
path: |
${{ github.workspace }}/ocis
${{ github.workspace }}/ociswrapper
retention-days: 1
php-integration-tests:
name: php integration tests (${{ matrix.php-version}}-${{ matrix.branch }}${{ matrix.branch == 'master' && matrix.php-version == '8.1' && '-with-coverage' || '' }})
runs-on: ubuntu-latest
needs: build-ocis
if: always() && (success() || github.event_name == 'schedule')
strategy:
fail-fast: false
matrix:
php-version: ['8.1', '8.2', '8.3']
branch: ['master', 'stable']
services:
postgres:
image: postgres:alpine3.18
env:
POSTGRES_DB: keycloak
POSTGRES_USER: keycloak
POSTGRES_PASSWORD: keycloak
ports:
- 5432:5432
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ocis-bin-${{ matrix.branch }}
path: ${{ github.workspace }}
- uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
with:
php-version: ${{ matrix.php-version }}
tools: composer:72a8f8e653710e18d83e5dd531eb5a71fc3223e6 # v2.9.5
coverage: xdebug
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .cache/composer
key: composer-${{ hashFiles('composer.json') }}
- run: composer install
- name: keycloak
run: |
docker run -d --name keycloak \
--network host \
-e OCIS_DOMAIN=localhost:9200 \
-e KC_HOSTNAME=localhost:8080 \
-e KC_DB=postgres \
-e KC_DB_URL="jdbc:postgresql://localhost:5432/keycloak" \
-e KC_DB_USERNAME=keycloak \
-e KC_DB_PASSWORD=keycloak \
-e KC_FEATURES=impersonation \
-e KEYCLOAK_ADMIN=admin \
-e KEYCLOAK_ADMIN_PASSWORD=admin \
-v ${{ github.workspace }}/tests/integration/docker/keycloak/ocis-ci-realm.dist.json:/opt/keycloak/data/import/ocis-realm.json \
quay.io/keycloak/keycloak:22.0.4 \
start-dev --proxy edge --spi-connections-http-client-default-disable-trust-manager=true --import-realm --health-enabled=true
- name: wait for keycloak
run: timeout 300 bash -c 'until curl -sf http://localhost:8080; do sleep 5; done' || (echo "Keycloak failed to start" && exit 1)
- name: ocis
env:
OCIS_URL: "https://localhost:9200"
OCIS_LOG_LEVEL: "error"
IDM_ADMIN_PASSWORD: "admin" # override the random admin password from `ocis init`
PROXY_AUTOPROVISION_ACCOUNTS: "true"
PROXY_ROLE_ASSIGNMENT_DRIVER: "oidc"
OCIS_OIDC_ISSUER: "http://localhost:8080/realms/oCIS"
PROXY_OIDC_REWRITE_WELLKNOWN: "true"
WEB_OIDC_CLIENT_ID: "web"
PROXY_USER_OIDC_CLAIM: "preferred_username"
PROXY_USER_CS3_CLAIM: "username"
OCIS_ADMIN_USER_ID: ""
OCIS_EXCLUDE_RUN_SERVICES: "idp"
GRAPH_ASSIGN_DEFAULT_USER_ROLE: "false"
GRAPH_USERNAME_MATCH: "none"
run: |
chmod +x ${{ github.workspace }}/ocis ${{ github.workspace }}/ociswrapper
${{ github.workspace }}/ocis init --insecure true
${{ github.workspace }}/ociswrapper serve --bin ${{ github.workspace }}/ocis --url ${{ env.OCIS_URL }} &
- name: wait for ocis
run: timeout 300 bash -c 'until curl -skf https://localhost:9200; do sleep 5; done' || (echo "oCIS failed to start" && exit 1)
- name: php-integration-tests
env:
OCIS_URL: "https://localhost:9200"
OCISWRAPPER_URL: "http://localhost:5200"
OCIS_VERSION: ${{ matrix.branch }}
run: make test-php-integration-ci
- name: coverage rename
if: matrix.branch == 'master' && matrix.php-version == env.DEFAULT_PHP_VERSION
run: mv tests/output/clover.xml tests/output/clover-php-integration-${{ matrix.php-version }}.xml
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: matrix.branch == 'master' && matrix.php-version == env.DEFAULT_PHP_VERSION
with:
name: coverage-integrationTests-${{ matrix.php-version }}
path: tests/output/clover-php-integration-${{ matrix.php-version }}.xml
retention-days: 1
docs:
name: docs
if: github.event_name != 'schedule'
runs-on: ubuntu-latest
needs: [php-unit-tests, php-integration-tests]
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: docs generate
run: docker run --rm -v ${{ github.workspace }}:/data phpdoc/phpdoc@sha256:2b36e4f74937e40246d54ed12dfa4f988f21ed8d19e46f426ac3dc32eac2ff1d # v3.9.1
- name: publish api docs
uses: peaceiris/actions-gh-pages@84c30a85c19949d7eee79c4ff27748b70285e453 # v4.1.0
if: github.event_name != 'pull_request'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs
publish_branch: docs
force_orphan: true
- name: compile docs hugo
run: |
mkdir docs-hugo
cat docs-hugo-header.md README.md > docs-hugo/_index.md
- name: publish docs hugo
uses: peaceiris/actions-gh-pages@84c30a85c19949d7eee79c4ff27748b70285e453 # v4.1.0
if: github.event_name != 'pull_request'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs-hugo
publish_branch: docs-hugo
force_orphan: true
sonar-analysis:
name: sonar analysis
if: github.event_name != 'schedule'
runs-on: ubuntu-latest
needs: [php-unit-tests, php-integration-tests]
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
fetch-depth: '0'
- name: download tests coverage
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: coverage-*
path: results/
merge-multiple: 'true'
- name: list-coverage-results
run: ls -l results
- name: sonarcloud
uses: SonarSource/sonarqube-scan-action@299e4b793aaa83bf2aba7c9c14bedbb485688ec4 # v7.1.0
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}