Skip to content

Commit 5bee508

Browse files
committed
add: deploy test
Signed-off-by: Anupam Kumar <[email protected]>
1 parent b02ef39 commit 5bee508

File tree

1 file changed

+134
-0
lines changed

1 file changed

+134
-0
lines changed

.github/workflows/test-deploy.yml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
2+
# SPDX-License-Identifier: MIT
3+
name: Test Deploy
4+
5+
on:
6+
pull_request:
7+
branches: [main]
8+
push:
9+
branches: [main]
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
15+
concurrency:
16+
group: tests-deploy-${{ github.head_ref || github.run_id }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
nc-host-app-docker:
21+
runs-on: ubuntu-22.04
22+
name: NC In Host
23+
24+
services:
25+
postgres:
26+
image: ghcr.io/nextcloud/continuous-integration-postgres-14:latest
27+
ports:
28+
- 4444:5432/tcp
29+
env:
30+
POSTGRES_USER: root
31+
POSTGRES_PASSWORD: rootpassword
32+
POSTGRES_DB: nextcloud
33+
options: --health-cmd pg_isready --health-interval 5s --health-timeout 2s --health-retries 5
34+
35+
steps:
36+
- name: Set app env
37+
run: echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
38+
39+
- name: Checkout server
40+
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
41+
with:
42+
submodules: true
43+
repository: nextcloud/server
44+
ref: master
45+
46+
- name: Checkout Test Deploy
47+
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
48+
with:
49+
path: apps/${{ env.APP_NAME }}
50+
51+
- name: Set up php
52+
uses: shivammathur/setup-php@4bd44f22a98a19e0950cbad5f31095157cc9621b # v2
53+
with:
54+
php-version: '8.3'
55+
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, pgsql, pdo_pgsql
56+
coverage: none
57+
ini-file: development
58+
ini-values:
59+
apc.enabled=on, apc.enable_cli=on, disable_functions=
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
63+
- name: Set up Nextcloud
64+
env:
65+
DB_PORT: 4444
66+
run: |
67+
mkdir data
68+
./occ maintenance:install --verbose --database=pgsql --database-name=nextcloud --database-host=127.0.0.1 \
69+
--database-port=$DB_PORT --database-user=root --database-pass=rootpassword \
70+
--admin-user admin --admin-pass admin
71+
./occ config:system:set loglevel --value=0 --type=integer
72+
./occ config:system:set debug --value=true --type=boolean
73+
./occ app:enable --force app_api
74+
75+
- name: Test deploy
76+
run: |
77+
PHP_CLI_SERVER_WORKERS=2 php -S 127.0.0.1:8080 &
78+
./occ app_api:daemon:register docker_local_sock Docker docker-install http /var/run/docker.sock http://127.0.0.1:8080/index.php
79+
./occ app_api:app:register ${{ env.APP_NAME }} docker_local_sock \
80+
--info-xml apps/${{ env.APP_NAME }}/appinfo/info.xml
81+
./occ app_api:app:enable ${{ env.APP_NAME }}
82+
./occ app_api:app:disable ${{ env.APP_NAME }}
83+
84+
- name: Check logs
85+
run: |
86+
grep -q 'Started' data/nextcloud.log || error
87+
grep -q 'Connect to Nextcloud was successful' data/nextcloud.log || error
88+
grep -q 'enabled_handler: enabled=True' data/nextcloud.log || error
89+
grep -q 'enabled_handler: enabled=False' data/nextcloud.log || error
90+
grep -q 'Running on CPU' data/nextcloud.log || error
91+
92+
- name: Save container info & logs
93+
if: always()
94+
run: |
95+
docker inspect ${{ env.APP_NAME }} | json_pp > container.json
96+
docker logs ${{ env.APP_NAME }} > container.log 2>&1
97+
98+
- name: Unregister App & Daemon
99+
run: |
100+
./occ app_api:app:unregister ${{ env.APP_NAME }}
101+
./occ app_api:daemon:unregister docker_local_sock
102+
103+
- name: Upload Container info
104+
if: always()
105+
uses: actions/upload-artifact@v4
106+
with:
107+
name: nc_host_app_docker_container.json
108+
path: container.json
109+
if-no-files-found: warn
110+
111+
- name: Upload Container logs
112+
if: always()
113+
uses: actions/upload-artifact@v4
114+
with:
115+
name: nc_host_app_docker_container.log
116+
path: container.log
117+
if-no-files-found: warn
118+
119+
- name: Upload NC logs
120+
if: always()
121+
uses: actions/upload-artifact@v4
122+
with:
123+
name: nc_host_app_docker_nextcloud.log
124+
path: data/nextcloud.log
125+
if-no-files-found: warn
126+
127+
tests-deploy-success:
128+
permissions:
129+
contents: none
130+
runs-on: ubuntu-22.04
131+
needs: [nc-host-app-docker]
132+
name: Tests-Deploy-OK
133+
steps:
134+
- run: echo "Tests-Deploy passed successfully"

0 commit comments

Comments
 (0)