-
Notifications
You must be signed in to change notification settings - Fork 25
179 lines (151 loc) · 6.17 KB
/
tests-exapp-integration.yml
File metadata and controls
179 lines (151 loc) · 6.17 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
# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: MIT
name: Tests - ExApp Integration
on:
pull_request:
branches: [main]
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: tests-exapp-integration-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
NEXTCLOUD_URL: "http://127.0.0.1:8080"
NEXTCLOUD_USER: "admin"
NEXTCLOUD_PASS: "admin"
APP_ID: "test_appapi"
APP_VERSION: "1.0.0"
APP_PORT: 9009
APP_HOST: "127.0.0.1"
APP_SECRET: "tC6vkwPhcppjMykD1r0n9NlI95uJMBYjs5blpIcA1PAdoPDmc5qoAjaBAkyocZ6E"
jobs:
exapp-integration:
runs-on: ubuntu-22.04
name: ExApp integration (Playwright)
services:
postgres:
image: ghcr.io/nextcloud/continuous-integration-postgres-14:latest # zizmor: ignore[unpinned-images]
ports:
- 4444:5432/tcp
env:
POSTGRES_USER: root
POSTGRES_PASSWORD: rootpassword
POSTGRES_DB: nextcloud
options: --health-cmd pg_isready --health-interval 5s --health-timeout 2s --health-retries 5
steps:
- name: Set app env
run: echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
- name: Checkout server
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
submodules: true
repository: nextcloud/server
ref: master
- name: Checkout AppAPI
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
path: apps/${{ env.APP_NAME }}
- name: Set up php
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2
with:
php-version: '8.3'
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, pgsql, pdo_pgsql
coverage: none
ini-file: development
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.11'
- name: Read package.json node and npm engines version
uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
id: versions
with:
path: apps/${{ env.APP_NAME }}
fallbackNode: '^24'
fallbackNpm: '^11.3'
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ steps.versions.outputs.nodeVersion }}
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}'
- name: Install AppAPI composer deps
working-directory: apps/${{ env.APP_NAME }}
run: composer i
- name: Build AppAPI frontend bundle
working-directory: apps/${{ env.APP_NAME }}
run: |
npm ci
npm run build
- name: Set up Nextcloud
env:
DB_PORT: 4444
run: |
mkdir data
./occ maintenance:install --verbose --database=pgsql --database-name=nextcloud --database-host=127.0.0.1 \
--database-port=$DB_PORT --database-user=root --database-pass=rootpassword \
--admin-user "$NEXTCLOUD_USER" --admin-pass "$NEXTCLOUD_PASS"
./occ config:system:set ratelimit.protection.enabled --value=false --type=boolean
./occ app:enable --force ${{ env.APP_NAME }}
- name: Run Nextcloud
run: PHP_CLI_SERVER_WORKERS=4 php -S 127.0.0.1:8080 &
- name: Install integration test Python deps
run: python3 -m pip install -r apps/${{ env.APP_NAME }}/tests/exapp_integration/requirements.txt
- name: Install Playwright browser
run: python3 -m playwright install --with-deps chromium
- name: Register manual_daemon
run: php occ app_api:daemon:register manual_daemon "Manual Install" manual-install http "$APP_HOST" "$NEXTCLOUD_URL"
- name: Start test ExApp
run: |
cd apps/${{ env.APP_NAME }}/tests/exapp_integration
nohup python3 _test_app.py > /tmp/test_appapi.log 2>&1 &
echo $! > /tmp/test_appapi.pid
for _ in $(seq 1 30); do
curl -fs "http://$APP_HOST:$APP_PORT/heartbeat" >/dev/null && break
sleep 1
done
curl -fs "http://$APP_HOST:$APP_PORT/heartbeat"
- name: Register test ExApp
run: |
php occ app_api:app:register "$APP_ID" manual_daemon --json-info \
"{\"id\":\"$APP_ID\",\"name\":\"AppAPI Integration Test ExApp\",\"version\":\"$APP_VERSION\",\"secret\":\"$APP_SECRET\",\"port\":$APP_PORT,\"host\":\"$APP_HOST\",\"protocol\":\"http\",\"system_app\":0}" \
--wait-finish
php occ app_api:app:list | grep -q "^$APP_ID .* \[enabled\]$"
- name: Run pytest
working-directory: apps/${{ env.APP_NAME }}/tests/exapp_integration
env:
OCC_CMD: "php ${{ github.workspace }}/occ"
run: python3 -m pytest -v
- name: Stop test ExApp
if: always()
run: |
[ -f /tmp/test_appapi.pid ] && kill -15 "$(cat /tmp/test_appapi.pid)" || true
- name: Upload NC logs
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: exapp-integration-nextcloud.log
path: data/nextcloud.log
if-no-files-found: warn
- name: Upload test ExApp log
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: exapp-integration-test_appapi.log
path: /tmp/test_appapi.log
if-no-files-found: warn
tests-exapp-integration-success:
permissions:
contents: none
runs-on: ubuntu-22.04
needs: [exapp-integration]
name: TestsExAppIntegration-OK
steps:
- run: echo "ExApp integration tests passed"