Skip to content

Commit b714a55

Browse files
committed
ci: automate upgrade testing
Signed-off-by: nabim777 <nabinalemagar019@gmail.com>
1 parent 26c6556 commit b714a55

4 files changed

Lines changed: 245 additions & 14 deletions

File tree

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# SPDX-FileCopyrightText: 2023-2024 Jankari Tech Pvt. Ltd.
2+
# SPDX-FileCopyrightText: 2023 Bundesministerium des Innern und für Heimat, PG ZenDiS "Projektgruppe für Aufbau ZenDiS"
3+
# SPDX-FileCopyrightText: 2023 Nextcloud GmbH
4+
# SPDX-License-Identifier: AGPL-3.0-only
5+
#!/usr/bin/env bash
6+
7+
# This bash script is to register and publish the apps in self-hosted appstore.
8+
# To run this script the self-hosted appstore instances must be up and running
9+
10+
set -e
11+
12+
# helper functions
13+
log_error() {
14+
echo -e "\e[31m$1\e[0m"
15+
}
16+
17+
log_info() {
18+
echo -e "\e[37m$1\e[0m"
19+
}
20+
21+
log_success() {
22+
echo -e "\e[32m$1\e[0m"
23+
}
24+
25+
CERTIFICATE="-----BEGIN CERTIFICATE-----\r\nMIIEEjCCAvoCAhF6MA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD\r\nVQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI\r\nMTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB\r\ndXRob3JpdHkwHhcNMjEwMzE4MTMwMTExWhcNMzEwNjI0MTMwMTExWjAiMSAwHgYD\r\nVQQDDBdpbnRlZ3JhdGlvbl9vcGVucHJvamVjdDCCAiIwDQYJKoZIhvcNAQEBBQAD\r\nggIPADCCAgoCggIBALn0ohZShOzR6UJAuN4IErLD5jenUWr83XnKCouC0qeXH6FI\r\nTNGTyOy\/KbDDRIoL1L20xYRl5UKwTbDye10ItUBhNcv72pJ2rDOSJrL84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rt1BSzpA9QPjSH5m5cRZ0BPn11trsbORNfgoHu4pYaVdNPQuspDJwmsjFgcpwVNV4HA0cwdiCwXi3iawHI3AYszId0rCVBHQX6CkTxEzAfg1NT3y40IV1awlWKh7i1+EuLUAjDfwzelCb73Wx17nNo9kq0a25YyMw8qAiGnCXWzgJTpS1zQpfawVaXRCvSLnaFtS1UsofLpr66+gteLpXPNy+WTfEwDe97HIgiNFEY4jz61P9HhXLEAep14UpYUvWtvrbMAt0ZKfQhwJv6aQrZFxGR+N7Kb4NGeaX2JC+NWbddEMv1qI6Y8X67XjFqLd8pg4aVtZQUX84zE5EKe74risrb3E1iH8R/rX/GOmEYlaab6UY0Fw0sAVGu1BUimyq5AYQW8ZOGfa71QWjzxM5mUHG+7UhBDS6DRHMSP3W5fckDB9EpuqRuBydl6Z0FVomIbbMq1kUWQd36+TeZnRzqY0WMcCLvbrXFcOFDf2nrhurbKPyup7jLRlIQvxUP2QqGizDaIziBUjbAtPW3WikOfpNELZAaNQ++1bpjt1+MPxe3ayJ85pzzuWzWmXKQrB97Tqfwsv7p3AwvQog3Mm95xckmONAece31GXQNAvg191B5roINSz+0oL6ed6w8qdfqlScQnjGWUDa0PwT0="
27+
28+
registerApps() {
29+
app_name=$1
30+
31+
register_app=$(curl -s -o /dev/null -w "%{http_code}" -X POST -uadmin:admin \
32+
http://localhost:8000/api/v1/apps \
33+
-H "Content-Type: application/json" \
34+
-d "{
35+
\"certificate\": \"${CERTIFICATE}\",
36+
\"signature\": \"${SIGNATURE}\"
37+
}")
38+
if [[ ${register_app} == 201 ]]; then
39+
log_success "\"${app_name}\" has been registered successfully!"
40+
elif [[ ${register_app} == 204 ]]; then
41+
log_info "\"${app_name}\" has been updated!"
42+
elif [[ ${register_app} == 400 ]]; then
43+
log_error "\"${app_name}\" contains invalid characters, the signature!"
44+
exit 1
45+
else
46+
log_error "Failed to register \"${app_name}\""
47+
exit 1
48+
fi
49+
}
50+
51+
publishApps() {
52+
app_name=$1
53+
app_version=$2
54+
55+
register_app=$(curl -s -o /dev/null -w "%{http_code}" -X POST -uadmin:admin \
56+
http://localhost:8000/api/v1/apps/releases \
57+
-H "Content-Type: application/json" \
58+
-d "{
59+
\"download\":\"https://github.com/nextcloud/${app_name}/releases/download/v${app_version}/${app_name}-${app_version}.tar.gz\",
60+
\"signature\": \"${SIGNATURE}\"
61+
}")
62+
if [[ ${register_app} == 200 ]]; then
63+
log_success "\"${app_name} ${app_version}\" has been updated successfully!"
64+
elif [[ ${register_app} == 201 ]]; then
65+
log_success "\"${app_name} ${app_version}\" has been published successfully!"
66+
else
67+
log_error "Failed to publish \"${app_name} ${app_version}\""
68+
exit 1
69+
fi
70+
}
71+
72+
registerApps "integration_openproject"
73+
publishApps "integration_openproject" "2.9.2"

.github/workflows/appstore.yml

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
# This workflow is provided via the organization template repository
2+
#
3+
# https://github.com/nextcloud/.github
4+
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5+
6+
# SPDX-FileCopyrightText: 2022 Free Software Foundation Europe e.V. <https://fsfe.org>
7+
#
8+
# SPDX-License-Identifier: CC0-1.0
9+
10+
name: Upgrade Testing
11+
12+
on: [pull_request]
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
env:
18+
DJANGO_SETTINGS_MODULE: nextcloudappstore.settings.development
19+
services:
20+
21+
database-mysql:
22+
image: ghcr.io/nextcloud/continuous-integration-mariadb-10.5:latest
23+
env:
24+
MYSQL_ROOT_PASSWORD: 'nextcloud'
25+
MYSQL_PASSWORD: 'nextcloud'
26+
MYSQL_USER: 'nextcloud'
27+
MYSQL_DATABASE: 'nextcloud'
28+
ports:
29+
- 3306:3306
30+
31+
steps:
32+
- name: Setup NodeJS
33+
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238
34+
with:
35+
node-version: 20
36+
37+
- name: Setup npm
38+
run: npm i -g npm
39+
40+
- name: Setup PHP
41+
uses: shivammathur/setup-php@a4e22b60bbb9c1021113f2860347b0759f66fe5d
42+
with:
43+
php-version: '8.2'
44+
extensions: mbstring, intl, mysql, gd
45+
ini-values: post_max_size=256M, max_execution_time=180
46+
coverage: xdebug
47+
tools: php-cs-fixer, phpunit
48+
49+
- name: Build nextcloud project
50+
# if: ${{ startsWith( steps.tag.outputs.currenttag , 'v' ) }}
51+
# id: build_release
52+
run: |
53+
# echo "app_id=$APP_ID" >> $GITHUB_OUTPUT
54+
# echo "###### copy certificate"
55+
# mkdir -p ~/.nextcloud/certificates
56+
# echo "$APP_CRT" > ~/.nextcloud/certificates/${APP_ID}.crt
57+
# echo "$APP_KEY" > ~/.nextcloud/certificates/${APP_ID}.key
58+
echo "###### install dependencies"
59+
export DEBIAN_FRONTEND=noninteractive
60+
# sudo apt update -y
61+
# sudo apt install make openssl -y
62+
echo "###### installing nextcloud"
63+
mkdir ~/html
64+
git clone https://github.com/nextcloud/server.git --recursive --depth 1 -b stable29 ~/html/nextcloud
65+
cd ~/html/nextcloud
66+
git submodule update --init
67+
mkdir -p data
68+
# chown -R www-data:www-data config data apps
69+
php occ maintenance:install \
70+
--database mysql \
71+
--database-name nextcloud \
72+
--database-host 127.0.0.1 \
73+
--database-user nextcloud \
74+
--database-pass nextcloud \
75+
--admin-user admin \
76+
--admin-pass admin
77+
php occ maintenance:mode --off
78+
sudo php -S localhost:80 -t ~/html/nextcloud &
79+
80+
- name: Wait for Nextcloud server to be ready
81+
run: |
82+
if ! timeout 5m bash -c '
83+
until curl -s -f http://localhost/status.php | grep '"'"'"installed":true'"'"'; do
84+
echo "[INFO] Waiting for server to be ready..."
85+
sleep 10
86+
done
87+
'; then
88+
echo "[ERROR] Server not ready within 5 minutes."
89+
exit 1
90+
fi
91+
92+
93+
- name: Setup System dependencies for appstore
94+
run: |
95+
sudo apt install -y \
96+
python3-venv \
97+
python3-wheel \
98+
libxslt-dev \
99+
libxml2-dev \
100+
libz-dev \
101+
libpq-dev \
102+
build-essential \
103+
python3-dev \
104+
python3-setuptools \
105+
gettext \
106+
libssl-dev \
107+
libffi-dev \
108+
nodejs \
109+
yarn
110+
111+
- name: Checkout appstore
112+
uses: actions/checkout@v3
113+
with:
114+
repository: nextcloud/appstore
115+
path: appstore
116+
117+
- name: Install Appstore
118+
run: |
119+
cd appstore
120+
python3 -m venv venv
121+
source venv/bin/activate
122+
pip install poetry==1.8.2
123+
make dev-setup
124+
python manage.py runserver &
125+
126+
- name: Check for Appstore
127+
run: |
128+
cd appstore
129+
status=$(curl -o /dev/null -s -w "%{http_code}" http://localhost:8000)
130+
if [ "$status" -eq 200 ]; then
131+
echo "OK"
132+
else
133+
echo "FAILED (status: $status)"
134+
fi
135+
136+
- name: Register and publish apps
137+
run: |
138+
wget https://raw.githubusercontent.com/nextcloud/integration_openproject/${{github.head_ref}}/.github/scripts/self-hosted-app-store.sh
139+
bash ./self-hosted-app-store.sh
140+
141+
- name: Configure Nextcloud for testing
142+
run: |
143+
ls -l
144+
cd ~/html/nextcloud
145+
ls -l
146+
php occ config:system:set appstoreurl --value http://localhost:8000/api/v1
147+
php occ config:system:set allow_local_remote_servers --value true
148+
# php occ app:enable integration_openproject
149+
150+
# - name: Setup Debug Session
151+
# uses: csexton/debugger-action@master
152+
153+
- name: Configure Nextcloud for testing
154+
run: |
155+
ls -l
156+
cd ~/html/nextcloud
157+
ls -l
158+
php occ app:enable integration_openproject

.github/workflows/ci-workflow.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
# SPDX-License-Identifier: AGPL-3.0-or-later
33
name: CI
44

5-
on:
6-
push:
7-
branches:
8-
- 'master'
9-
pull_request:
10-
paths-ignore:
11-
- '**.md'
12-
- '**.txt'
13-
- '**.sh'
14-
- 'dev/**'
15-
- 'l10n/**'
16-
- 'img/**'
17-
- 'docker-compose*'
5+
# on:
6+
# push:
7+
# branches:
8+
# - 'master'
9+
# pull_request:
10+
# paths-ignore:
11+
# - '**.md'
12+
# - '**.txt'
13+
# - '**.sh'
14+
# - 'dev/**'
15+
# - 'l10n/**'
16+
# - 'img/**'
17+
# - 'docker-compose*'
1818

1919
concurrency:
2020
group: ${{ github.workflow }}-${{ github.ref }}

.github/workflows/reuse.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
name: REUSE Compliance Check
1111

12-
on: [pull_request]
12+
# on: [pull_request]
1313

1414
permissions:
1515
contents: read

0 commit comments

Comments
 (0)