diff --git a/.github/scripts/register-and-publish-app-to-self-hosted-appstore.sh b/.github/scripts/register-and-publish-app-to-self-hosted-appstore.sh new file mode 100644 index 000000000..4edaede5c --- /dev/null +++ b/.github/scripts/register-and-publish-app-to-self-hosted-appstore.sh @@ -0,0 +1,74 @@ +# SPDX-FileCopyrightText: 2026 Jankari Tech Pvt. Ltd. +# SPDX-License-Identifier: AGPL-3.0-only + +set -e + +# helper functions +log_error() { + echo -e "\e[31m$1\e[0m" +} + +log_info() { + echo -e "\e[37m$1\e[0m" +} + +log_success() { + echo -e "\e[32m$1\e[0m" +} + +if [[ -z "$APP_VERSION" ]]; then + log_error "Environment variables APP_VERSION is missing." + exit 1 +fi + +APPSTORE_BASE_URL="${APPSTORE_BASE_URL:-http://localhost:8000}" +# public certificate of the integration app for testing +CERTIFICATE="-----BEGIN CERTIFICATE-----\r\nMIIEEjCCAvoCAhF6MA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD\r\nVQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI\r\nMTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB\r\ndXRob3JpdHkwHhcNMjEwMzE4MTMwMTExWhcNMzEwNjI0MTMwMTExWjAiMSAwHgYD\r\nVQQDDBdpbnRlZ3JhdGlvbl9vcGVucHJvamVjdDCCAiIwDQYJKoZIhvcNAQEBBQAD\r\nggIPADCCAgoCggIBALn0ohZShOzR6UJAuN4IErLD5jenUWr83XnKCouC0qeXH6FI\r\nTNGTyOy\/KbDDRIoL1L20xYRl5UKwTbDye10ItUBhNcv72pJ2rDOSJrL84fqMxf00\r\nWdd\/APXJfNNqtgh1QTq9vvim9YCEu7JdeIhZK9ea89RPn47iSj7YijY78mGBfyfm\r\nqpHRYX\/QZAQcwjO2lE9soWUaZlrqu3mxTI218zmaqqcma4x3QakfsZeXZhQSU7D1\r\n6iYG8wy8IaYueJM5OoRRziBXoIfPpwYpEj4RhV1WME9jGhutyrHYg3jAdfvzsFVG\r\ngSVUP2ey1sq3HGZGbzWMBFLDGqfet0lGBIB0HTna1Zvu3ZnuK2uV3MObCmBBbBSs\r\n\/s8hyQTqWEbY2aqVoTBN5lyogwfL6pgZJFvhmtg21oHxBBqqAeQ+TZmWD62WorsX\r\n4F6Ahh1VKkmr5LkVvr2CfME0M1mj9s9gSc7ekXk1oHabH+wwgJV2ZhyezhXgWKgL\r\nUahjSRzkKqp5mbh27sg1kLCx9QNyXxaz8rnAcazGB00JzQlUmXg76cJ0v\/M3qihz\r\nQR5oju\/iMiUYKtqec9LU6wfvmGOOvtl2OFOD3ff69FPS2Km8He4pFWkSqw4DGivE\r\nIJLlgqLGIkWm+uNyocANtYqib52AYwJ\/nFMF6nzOvM1LoxHyJlFmudZRju2jAgMB\r\nAAEwDQYJKoZIhvcNAQELBQADggEBAD8mQtw0p3oh9fyOuyTmalHxoG9rLiV0Q2mz\r\n1T0jonVYN7YqSxS\/yWIQnZQ98x2nU93Be4G9VaLT0NZvRjnem2zemSVvuwp11GeK\r\ne80gJTaJjh8n1Z+gD6GU4C+LjWeiR75sd6Jcqfp3bqL6FGvSzIk3QQOfWuC03aXa\r\nFRleNH6rkMV30sWnXyocatculf7ThHZQMN1c0KuQFrd\/alQh\/+EyjBleLozkeC6G\r\n9IlE9DGRK0NUSvy7W68I7cVhR2ToE8oApdOJ1Cd6TpTYMRtvI2lQ4F7vF++ym0Lw\r\nMIxSI44hNeixh8Yn9rcy\/LqOUgl0niB5hfAiauRwHcOY5wf1hKE=\r\n-----END CERTIFICATE-----" +APP_ID="integration_openproject" + +registerApps() { + app_name=$1 + + register_app=$(curl -s -o /dev/null -w "%{http_code}" -X POST -uadmin:admin \ + ${APPSTORE_BASE_URL}/api/v1/apps \ + -H "Content-Type: application/json" \ + -d "{ + \"certificate\": \"${CERTIFICATE}\", + \"signature\": \"signature\" + }") + if [[ ${register_app} == 201 ]]; then + log_success "\"${app_name}\" has been registered successfully!" + elif [[ ${register_app} == 204 ]]; then + log_info "\"${app_name}\" has been updated!" + elif [[ ${register_app} == 400 ]]; then + log_error "\"${app_name}\" contains invalid characters, the signature!" + exit 1 + else + log_error "Failed to register \"${app_name}\"" + exit 1 + fi +} + +publishApps() { + app_name=$1 + app_version=$2 + + register_app=$(curl -s -o /dev/null -w "%{http_code}" -X POST -uadmin:admin \ + ${APPSTORE_BASE_URL}/api/v1/apps/releases \ + -H "Content-Type: application/json" \ + -d "{ + \"download\":\"https://github.com/nextcloud/$APP_ID/releases/download/v$APP_VERSION/$APP_ID-$APP_VERSION.tar.gz\", + \"signature\": \"signature\" + }") + if [[ ${register_app} == 200 ]]; then + log_success "\"${app_name} ${app_version}\" has been updated successfully!" + elif [[ ${register_app} == 201 ]]; then + log_success "\"${app_name} ${app_version}\" has been published successfully!" + else + log_error "Failed to publish \"${app_name} ${app_version}\"" + exit 1 + fi +} + +registerApps "$APP_ID" +publishApps "$APP_ID" "$APP_VERSION" \ No newline at end of file diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index 644f63ff7..600b89340 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -2,19 +2,19 @@ # SPDX-License-Identifier: AGPL-3.0-or-later name: CI -on: - push: - branches: - - 'master' - pull_request: - paths-ignore: - - '**.md' - - '**.txt' - - '**.sh' - - 'dev/**' - - 'l10n/**' - - 'img/**' - - 'docker-compose*' +# on: +# push: +# branches: +# - 'master' +# pull_request: +# paths-ignore: +# - '**.md' +# - '**.txt' +# - '**.sh' +# - 'dev/**' +# - 'l10n/**' +# - 'img/**' +# - 'docker-compose*' concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/reuse.yml b/.github/workflows/reuse.yml index 949d2aa88..ee13d46a6 100644 --- a/.github/workflows/reuse.yml +++ b/.github/workflows/reuse.yml @@ -9,7 +9,7 @@ name: REUSE Compliance Check -on: [pull_request] +# on: [pull_request] permissions: contents: read diff --git a/.github/workflows/upgrade-testing.yml b/.github/workflows/upgrade-testing.yml new file mode 100644 index 000000000..0b41fbcbe --- /dev/null +++ b/.github/workflows/upgrade-testing.yml @@ -0,0 +1,206 @@ +# SPDX-FileCopyrightText: 2026 Jankari Tech Pvt. Ltd. +# SPDX-License-Identifier: AGPL-3.0-or-later + +name: Upgrade Testing + +on: [pull_request] + +jobs: + create-matrix: + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 + + - name: Create matrix + id: create-matrix + env: + NEXTCLOUD_VERSIONS: "29 30" + PHP_VERSIONS: "8.2 8.3" + run: | + MATRIX=$(./.github/scripts/generate-matrix.sh) + echo "matrix={\"include\": [$MATRIX]}" >> $GITHUB_OUTPUT + outputs: + matrix: ${{ steps.create-matrix.outputs.matrix }} + + upgrade-test: + name: Upgrade Testing + needs: create-matrix + if: ${{ success() }} + strategy: + matrix: ${{ fromJson(needs.create-matrix.outputs.matrix) }} + runs-on: ubuntu-latest + + env: + DJANGO_SETTINGS_MODULE: nextcloudappstore.settings.development + PREVIOUS_APP_VERSION: 2.9.2 + UPGRADE_APP_VERSION: 2.10.0 + APPSTORE_BASE_URL: http://localhost:8000 + services: + database-mysql: + image: ghcr.io/nextcloud/continuous-integration-mariadb-10.5:latest + env: + MYSQL_ROOT_PASSWORD: 'nextcloud' + MYSQL_PASSWORD: 'nextcloud' + MYSQL_USER: 'nextcloud' + MYSQL_DATABASE: 'nextcloud' + ports: + - 3306:3306 + + steps: + - name: Checkout + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 + with: + path: integration_openproject + fetch-tags: true + ref: v${{ env.UPGRADE_APP_VERSION }} + + - name: Checkout + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 + with: + repository: nextcloud/activity + ref: ${{ matrix.nextcloudVersion }} + path: activity + + - name: Setup NodeJS + uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 + with: + node-version: 20 + + - name: Setup npm + run: npm i -g npm + + - name: Setup PHP + uses: shivammathur/setup-php@a4e22b60bbb9c1021113f2860347b0759f66fe5d + with: + php-version: ${{ format('{0}.{1}', matrix.phpVersionMajor,matrix.phpVersionMinor) }} + extensions: mbstring, intl, mysql, gd + ini-values: post_max_size=256M, max_execution_time=180 + + - name: Build nextcloud project + run: | + export DEBIAN_FRONTEND=noninteractive + echo "###### installing nextcloud" + mkdir ~/html + git clone https://github.com/nextcloud/server.git --recursive --depth 1 -b ${{ matrix.nextcloudVersion }} ~/html/nextcloud + cd ~/html/nextcloud + git submodule update --init + mkdir -p data + php occ maintenance:install \ + --database mysql \ + --database-name nextcloud \ + --database-host 127.0.0.1 \ + --database-user nextcloud \ + --database-pass nextcloud \ + --admin-user admin \ + --admin-pass admin + php occ maintenance:mode --off + sudo php -S localhost:80 -t ~/html/nextcloud & + + - name: Wait for Nextcloud server to be ready + run: | + if ! timeout 5m bash -c ' + until curl -s -f http://localhost/status.php | grep '"'"'"installed":true'"'"'; do + echo "[INFO] Waiting for server to be ready..." + sleep 10 + done + '; then + echo "[ERROR] Server not ready within 5 minutes." + exit 1 + fi + + + - name: Setup System dependencies for appstore + run: | + sudo apt install -y \ + python3-venv \ + python3-wheel \ + libxslt-dev \ + libxml2-dev \ + libz-dev \ + libpq-dev \ + build-essential \ + python3-dev \ + python3-setuptools \ + gettext \ + libssl-dev \ + libffi-dev \ + nodejs \ + yarn + + - name: Checkout appstore + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 + with: + repository: nextcloud/appstore + path: appstore + + - name: Install Appstore + run: | + cd appstore + python3 -m venv venv + source venv/bin/activate + pip install poetry==1.8.2 + make dev-setup + python manage.py runserver & + + - name: Check for Appstore + run: | + cd appstore + status=$(curl -o /dev/null -s -w "%{http_code}" "$APPSTORE_BASE_URL") + if [ "$status" -eq 200 ]; then + echo "OK" + else + echo "FAILED (status: $status)" + fi + + - name: Register and publish integration_openproject apps + env: + APP_VERSION: ${{ env.PREVIOUS_APP_VERSION }} + run: | + wget https://raw.githubusercontent.com/nextcloud/integration_openproject/${{github.head_ref}}/.github/scripts/register-and-publish-app-to-self-hosted-appstore.sh + bash ./register-and-publish-app-to-self-hosted-appstore.sh + + - name: Enable other apps from official app store + run: | + cp -R activity ~/html/nextcloud/apps + cd ~/html/nextcloud + php occ app:enable oidc user_oidc groupfolders activity + + - name: Enable integration_openproject app from self-hosted app store + run: | + # making the signature verification always pass for testing + # by making the $verified variable true in Installer.php + sed -i.bak 's/$verified = .*/$verified = true;/' /home/runner/html/nextcloud/lib/private/Installer.php || { + echo "::error::Failed to patch Installer.php with sed" + exit 1 + } + # latest data didn't get fetched properly, so we need to clear the appstore cache + echo "" > ~/html/nextcloud/data/appdata_*/appstore/apps.json + cd ~/html/nextcloud + php occ config:system:set ratelimit.protection.enabled --value false --type bool + php occ config:system:set appstoreurl --value "$APPSTORE_BASE_URL/api/v1" + php occ config:system:set allow_local_remote_servers --value true + php occ app:install integration_openproject + + - name: Register and publish next release of the app + env: + APP_VERSION: ${{ env.UPGRADE_APP_VERSION }} + run: | + bash ./register-and-publish-app-to-self-hosted-appstore.sh + + - name: upgrade apps + run: | + cd ~/html/nextcloud + # latest data didn't get fetched properly, so we need to clear the appstore cache + echo "" > ~/html/nextcloud/data/appdata_*/appstore/apps.json + php occ app:update --allow-unstable integration_openproject + + - name: API Tests + env: + NEXTCLOUD_BASE_URL: http://localhost + run: | + cd integration_openproject + # build apps + make + # Run API tests + make api-test \ No newline at end of file