diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml deleted file mode 100644 index 5df2a4e64..000000000 --- a/.github/workflows/analysis.yml +++ /dev/null @@ -1,65 +0,0 @@ -# synced from @nextcloud/android-config - -# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors -# SPDX-FileCopyrightText: 2023 Tobias Kaminsky -# SPDX-FileCopyrightText: 2023 Andy Scherzinger -# SPDX-FileCopyrightText: 2023 Josh Richards -# SPDX-License-Identifier: GPL-3.0-or-later - -name: "Analysis" - -on: - pull_request: - branches: [ "master", "main", "stable-*" ] - push: - branches: [ "master", "main", "stable-*" ] - -permissions: - pull-requests: write - contents: write - -concurrency: - group: analysis-wrapper-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - analysis: - runs-on: ubuntu-24.04 - steps: - - name: Setup variables - id: get-vars - run: | - if [ -z "$GITHUB_HEAD_REF" ]; then - # push - { - echo "branch=$GITHUB_REF_NAME" - echo "pr=$GITHUB_RUN_ID" - echo "repo=${{ github.repository }}" - } >> "$GITHUB_OUTPUT" - else - # pull request - { - echo "branch=$GITHUB_HEAD_REF" - echo "pr=${{ github.event.pull_request.number }}" - echo "repo=${{ github.event.pull_request.head.repo.full_name }}" - } >> "$GITHUB_OUTPUT" - fi - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - repository: ${{ steps.get-vars.outputs.repo }} - ref: ${{ steps.get-vars.outputs.branch }} - - name: Set up JDK 17 - uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0 - with: - distribution: "temurin" - java-version: 17 - - name: Install dependencies - run: | - sudo apt install python3-defusedxml - - name: Run analysis wrapper - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - mkdir -p "$HOME/.gradle" - echo "org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > "$HOME/.gradle/gradle.properties" - scripts/analysis/analysis-wrapper.sh ${{ steps.get-vars.outputs.branch }} ${{ secrets.LOG_USERNAME }} ${{ secrets.LOG_PASSWORD }} "$GITHUB_RUN_NUMBER" ${{ steps.get-vars.outputs.pr }} diff --git a/.github/workflows/assemble.yml b/.github/workflows/assemble.yml deleted file mode 100644 index d87b9f423..000000000 --- a/.github/workflows/assemble.yml +++ /dev/null @@ -1,32 +0,0 @@ -# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors -# SPDX-FileCopyrightText: 2023 Andy Scherzinger -# SPDX-FileCopyrightText: 2022 Tobias Kaminsky -# SPDX-FileCopyrightText: 2022 Álvaro Brey -# SPDX-License-Identifier: MIT - -name: Assemble - -on: - pull_request: - branches: [ master, stable-* ] - push: - branches: [ master, stable-* ] - -jobs: - assemble: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - name: Set up JDK 17 - uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0 - with: - distribution: "temurin" - java-version: 17 - - name: Setup JVM options - run: | - mkdir -p "$HOME/.gradle" - echo "org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > "$HOME/.gradle/gradle.properties" - - name: Assemble - uses: gradle/gradle-build-action@v3 - with: - arguments: assemble diff --git a/.github/workflows/autoApproveSync.yml b/.github/workflows/autoApproveSync.yml deleted file mode 100644 index 738cf4131..000000000 --- a/.github/workflows/autoApproveSync.yml +++ /dev/null @@ -1,40 +0,0 @@ -# synced from @nextcloud/android-config - -# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors -# SPDX-FileCopyrightText: 2023 Álvaro Brey -# SPDX-License-Identifier: GPL-3.0-or-later - -name: Auto approve sync -on: - pull_request_target: - branches: - - master - - main - types: - - opened - - reopened - - synchronize - - labeled - -concurrency: - group: sync-approve-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -permissions: - pull-requests: write - -jobs: - auto-approve: - name: Auto approve sync - runs-on: ubuntu-latest - if: ${{ contains(github.event.pull_request.labels.*.name, 'sync') && github.actor == 'nextcloud-android-bot' }} - steps: - - name: Disabled on forks - if: ${{ github.event.pull_request.head.repo.full_name != github.repository }} - run: | - echo 'Can not approve PRs from forks' - exit 1 - - - uses: hmarr/auto-approve-action@f0939ea97e9205ef24d872e76833fa908a770363 # v4.0.0 - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml deleted file mode 100644 index 0fce37d53..000000000 --- a/.github/workflows/check.yml +++ /dev/null @@ -1,38 +0,0 @@ -# SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors -# SPDX-FileCopyrightText: 2017 Tobias Kaminsky -# SPDX-License-Identifier: GPL-3.0-or-later -name: Check - -on: - pull_request: - branches: [ master, stable-* ] - push: - branches: [ master, stable-* ] - -jobs: - check: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - task: [ detekt, spotlessKotlinCheck, lint ] - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - name: Set up JDK 17 - uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0 - with: - distribution: "temurin" - java-version: 17 - - name: Setup JVM options - run: | - mkdir -p "$HOME/.gradle" - echo "org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > "$HOME/.gradle/gradle.properties" - - name: Check ${{ matrix.task }} - uses: gradle/gradle-build-action@v3 - with: - arguments: ${{ matrix.task }} - - uses: actions/upload-artifact@v4 - if: ${{ always() }} - with: - name: ${{ matrix.task }}-report - path: library/build/reports diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index 18325b3d3..000000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,56 +0,0 @@ -# synced from @nextcloud/android-config - -# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors -# SPDX-FileCopyrightText: 2023-2024 Andy Scherzinger -# SPDX-FileCopyrightText: 2022 Tobias Kaminsky -# SPDX-FileCopyrightText: 2022 Álvaro Brey -# SPDX-License-Identifier: GPL-3.0-or-later - -name: "CodeQL" - -on: - push: - branches: [ "master", "main", "stable-*" ] - pull_request: - branches: [ "master", "main" ] - schedule: - - cron: '24 18 * * 3' - -permissions: - contents: read - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-24.04 - permissions: - actions: read - contents: read - security-events: write - strategy: - fail-fast: false - matrix: - language: [ 'java' ] - steps: - - name: Checkout repository - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - name: Set Swap Space - uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c # v1.0 - with: - swap-size-gb: 10 - - name: Initialize CodeQL - uses: github/codeql-action/init@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0 - with: - languages: ${{ matrix.language }} - - name: Set up JDK 17 - uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0 - with: - distribution: "temurin" - java-version: 17 - - name: Assemble - run: | - mkdir -p "$HOME/.gradle" - echo "org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > "$HOME/.gradle/gradle.properties" - ./gradlew assembleDebug - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0 diff --git a/.github/workflows/configNC_master.sh b/.github/workflows/configNC_master.sh new file mode 100644 index 000000000..8f9530d0c --- /dev/null +++ b/.github/workflows/configNC_master.sh @@ -0,0 +1,67 @@ +#!/bin/sh + +# Nextcloud Android Library +# +# SPDX-FileCopyrightText: 2024 Your Name +# SPDX-License-Identifier: MIT +# + + + +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + +source ~/.bashrc; nvm install node + +php /var/www/html/occ log:manage --level warning + +OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1 +OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2 +OC_PASS=user3 php /var/www/html/occ user:add --password-from-env --display-name='User Three' user3 +OC_PASS=test php /var/www/html/occ user:add --password-from-env --display-name='Test@Test' test@test +OC_PASS=test php /var/www/html/occ user:add --password-from-env --display-name='Test Spaces' 'test test' +php /var/www/html/occ user:setting user2 files quota 1G +php /var/www/html/occ group:add users +php /var/www/html/occ group:adduser users user1 +php /var/www/html/occ group:adduser users user2 +php /var/www/html/occ group:adduser users test + +git clone --depth=1 -b master https://github.com/nextcloud/activity.git /var/www/html/apps/activity/ +php /var/www/html/occ app:enable activity + +git clone --depth=1 -b main https://github.com/nextcloud/text.git /var/www/html/apps/text/ +php /var/www/html/occ app:enable text + +git clone --depth=1 -b master https://github.com/nextcloud/end_to_end_encryption/ /var/www/html/apps/end_to_end_encryption/ +php /var/www/html/occ app:enable end_to_end_encryption + +git clone --depth=1 -b master https://github.com/nextcloud/password_policy/ /var/www/html/apps/password_policy/ +php /var/www/html/occ app:enable password_policy + +git clone --depth=1 -b master https://github.com/nextcloud/external/ /var/www/html/apps/external/ +cd /var/www/html/apps/external; composer install --no-dev +php /var/www/html/occ app:enable external +php /var/www/html/occ config:app:set external sites --value="{\"1\":{\"id\":1,\"name\":\"Nextcloud\",\"url\":\"https:\/\/www.nextcloud.com\",\"lang\":\"\",\"type\":\"link\",\"device\":\"\",\"icon\":\"external.svg\",\"groups\":[],\"redirect\":false},\"2\":{\"id\":2,\"name\":\"Forum\",\"url\":\"https:\/\/help.nextcloud.com\",\"lang\":\"\",\"type\":\"link\",\"device\":\"\",\"icon\":\"external.svg\",\"groups\":[],\"redirect\":false}}" + +git clone --depth=1 -b main https://github.com/nextcloud/files_lock.git /var/www/html/apps/files_lock/ +php /var/www/html/occ app:enable -f files_lock + +git clone --depth=1 https://github.com/nextcloud/groupfolders.git /var/www/html/apps/groupfolders/ +php /var/www/html/occ app:enable -f groupfolders +php /var/www/html/occ groupfolders:create groupfolder +php /var/www/html/occ groupfolders:group 1 users + +git clone --depth=1 https://github.com/nextcloud/notifications.git /var/www/html/apps/notifications/ +php /var/www/html/occ app:enable -f notifications +php /var/www/html/occ notification:generate test -d test + +git clone --depth=1 https://github.com/nextcloud/photos.git /var/www/html/apps/photos/ +cd /var/www/html/apps/photos; composer install --no-dev +php /var/www/html/occ app:enable -f photos + +git clone --depth=1 https://github.com/nextcloud/assistant.git /var/www/html/apps/assistant/ +cd /var/www/html/apps/assistant; source ~/.bashrc; make +php /var/www/html/occ app:enable -f assistant + +php /var/www/html/occ app:enable -f testing diff --git a/.github/workflows/configNC_stable16.sh b/.github/workflows/configNC_stable16.sh new file mode 100644 index 000000000..ea8e53aa5 --- /dev/null +++ b/.github/workflows/configNC_stable16.sh @@ -0,0 +1,45 @@ +#!/bin/sh + +# Nextcloud Android Library +# +# SPDX-FileCopyrightText: 2024 Your Name +# SPDX-License-Identifier: MIT +# + +SERVER_VERSION="stable16" + +php /var/www/html/occ log:manage --level warning + +OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1 +OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2 +OC_PASS=user3 php /var/www/html/occ user:add --password-from-env --display-name='User Three' user3 +OC_PASS=test php /var/www/html/occ user:add --password-from-env --display-name='Test@Test' test@test +OC_PASS=test php /var/www/html/occ user:add --password-from-env --display-name='Test Spaces' 'test test' +php /var/www/html/occ user:setting user2 files quota 1G +php /var/www/html/occ group:add users +php /var/www/html/occ group:adduser users user1 +php /var/www/html/occ group:adduser users user2 +php /var/www/html/occ group:adduser users test + +git clone --depth=1 -b $SERVER_VERSION https://github.com/nextcloud/activity.git /var/www/html/apps/activity/ +php /var/www/html/occ app:enable activity + +git clone --depth=1 -b $SERVER_VERSION https://github.com/nextcloud/text.git /var/www/html/apps/text/ +php /var/www/html/occ app:enable text + +php /var/www/html/occ app:enable end_to_end_encryption + +git clone --depth=1 -b $SERVER_VERSION https://github.com/nextcloud/password_policy/ /var/www/html/apps/password_policy/ +php /var/www/html/occ app:enable password_policy + +php /var/www/html/occ app:enable external +php /var/www/html/occ config:app:set external sites --value="{\"1\":{\"id\":1,\"name\":\"Nextcloud\",\"url\":\"https:\/\/www.nextcloud.com\",\"lang\":\"\",\"type\":\"link\",\"device\":\"\",\"icon\":\"external.svg\",\"groups\":[],\"redirect\":false},\"2\":{\"id\":2,\"name\":\"Forum\",\"url\":\"https:\/\/help.nextcloud.com\",\"lang\":\"\",\"type\":\"link\",\"device\":\"\",\"icon\":\"external.svg\",\"groups\":[],\"redirect\":false}}" + +php /var/www/html/occ app:enable groupfolders +php /var/www/html/occ groupfolders:create groupfolder +php /var/www/html/occ groupfolders:group 1 users + +git clone --depth=1 -b $SERVER_VERSION https://github.com/nextcloud/notifications.git /var/www/html/apps/notifications/ +php /var/www/html/occ app:enable notifications + +php /var/www/html/occ app:enable testing diff --git a/.github/workflows/configNC_stable30.sh b/.github/workflows/configNC_stable30.sh new file mode 100644 index 000000000..786768e9e --- /dev/null +++ b/.github/workflows/configNC_stable30.sh @@ -0,0 +1,62 @@ +#!/bin/sh + +# Nextcloud Android Library +# +# SPDX-FileCopyrightText: 2024 Your Name +# SPDX-License-Identifier: MIT +# + +SERVER_VERSION="stable30" + +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash +source ~/.bashrc; nvm install node + +php /var/www/html/occ log:manage --level warning + +OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1 +OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2 +OC_PASS=user3 php /var/www/html/occ user:add --password-from-env --display-name='User Three' user3 +OC_PASS=test php /var/www/html/occ user:add --password-from-env --display-name='Test@Test' test@test +OC_PASS=test php /var/www/html/occ user:add --password-from-env --display-name='Test Spaces' 'test test' +php /var/www/html/occ user:setting user2 files quota 1G +php /var/www/html/occ group:add users +php /var/www/html/occ group:adduser users user1 +php /var/www/html/occ group:adduser users user2 +php /var/www/html/occ group:adduser users test + +git clone -b $SERVER_VERSION https://github.com/nextcloud/activity.git /var/www/html/apps/activity/ +php /var/www/html/occ app:enable activity + +git clone -b $SERVER_VERSION https://github.com/nextcloud/text.git /var/www/html/apps/text/ +php /var/www/html/occ app:enable text + +git clone -b $SERVER_VERSION https://github.com/nextcloud/end_to_end_encryption/ /var/www/html/apps/end_to_end_encryption/ +php /var/www/html/occ app:enable end_to_end_encryption + +git clone -b $SERVER_VERSION https://github.com/nextcloud/password_policy/ /var/www/html/apps/password_policy/ +php /var/www/html/occ app:enable password_policy + +php /var/www/html/occ app:enable external +php /var/www/html/occ config:app:set external sites --value="{\"1\":{\"id\":1,\"name\":\"Nextcloud\",\"url\":\"https:\/\/www.nextcloud.com\",\"lang\":\"\",\"type\":\"link\",\"device\":\"\",\"icon\":\"external.svg\",\"groups\":[],\"redirect\":false},\"2\":{\"id\":2,\"name\":\"Forum\",\"url\":\"https:\/\/help.nextcloud.com\",\"lang\":\"\",\"type\":\"link\",\"device\":\"\",\"icon\":\"external.svg\",\"groups\":[],\"redirect\":false}}" + +git clone -b $SERVER_VERSION https://github.com/nextcloud/files_lock.git /var/www/html/apps/files_lock/ +php /var/www/html/occ app:enable -f files_lock + +git clone -b $SERVER_VERSION https://github.com/nextcloud/groupfolders.git /var/www/html/apps/groupfolders/ +php /var/www/html/occ app:enable -f groupfolders +php /var/www/html/occ groupfolders:create groupfolder +php /var/www/html/occ groupfolders:group 1 users + +git clone -b $SERVER_VERSION https://github.com/nextcloud/notifications.git /var/www/html/apps/notifications/ +php /var/www/html/occ app:enable -f notifications +php /var/www/html/occ notification:generate test -d test + +git clone -b $SERVER_VERSION https://github.com/nextcloud/photos.git /var/www/html/apps/photos/ +cd /var/www/html/apps/photos; composer install --no-dev +php /var/www/html/occ app:enable -f photos + +git clone https://github.com/nextcloud/assistant.git /var/www/html/apps/assistant/ +cd /var/www/html/apps/assistant; git checkout tags/v1.0.8; source ~/.bashrc; npm run build; composer install --no-dev +php /var/www/html/occ app:enable -f assistant + +php /var/www/html/occ app:enable -f testing diff --git a/.github/workflows/configServer.sh b/.github/workflows/configServer.sh new file mode 100644 index 000000000..a44431413 --- /dev/null +++ b/.github/workflows/configServer.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +# Nextcloud Android Library +# +# SPDX-FileCopyrightText: 2024 Your Name +# SPDX-License-Identifier: MIT +# + +wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg +apt-get update && apt-get install -y composer +mkdir /var/www/.nvm /var/www/.npm +touch /var/www/.bashrc +chown -R 33:33 /var/www/.nvm /var/www/.npm /var/www/.bashrc + +rm data -rf +rm config/config.php +BRANCH="$1" /usr/local/bin/initnc.sh diff --git a/.github/workflows/configServer16.sh b/.github/workflows/configServer16.sh new file mode 100644 index 000000000..cb603e595 --- /dev/null +++ b/.github/workflows/configServer16.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +# Nextcloud Android Library +# +# SPDX-FileCopyrightText: 2024 Your Name +# SPDX-License-Identifier: MIT +# + +rm data -rf +rm config/config.php +BRANCH="stable16" /initnc.sh diff --git a/.github/workflows/detectNewJavaFiles.yml b/.github/workflows/detectNewJavaFiles.yml deleted file mode 100644 index 908e3fd28..000000000 --- a/.github/workflows/detectNewJavaFiles.yml +++ /dev/null @@ -1,43 +0,0 @@ -# synced from @nextcloud/android-config - -# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors -# SPDX-FileCopyrightText: 2023 Andy Scherzinger -# SPDX-FileCopyrightText: 2022 Tobias Kaminsky -# SPDX-FileCopyrightText: 2022 Álvaro Brey -# SPDX-License-Identifier: GPL-3.0-or-later - -name: "Detect new java files" - -on: - pull_request: - branches: [ master, main, stable-* ] - -permissions: read-all - -concurrency: - group: detect-new-java-files-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - detectNewJavaFiles: - runs-on: ubuntu-latest - steps: - - id: file_changes - uses: trilom/file-changes-action@a6ca26c14274c33b15e6499323aac178af06ad4b # v1.2.4 - with: - output: ',' - - name: Detect new java files - run: | - if [ -z '${{ steps.file_changes.outputs.files_added }}' ]; then - echo "No new files added" - exit 0 - fi - new_java=$(echo '${{ steps.file_changes.outputs.files_added }}' | tr ',' '\n' | grep '\.java$' | cat) - if [ -n "$new_java" ]; then - # shellcheck disable=SC2016 - printf 'New java files detected:\n```\n%s\n```\n' "$new_java" | tee "$GITHUB_STEP_SUMMARY" - exit 1 - else - echo "No new java files detected" - exit 0 - fi diff --git a/.github/workflows/detectSnaphost.yml b/.github/workflows/detectSnaphost.yml deleted file mode 100644 index d5099f4c0..000000000 --- a/.github/workflows/detectSnaphost.yml +++ /dev/null @@ -1,22 +0,0 @@ -# SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors -# SPDX-FileCopyrightText: 2017 Tobias Kaminsky -# SPDX-License-Identifier: GPL-3.0-or-later -name: "Detect snapshot" - -on: - pull_request: - branches: [ master, stable-* ] - push: - branches: [ master, stable-* ] - -# Declare default permissions as read only. -permissions: read-all - -jobs: - detekt: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - name: Detect SNAPSHOT - run: scripts/analysis/detectSNAPSHOT.sh diff --git a/.github/workflows/garm.yml b/.github/workflows/garm.yml new file mode 100644 index 000000000..aa1636a0d --- /dev/null +++ b/.github/workflows/garm.yml @@ -0,0 +1,198 @@ +# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors +# SPDX-License-Identifier: AGPL-3.0-or-later + +name: "Garm" + +on: + pull_request: + branches: [ master, stable-* ] + +permissions: + contents: read + pull-requests: write + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + test: + runs-on: ubuntu-latest-kvm + services: + server: + image: ghcr.io/nextcloud/continuous-integration-shallow-server:latest + options: --name server + ports: + - 80:80 + strategy: + fail-fast: false + matrix: + server: [ stable30 ] # [ master, stable29 ] + api-level: [ 27 ] # [ 18, 27 ] + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: configure server + run: | + sudo apt-get update && sudo apt-get install unzip cpu-checker qemu-kvm --yes + sudo chmod 666 /dev/kvm + docker cp .github/workflows/configServer.sh server:/tmp/ + docker exec server chmod +x /tmp/configServer.sh + docker exec server /tmp/configServer.sh ${{ matrix.server }} + docker cp .github/workflows/configNC_${{ matrix.server }}.sh server:/tmp/ + docker exec server chmod +x /tmp/configNC_${{ matrix.server }}.sh + docker exec --user www-data server /tmp/configNC_${{ matrix.server }}.sh + docker exec server /usr/local/bin/run.sh + + - name: set up JDK 17 + uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0 + with: + distribution: "temurin" + java-version: 17 + + - name: create AVD and generate snapshot for caching + uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d # v2.33.0 + with: + api-level: ${{ matrix.api-level }} + force-avd-creation: false + arch: x86 + sdcard-path-or-size: 100M + target: google_apis + emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -skin 500x833 + script: echo "Generated AVD snapshot for caching." + + - name: Configure gradle daemon + run: | + mkdir -p $HOME/.gradle + echo "org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > $HOME/.gradle/gradle.properties + echo "org.gradle.caching=true" >> $HOME/.gradle/gradle.properties + + - name: Build gplay # TODO build only once! + run: | + sed -i s#https://server#http://10.0.2.2# gradle.properties + sed -i s"#1#5#" ./library/src/androidTest/java/com/owncloud/android/RetryTestRule.kt + ./gradlew assembleDebug --info + + - name: wait and ping server + run: | + while ! curl http://localhost/status.php 2>&1 | grep installed; do + echo "wait…" + sleep 5 + done + + - name: gplay + env: + SHOT_TEST: "true" + uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d # v2.33.0 + with: + api-level: ${{ matrix.api-level }} + force-avd-creation: false + arch: x86 + sdcard-path-or-size: 100M + target: google_apis + emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -skin 500x833 + script: scripts/runTests.sh + + - name: upload failing results + if: ${{ failure() }} + env: + LOG_USERNAME: ${{ secrets.LOG_USERNAME }} + LOG_PASSWORD: ${{ secrets.LOG_PASSWORD }} + GIT_USERNAME: ${{ secrets.GIT_USERNAME }} + GIT_TOKEN: ${{ secrets.GIT_TOKEN }} + run: scripts/uploadReport.sh "${{ secrets.LOG_USERNAME }}" "${{ secrets.LOG_PASSWORD }}" ${{github.event.number}} "master" "IT" ${{github.event.number}} "${{ secrets.GIT_USERNAME }}" "${{ secrets.GIT_TOKEN }}" + - name: Archive Espresso results + uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + if: ${{ always() }} + with: + name: Report-${{ matrix.server }}-${{ matrix.api-level }} + path: app/build/reports + retention-days: 4 + +# stable16: +# runs-on: ubuntu-latest-kvm +# services: +# server: +# image: nextcloudci/server:server-13 +# options: --name server +# ports: +# - 80:80 +# strategy: +# fail-fast: false +# matrix: +# api-level: [ 27 ] +# steps: +# - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 +# +# - name: wait and ping server +# run: | +# while ! curl http://localhost/status.php 2>&1 | grep installed; do +# echo "wait…" +# sleep 5 +# done +# +# - name: configure server +# run: | +# docker cp .github/workflows/configServer16.sh server:/tmp/ +# docker exec server chmod +x /tmp/configServer16.sh +# docker exec server /tmp/configServer16.sh +# docker cp .github/workflows/configNC_stable16.sh server:/tmp/ +# docker exec server chmod +x /tmp/configNC_stable16.sh +# docker exec --user www-data server /tmp/configNC_stable16.sh +# +# - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 +# with: +# distribution: "temurin" +# java-version: 17 +# +# - name: create AVD and generate snapshot for caching +# uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d # v2.33.0 +# with: +# api-level: ${{ matrix.api-level }} +# force-avd-creation: false +# arch: x86 +# sdcard-path-or-size: 100M +# target: google_apis +# emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -skin 500x833 +# script: echo "Generated AVD snapshot for caching." +# +# - name: Configure gradle daemon +# run: | +# mkdir -p $HOME/.gradle +# echo "org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > $HOME/.gradle/gradle.properties +# echo "org.gradle.caching=true" >> $HOME/.gradle/gradle.properties +# +# - name: Build gplay # TODO build only once! +# run: | +# sed -i s#https://server#http://10.0.2.2# gradle.properties +# sed -i s"#1#5#" ./library/src/androidTest/java/com/owncloud/android/RetryTestRule.kt +# ./gradlew assembleDebug +# +# - name: gplay +# env: +# SHOT_TEST: "true" +# uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d # v2.33.0 +# with: +# api-level: ${{ matrix.api-level }} +# force-avd-creation: false +# arch: x86 +# sdcard-path-or-size: 100M +# target: google_apis +# emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -skin 500x833 +# script: scripts/runTests.sh +# +# - name: upload failing results +# if: ${{ failure() }} +# env: +# LOG_USERNAME: ${{ secrets.LOG_USERNAME }} +# LOG_PASSWORD: ${{ secrets.LOG_PASSWORD }} +# GIT_USERNAME: ${{ secrets.GIT_USERNAME }} +# GIT_TOKEN: ${{ secrets.GIT_TOKEN }} +# run: scripts/uploadReport.sh "${{ secrets.LOG_USERNAME }}" "${{ secrets.LOG_PASSWORD }}" ${{github.event.number}} "master" "IT" ${{github.event.number}} "${{ secrets.GIT_USERNAME }}" "${{ secrets.GIT_TOKEN }}" +# - name: Archive Espresso results +# uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 +# if: ${{ always() }} +# with: +# name: Report-${{ matrix.server }}-${{ matrix.api-level }} +# path: app/build/reports +# retention-days: 4 diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml deleted file mode 100644 index 7071005c2..000000000 --- a/.github/workflows/gradle-wrapper-validation.yml +++ /dev/null @@ -1,29 +0,0 @@ -# synced from @nextcloud/android-config - -# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors -# SPDX-FileCopyrightText: 2023 Andy Scherzinger -# SPDX-FileCopyrightText: 2023 Tobias Kaminsky -# SPDX-FileCopyrightText: 2023 Álvaro Brey -# SPDX-License-Identifier: GPL-3.0-or-later - -name: "Validate Gradle Wrapper" -on: - pull_request: - branches: [ master, stable-* ] - push: - branches: [ master, stable-* ] - -# Declare default permissions as read only. -permissions: read-all - -concurrency: - group: validate-gradle-wrapper-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - validation: - name: "Validation" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - uses: gradle/wrapper-validation-action@f9c9c575b8b21b6485636a91ffecd10e558c62f6 # v3.5.0 diff --git a/.github/workflows/pr-feedback.yml b/.github/workflows/pr-feedback.yml deleted file mode 100644 index 6a01fa09b..000000000 --- a/.github/workflows/pr-feedback.yml +++ /dev/null @@ -1,50 +0,0 @@ -# This workflow is provided via the organization template repository -# -# https://github.com/nextcloud/.github -# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization - -# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors -# SPDX-FileCopyrightText: 2023 Marcel Klehr -# SPDX-FileCopyrightText: 2023 Joas Schilling <213943+nickvergessen@users.noreply.github.com> -# SPDX-FileCopyrightText: 2023 Daniel Kesselberg -# SPDX-FileCopyrightText: 2023 Florian Steffens -# SPDX-License-Identifier: MIT - -name: 'Ask for feedback on PRs' -on: - schedule: - - cron: '30 1 * * *' - -jobs: - pr-feedback: - runs-on: ubuntu-latest - steps: - - name: The get-github-handles-from-website action - uses: marcelklehr/get-github-handles-from-website-action@a739600f6b91da4957f51db0792697afbb2f143c # v1.0.0 - id: scrape - with: - website: 'https://nextcloud.com/team/' - - - name: Get blocklist - id: blocklist - run: | - blocklist=$(curl https://raw.githubusercontent.com/nextcloud/.github/master/non-community-usernames.txt | paste -s -d, -) - echo "blocklist=$blocklist" >> "$GITHUB_OUTPUT" - - - uses: marcelklehr/pr-feedback-action@1883b38a033fb16f576875e0cf45f98b857655c4 - with: - feedback-message: | - Hello there, - Thank you so much for taking the time and effort to create a pull request to our Nextcloud project. - - We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. - - Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 - - Thank you for contributing to Nextcloud and we hope to hear from you soon! - - (If you believe you should not receive this message, you can add yourself to the [blocklist](https://github.com/nextcloud/.github/blob/master/non-community-usernames.txt).) - days-before-feedback: 14 - start-date: '2024-04-30' - exempt-authors: '${{ steps.blocklist.outputs.blocklist }},${{ steps.scrape.outputs.users }}' - exempt-bots: true diff --git a/.github/workflows/reuse.yml b/.github/workflows/reuse.yml deleted file mode 100644 index 8b9b6227e..000000000 --- a/.github/workflows/reuse.yml +++ /dev/null @@ -1,22 +0,0 @@ -# This workflow is provided via the organization template repository -# -# https://github.com/nextcloud/.github -# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization - -# SPDX-FileCopyrightText: 2022 Free Software Foundation Europe e.V. -# -# SPDX-License-Identifier: CC0-1.0 - -name: REUSE Compliance Check - -on: [pull_request] - -jobs: - reuse-compliance-check: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - - name: REUSE Compliance Check - uses: fsfe/reuse-action@3ae3c6bdf1257ab19397fab11fd3312144692083 # v4.0.0 diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml deleted file mode 100644 index 1c2939209..000000000 --- a/.github/workflows/scorecard.yml +++ /dev/null @@ -1,47 +0,0 @@ -# synced from @nextcloud/android-config - -# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors -# SPDX-FileCopyrightText: 2023 Andy Scherzinger -# SPDX-License-Identifier: GPL-3.0-or-later - -name: Scorecard supply-chain security -on: - branch_protection_rule: - schedule: - - cron: '32 23 * * 4' - push: - branches: [ "main", "master" ] - -# Declare default permissions as read only. -permissions: read-all - -concurrency: - group: scorecard-supply-chain-security-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - analysis: - name: Scorecard analysis - runs-on: ubuntu-latest - permissions: - # Needed to upload the results to code-scanning dashboard. - security-events: write - - steps: - - name: "Checkout code" - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - persist-credentials: false - - - name: "Run analysis" - uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0 - with: - results_file: results.sarif - results_format: sarif - publish_results: false - - # Upload the results to GitHub's code scanning dashboard. - - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0 - with: - sarif_file: results.sarif diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml deleted file mode 100644 index 16ffacdb0..000000000 --- a/.github/workflows/stale.yml +++ /dev/null @@ -1,35 +0,0 @@ -# synced from @nextcloud/android-config - -# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors -# SPDX-FileCopyrightText: 2023 Tobias Kaminsky -# SPDX-FileCopyrightText: 2022 Álvaro Brey -# SPDX-License-Identifier: GPL-3.0-or-later - -name: 'Close stale issues' -on: - schedule: - - cron: '0 0 * * *' - -# Declare default permissions as read only. -permissions: read-all - -jobs: - stale: - runs-on: ubuntu-latest - permissions: - issues: write - pull-requests: write - steps: - - uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # v9.0.0 - with: - days-before-stale: 28 - days-before-close: 14 - days-before-pr-close: -1 - only-labels: 'bug,needs info' - exempt-issue-labels: 'no-stale' - stale-issue-message: >- - This bug report did not receive an update in the last 4 weeks. - Please take a look again and update the issue with new details, - otherwise the issue will be automatically closed in 2 weeks. Thank you! - exempt-all-pr-milestones: true - labels-to-remove-when-unstale: 'needs info' diff --git a/library/src/androidTest/java/com/nextcloud/android/lib/resources/dashboard/DashboardGetWidgetItemsRemoteOperationIT.kt b/library/src/androidTest/java/com/nextcloud/android/lib/resources/dashboard/DashboardGetWidgetItemsRemoteOperationIT.kt index a2e9aed38..b10e8ee8f 100644 --- a/library/src/androidTest/java/com/nextcloud/android/lib/resources/dashboard/DashboardGetWidgetItemsRemoteOperationIT.kt +++ b/library/src/androidTest/java/com/nextcloud/android/lib/resources/dashboard/DashboardGetWidgetItemsRemoteOperationIT.kt @@ -14,14 +14,18 @@ import com.owncloud.android.lib.resources.shares.OCShare import com.owncloud.android.lib.resources.shares.ShareType import com.owncloud.android.lib.resources.status.NextcloudVersion import org.junit.Assert.assertTrue +import org.junit.Before import org.junit.Test class DashboardGetWidgetItemsRemoteOperationIT : AbstractIT() { - @Test - fun getItems() { + @Before + fun before() { // only on NC25+ testOnlyOnServer(NextcloudVersion.nextcloud_25) + } + @Test + fun getItems() { // create folder to have some content assertTrue(CreateFolderRemoteOperation("/testFolder", false).execute(client2).isSuccess) assertTrue( diff --git a/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingCreateFileRemoteOperationIT.java b/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingCreateFileRemoteOperationIT.java index b8b88a081..81d885844 100644 --- a/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingCreateFileRemoteOperationIT.java +++ b/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingCreateFileRemoteOperationIT.java @@ -9,13 +9,20 @@ import com.owncloud.android.AbstractIT; import com.owncloud.android.lib.common.operations.RemoteOperationResult; +import com.owncloud.android.lib.resources.status.OwnCloudVersion; +import org.junit.BeforeClass; import org.junit.Test; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; public class DirectEditingCreateFileRemoteOperationIT extends AbstractIT { + @BeforeClass + public static void beforeClass() { + testOnlyOnServer(OwnCloudVersion.nextcloud_18); + } + @Test public void createEmptyFile() { RemoteOperationResult result = new DirectEditingCreateFileRemoteOperation("/test.md", diff --git a/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingObtainListOfTemplatesRemoteOperationIT.java b/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingObtainListOfTemplatesRemoteOperationIT.java index 83540cdbe..2ca3334a5 100644 --- a/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingObtainListOfTemplatesRemoteOperationIT.java +++ b/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingObtainListOfTemplatesRemoteOperationIT.java @@ -10,7 +10,9 @@ import com.owncloud.android.AbstractIT; import com.owncloud.android.lib.common.TemplateList; import com.owncloud.android.lib.common.operations.RemoteOperationResult; +import com.owncloud.android.lib.resources.status.OwnCloudVersion; +import org.junit.BeforeClass; import org.junit.Test; import java.util.Objects; @@ -19,6 +21,10 @@ import static org.junit.Assert.assertTrue; public class DirectEditingObtainListOfTemplatesRemoteOperationIT extends AbstractIT { + @BeforeClass + public static void beforeClass() { + testOnlyOnServer(OwnCloudVersion.nextcloud_18); + } @Test public void testGetAll() { diff --git a/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingObtainRemoteOperationIT.kt b/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingObtainRemoteOperationIT.kt index 4fccbcda2..377384f35 100644 --- a/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingObtainRemoteOperationIT.kt +++ b/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingObtainRemoteOperationIT.kt @@ -8,13 +8,20 @@ package com.nextcloud.android.lib.resources.directediting import com.owncloud.android.AbstractIT +import com.owncloud.android.lib.resources.status.OwnCloudVersion import junit.framework.Assert.assertEquals import junit.framework.Assert.assertFalse import junit.framework.Assert.assertNotNull import junit.framework.Assert.assertTrue +import org.junit.Before import org.junit.Test class DirectEditingObtainRemoteOperationIT : AbstractIT() { + @Before + fun before() { + testOnlyOnServer(OwnCloudVersion.nextcloud_18) + } + @Test fun testGetAll() { val result = DirectEditingObtainRemoteOperation().run(nextcloudClient) diff --git a/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingOpenFileRemoteOperationIT.java b/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingOpenFileRemoteOperationIT.java index 9f23bf3a7..aa12df605 100644 --- a/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingOpenFileRemoteOperationIT.java +++ b/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingOpenFileRemoteOperationIT.java @@ -11,9 +11,11 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation; import com.owncloud.android.lib.resources.files.UploadFileRemoteOperation; +import com.owncloud.android.lib.resources.status.OwnCloudVersion; import junit.framework.TestCase; +import org.junit.BeforeClass; import org.junit.Test; import java.io.IOException; @@ -22,6 +24,11 @@ import static org.junit.Assert.assertTrue; public class DirectEditingOpenFileRemoteOperationIT extends AbstractIT { + @BeforeClass + public static void beforeClass() { + testOnlyOnServer(OwnCloudVersion.nextcloud_18); + } + @Test public void openFile() throws IOException { // create file diff --git a/library/src/androidTest/java/com/nextcloud/android/lib/resources/search/UnifiedSearchRemoteOperationIT.kt b/library/src/androidTest/java/com/nextcloud/android/lib/resources/search/UnifiedSearchRemoteOperationIT.kt index 5f78c913c..721cdf00d 100644 --- a/library/src/androidTest/java/com/nextcloud/android/lib/resources/search/UnifiedSearchRemoteOperationIT.kt +++ b/library/src/androidTest/java/com/nextcloud/android/lib/resources/search/UnifiedSearchRemoteOperationIT.kt @@ -11,10 +11,12 @@ import com.owncloud.android.AbstractIT import com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation import com.owncloud.android.lib.resources.files.model.RemoteFile +import com.owncloud.android.lib.resources.status.OwnCloudVersion import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertNotNull import org.junit.Assert.assertTrue +import org.junit.BeforeClass import org.junit.Test class UnifiedSearchRemoteOperationIT : AbstractIT() { @@ -76,4 +78,12 @@ class UnifiedSearchRemoteOperationIT : AbstractIT() { assertTrue(data.entries.isNotEmpty()) assertNotNull(data.entries.find { it.title == "test Folder" }) } + + companion object { + @BeforeClass + @JvmStatic + fun before() { + testOnlyOnServer(OwnCloudVersion.nextcloud_20) + } + } } diff --git a/library/src/androidTest/java/com/nextcloud/android/lib/richWorkspace/RichWorkspaceDirectEditingRemoteOperationIT.java b/library/src/androidTest/java/com/nextcloud/android/lib/richWorkspace/RichWorkspaceDirectEditingRemoteOperationIT.java index 8d4d2f8c3..eef06c8b5 100644 --- a/library/src/androidTest/java/com/nextcloud/android/lib/richWorkspace/RichWorkspaceDirectEditingRemoteOperationIT.java +++ b/library/src/androidTest/java/com/nextcloud/android/lib/richWorkspace/RichWorkspaceDirectEditingRemoteOperationIT.java @@ -16,13 +16,19 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation; import com.owncloud.android.lib.resources.files.UploadFileRemoteOperation; +import com.owncloud.android.lib.resources.status.OwnCloudVersion; +import org.junit.BeforeClass; import org.junit.Test; import java.io.File; import java.io.IOException; public class RichWorkspaceDirectEditingRemoteOperationIT extends AbstractIT { + @BeforeClass + public static void beforeClass() { + testOnlyOnServer(OwnCloudVersion.nextcloud_18); + } @Test public void getEditLinkForRoot() { diff --git a/library/src/androidTest/java/com/owncloud/android/AbstractIT.java b/library/src/androidTest/java/com/owncloud/android/AbstractIT.java index 629747cce..9422e2f81 100644 --- a/library/src/androidTest/java/com/owncloud/android/AbstractIT.java +++ b/library/src/androidTest/java/com/owncloud/android/AbstractIT.java @@ -314,7 +314,7 @@ protected void longSleep() { } } - protected void testOnlyOnServer(OwnCloudVersion version) { + static protected void testOnlyOnServer(OwnCloudVersion version) { OCCapability ocCapability = (OCCapability) new GetCapabilitiesRemoteOperation() .execute(nextcloudClient) .getSingleData(); diff --git a/library/src/androidTest/java/com/owncloud/android/FileIT.java b/library/src/androidTest/java/com/owncloud/android/FileIT.java index 2cadacc7c..0caa49fc6 100644 --- a/library/src/androidTest/java/com/owncloud/android/FileIT.java +++ b/library/src/androidTest/java/com/owncloud/android/FileIT.java @@ -25,6 +25,7 @@ import com.owncloud.android.lib.resources.status.GetCapabilitiesRemoteOperation; import com.owncloud.android.lib.resources.status.NextcloudVersion; import com.owncloud.android.lib.resources.status.OCCapability; +import com.owncloud.android.lib.resources.status.OwnCloudVersion; import org.junit.Test; @@ -146,6 +147,8 @@ public void testShareViaLinkSharees() { @Test public void testShareToGroupSharees() { + testOnlyOnServer(OwnCloudVersion.nextcloud_17); + // create & verify folder String path = "/testFolder/"; assertTrue(new CreateFolderRemoteOperation(path, true).execute(client).isSuccess()); @@ -188,6 +191,8 @@ public void testShareToGroupSharees() { @Test public void testOneSharees() { + testOnlyOnServer(OwnCloudVersion.nextcloud_17); + // create & verify folder String path = "/testFolder/"; assertTrue(new CreateFolderRemoteOperation(path, true).execute(client).isSuccess()); @@ -223,6 +228,8 @@ public void testOneSharees() { @Test public void testTwoShareesOnParent() { + testOnlyOnServer(OwnCloudVersion.nextcloud_17); + // create & verify folder String path = "/testFolder/"; assertTrue(new CreateFolderRemoteOperation(path, true).execute(client).isSuccess()); @@ -271,6 +278,8 @@ public void testTwoShareesOnParent() { @Test public void testTwoSharees() { + testOnlyOnServer(OwnCloudVersion.nextcloud_17); + // create & verify folder String path = "/testFolder/"; assertTrue(new CreateFolderRemoteOperation(path, true).execute(client).isSuccess()); diff --git a/library/src/androidTest/java/com/owncloud/android/GetCapabilitiesRemoteOperationIT.java b/library/src/androidTest/java/com/owncloud/android/GetCapabilitiesRemoteOperationIT.java index 5445234be..97533bc45 100644 --- a/library/src/androidTest/java/com/owncloud/android/GetCapabilitiesRemoteOperationIT.java +++ b/library/src/androidTest/java/com/owncloud/android/GetCapabilitiesRemoteOperationIT.java @@ -9,6 +9,13 @@ */ package com.owncloud.android; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.resources.status.CapabilityBooleanType; import com.owncloud.android.lib.resources.status.E2EVersion; @@ -19,13 +26,6 @@ import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; - /** * Class to test GetRemoteCapabilitiesOperation */ @@ -112,10 +112,12 @@ private void checkCapability(OCCapability capability, String userId) { assertTrue(capability.getFilesVersioning().isTrue()); assertTrue(capability.getFilesUndelete().isTrue()); assertNotNull(capability.getVersion()); - assertFalse(capability.getEtag().isEmpty()); - assertSame(CapabilityBooleanType.FALSE, capability.getRichDocuments()); - assertFalse(capability.getDirectEditingEtag().isEmpty()); assertSame(CapabilityBooleanType.UNKNOWN, capability.getDropAccount()); + if (capability.getVersion().isNewerOrEqual(OwnCloudVersion.nextcloud_17)) { + assertFalse(capability.getEtag().isEmpty()); + assertFalse(capability.getDirectEditingEtag().isEmpty()); + } + assertSame(CapabilityBooleanType.FALSE, capability.getRichDocuments()); // user status if (capability.getVersion().isNewerOrEqual(OwnCloudVersion.nextcloud_20)) { diff --git a/library/src/androidTest/java/com/owncloud/android/lib/resources/e2ee/UpdateMetadataRemoteOperationIT.java b/library/src/androidTest/java/com/owncloud/android/lib/resources/e2ee/UpdateMetadataRemoteOperationIT.java index c30d7c13e..255bffb8b 100644 --- a/library/src/androidTest/java/com/owncloud/android/lib/resources/e2ee/UpdateMetadataRemoteOperationIT.java +++ b/library/src/androidTest/java/com/owncloud/android/lib/resources/e2ee/UpdateMetadataRemoteOperationIT.java @@ -26,7 +26,7 @@ public class UpdateMetadataRemoteOperationIT extends AbstractIT { //@Test public void uploadAndModifyV1() { // tests only for NC19+ - testOnlyOnServer(OwnCloudVersion.nextcloud_20); + testOnlyOnServer(OwnCloudVersion.nextcloud_19); // E2E server app checks for official NC client with >=3.13.0, // and blocks all other clients, e.g. 3rd party apps using this lib diff --git a/library/src/androidTest/java/com/owncloud/android/lib/resources/files/ReadFileRemoteOperationIT.kt b/library/src/androidTest/java/com/owncloud/android/lib/resources/files/ReadFileRemoteOperationIT.kt index 026b4083e..f222981b3 100644 --- a/library/src/androidTest/java/com/owncloud/android/lib/resources/files/ReadFileRemoteOperationIT.kt +++ b/library/src/androidTest/java/com/owncloud/android/lib/resources/files/ReadFileRemoteOperationIT.kt @@ -97,6 +97,8 @@ class ReadFileRemoteOperationIT : AbstractIT() { @Test fun testMetadata() { + testOnlyOnServer(NextcloudVersion.nextcloud_27) + val filePath = getFile("gps.jpg").absolutePath val remotePath = "/gps.jpg" @@ -113,8 +115,6 @@ class ReadFileRemoteOperationIT : AbstractIT() { @Suppress("Detekt.MagicNumber") assertEquals(ImageDimension(451f, 529f), remoteFile.imageDimension) - testOnlyOnServer(NextcloudVersion.nextcloud_27) - val ocCapability = GetCapabilitiesRemoteOperation() .execute(nextcloudClient) diff --git a/library/src/androidTest/java/com/owncloud/android/lib/resources/files/SearchRemoteOperationIT.java b/library/src/androidTest/java/com/owncloud/android/lib/resources/files/SearchRemoteOperationIT.java index f16c50e8d..58f62c385 100644 --- a/library/src/androidTest/java/com/owncloud/android/lib/resources/files/SearchRemoteOperationIT.java +++ b/library/src/androidTest/java/com/owncloud/android/lib/resources/files/SearchRemoteOperationIT.java @@ -24,7 +24,9 @@ import com.owncloud.android.lib.resources.shares.CreateShareRemoteOperation; import com.owncloud.android.lib.resources.shares.ShareType; import com.owncloud.android.lib.resources.status.GetCapabilitiesRemoteOperation; +import com.owncloud.android.lib.resources.status.NextcloudVersion; import com.owncloud.android.lib.resources.status.OCCapability; +import com.owncloud.android.lib.resources.status.OwnCloudVersion; import org.junit.BeforeClass; import org.junit.Test; @@ -94,6 +96,13 @@ public void testFileSearchEmpty() throws IOException { @Test public void testFileSearchEverything() throws IOException { + // on newer server we have Talk folder + int offset = 0; + if (capability.getVersion().isNewerOrEqual(NextcloudVersion.nextcloud_20) || + capability.getVersion().getMajorVersionNumber() == NextcloudVersion.nextcloud_17.getMajorVersionNumber()) { + offset = 1; + } + for (int i = 0; i < 10; i++) { String filePath = createFile("image" + i); String remotePath = "/image" + i + ".jpg"; @@ -108,7 +117,7 @@ public void testFileSearchEverything() throws IOException { RemoteOperationResult> result = sut.execute(client); assertTrue(result.isSuccess()); - assertEquals(11, result.getResultData().size()); + assertEquals(offset + 10, result.getResultData().size()); } @Test @@ -202,7 +211,14 @@ public void favoriteFiles() throws IOException { assertEquals(2, result.getResultData().size()); assertEquals(remotePath, result.getResultData().get(0).getRemotePath()); - assertEquals(sharedRemotePath, result.getResultData().get(1).getRemotePath()); + + if (capability.getVersion().isNewerOrEqual(OwnCloudVersion.nextcloud_17)) { + assertEquals(sharedRemotePath, result.getResultData().get(1).getRemotePath()); + } else { + // on NC16 we have a bug that each file ends with "/" + sharedRemotePath += "/"; + assertEquals(sharedRemotePath, result.getResultData().get(1).getRemotePath()); + } } /** @@ -210,6 +226,13 @@ public void favoriteFiles() throws IOException { */ @Test public void testRecentlyModifiedSearch() throws IOException { + // on newer server we have Talk folder + int offset = 0; + if (capability.getVersion().isNewerOrEqual(NextcloudVersion.nextcloud_20) || + capability.getVersion().getMajorVersionNumber() == NextcloudVersion.nextcloud_17.getMajorVersionNumber()) { + offset = 1; + } + long now = System.currentTimeMillis() / MILLI_TO_SECOND; String filePath = createFile("image"); assertTrue(new UploadFileRemoteOperation(filePath, "/image.jpg", "image/jpg", now - 50) @@ -234,7 +257,7 @@ public void testRecentlyModifiedSearch() throws IOException { RemoteOperationResult> result = sut.execute(client); assertTrue(result.isSuccess()); - assertEquals(4, result.getResultData().size()); + assertEquals(offset + 3, result.getResultData().size()); assertEquals("/video.mp4", result.getResultData().get(0).getRemotePath()); assertEquals("/pdf.pdf", result.getResultData().get(1).getRemotePath()); @@ -399,6 +422,8 @@ public void testPhotoSearchLimitAndTimestamp() throws IOException { @Test public void testGallerySearch() throws IOException { + testOnlyOnServer(OwnCloudVersion.nextcloud_18); + for (int i = 0; i < 10; i++) { String filePath = createFile("image" + i); String remotePath = "/image" + i + ".jpg"; @@ -425,6 +450,14 @@ public void testGallerySearch() throws IOException { @Test public void showOnlyFolders() throws IOException { + // on newer server we have Talk folder + // on NC16 groupfolder is also returned + int offset = 0; + if (capability.getVersion().isNewerOrEqual(NextcloudVersion.nextcloud_20) || + capability.getVersion().getMajorVersionNumber() == NextcloudVersion.nextcloud_17.getMajorVersionNumber()) { + offset = 1; + } + for (int i = 0; i < 10; i++) { String filePath = createFile("image" + i); String remotePath = "/image" + i + ".jpg"; @@ -438,13 +471,13 @@ public void showOnlyFolders() throws IOException { RemoteOperationResult> result = sut.execute(client); assertTrue(result.isSuccess()); - assertEquals(1, result.getResultData().size()); + assertEquals(0 + offset, result.getResultData().size()); assertTrue(new CreateFolderRemoteOperation("/folder/", false).execute(client).isSuccess()); result = sut.execute(client); assertTrue(result.isSuccess()); - assertEquals(2, result.getResultData().size()); + assertEquals(1 + offset, result.getResultData().size()); assertEquals("/folder/", result.getResultData().get(0).getRemotePath()); } diff --git a/library/src/androidTest/java/com/owncloud/android/lib/resources/files/UploadFileRemoteOperationIT.kt b/library/src/androidTest/java/com/owncloud/android/lib/resources/files/UploadFileRemoteOperationIT.kt index 8376af46c..f803ab8b0 100644 --- a/library/src/androidTest/java/com/owncloud/android/lib/resources/files/UploadFileRemoteOperationIT.kt +++ b/library/src/androidTest/java/com/owncloud/android/lib/resources/files/UploadFileRemoteOperationIT.kt @@ -11,6 +11,9 @@ import android.os.Build import com.owncloud.android.AbstractIT import com.owncloud.android.lib.common.utils.Log_OC import com.owncloud.android.lib.resources.files.model.RemoteFile +import com.owncloud.android.lib.resources.status.GetCapabilitiesRemoteOperation +import com.owncloud.android.lib.resources.status.OCCapability +import com.owncloud.android.lib.resources.status.OwnCloudVersion import junit.framework.TestCase.assertEquals import org.junit.Assert.assertNotNull import org.junit.Assert.assertTrue @@ -32,6 +35,10 @@ class UploadFileRemoteOperationIT : AbstractIT() { @Test fun upload() { + val ocCapability = + GetCapabilitiesRemoteOperation() + .execute(nextcloudClient).singleData as OCCapability + // create file val filePath = createFile("text") val remotePath = "/test.md" @@ -59,12 +66,15 @@ class UploadFileRemoteOperationIT : AbstractIT() { var remoteFile = result.data[0] as RemoteFile assertEquals(remotePath, remoteFile.remotePath) - assertEquals(creationTimestamp, remoteFile.creationTimestamp) assertEquals(uploadResult.resultData, remoteFile.etag) - assertTrue( - uploadTimestamp - TIME_OFFSET < remoteFile.uploadTimestamp || - uploadTimestamp + TIME_OFFSET > remoteFile.uploadTimestamp - ) + + if (ocCapability.version.isNewerOrEqual(OwnCloudVersion.nextcloud_18)) { + assertEquals(creationTimestamp, remoteFile.creationTimestamp) + assertTrue( + uploadTimestamp - TIME_OFFSET < remoteFile.uploadTimestamp || + uploadTimestamp + TIME_OFFSET > remoteFile.uploadTimestamp + ) + } // ReadFolderRemoteOperation result = ReadFolderRemoteOperation(remotePath).execute(client) @@ -73,11 +83,14 @@ class UploadFileRemoteOperationIT : AbstractIT() { remoteFile = result.data[0] as RemoteFile assertEquals(remotePath, remoteFile.remotePath) - assertEquals(creationTimestamp, remoteFile.creationTimestamp) - assertTrue( - uploadTimestamp - TIME_OFFSET < remoteFile.uploadTimestamp || - uploadTimestamp + TIME_OFFSET > remoteFile.uploadTimestamp - ) + + if (ocCapability.version.isNewerOrEqual(OwnCloudVersion.nextcloud_18)) { + assertEquals(creationTimestamp, remoteFile.creationTimestamp) + assertTrue( + uploadTimestamp - TIME_OFFSET < remoteFile.uploadTimestamp || + uploadTimestamp + TIME_OFFSET > remoteFile.uploadTimestamp + ) + } } private fun getCreationTimestamp(file: File): Long? { diff --git a/library/src/androidTest/java/com/owncloud/android/lib/resources/notifications/NotificationIT.kt b/library/src/androidTest/java/com/owncloud/android/lib/resources/notifications/NotificationIT.kt index ba34b46fb..ecef8e300 100644 --- a/library/src/androidTest/java/com/owncloud/android/lib/resources/notifications/NotificationIT.kt +++ b/library/src/androidTest/java/com/owncloud/android/lib/resources/notifications/NotificationIT.kt @@ -8,6 +8,7 @@ package com.owncloud.android.lib.resources.notifications import com.owncloud.android.AbstractIT +import com.owncloud.android.lib.resources.status.OwnCloudVersion import junit.framework.TestCase.assertEquals import junit.framework.TestCase.assertTrue import org.junit.Test @@ -22,6 +23,8 @@ class NotificationIT : AbstractIT() { val count = all.resultData.size // get one + testOnlyOnServer(OwnCloudVersion.nextcloud_17) + val firstNotification = all.resultData[0] val first = GetNotificationRemoteOperation(firstNotification.notificationId).execute(nextcloudClient) assertTrue(first.isSuccess) diff --git a/library/src/androidTest/java/com/owncloud/android/lib/resources/shares/GetSharesRemoteOperationIT.java b/library/src/androidTest/java/com/owncloud/android/lib/resources/shares/GetSharesRemoteOperationIT.java index 58ed2ac25..27d2f0cb3 100644 --- a/library/src/androidTest/java/com/owncloud/android/lib/resources/shares/GetSharesRemoteOperationIT.java +++ b/library/src/androidTest/java/com/owncloud/android/lib/resources/shares/GetSharesRemoteOperationIT.java @@ -27,6 +27,7 @@ import com.owncloud.android.lib.resources.status.GetCapabilitiesRemoteOperation; import com.owncloud.android.lib.resources.status.NextcloudVersion; import com.owncloud.android.lib.resources.status.OCCapability; +import com.owncloud.android.lib.resources.status.OwnCloudVersion; import junit.framework.TestCase; @@ -154,6 +155,8 @@ private void assertFolderAttributes(final OCShare share, final String expectedDi @Test public void sharedWithMe() { + testOnlyOnServer(OwnCloudVersion.nextcloud_19); + GetSharesRemoteOperation sut = new GetSharesRemoteOperation(); GetSharesRemoteOperation sutSharedWithMe = new GetSharesRemoteOperation(true); diff --git a/library/src/androidTest/java/com/owncloud/android/lib/resources/users/AppTokenRemoteOperationIT.kt b/library/src/androidTest/java/com/owncloud/android/lib/resources/users/AppTokenRemoteOperationIT.kt index 53802ec18..3642fbf05 100644 --- a/library/src/androidTest/java/com/owncloud/android/lib/resources/users/AppTokenRemoteOperationIT.kt +++ b/library/src/androidTest/java/com/owncloud/android/lib/resources/users/AppTokenRemoteOperationIT.kt @@ -9,6 +9,7 @@ package com.owncloud.android.lib.resources.users import androidx.test.platform.app.InstrumentationRegistry import com.owncloud.android.AbstractIT +import com.owncloud.android.lib.resources.status.OwnCloudVersion import junit.framework.Assert.assertFalse import junit.framework.Assert.assertTrue import okhttp3.Credentials.basic @@ -57,6 +58,8 @@ class AppTokenRemoteOperationIT : AbstractIT() { @Test fun deleteAppPassword() { + testOnlyOnServer(OwnCloudVersion.nextcloud_17) + val arguments = InstrumentationRegistry.getArguments() val username: String = arguments.getString("TEST_SERVER_USERNAME", "") val password: String = arguments.getString("TEST_SERVER_PASSWORD", "") diff --git a/scripts/createDockerTestContainer.sh b/scripts/createDockerTestContainer.sh new file mode 100755 index 000000000..6ad2af78a --- /dev/null +++ b/scripts/createDockerTestContainer.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Nextcloud Android Library +# +# SPDX-FileCopyrightText: 2024 Tobias Kaminsky +# SPDX-License-Identifier: MIT +# + +if [[ $# -ne 1 ]]; then + echo "please specify stable29 or master as first parameter" + exit +fi + +docker stop testNC +docker rm testNC +docker run --name=testNC ghcr.io/nextcloud/continuous-integration-shallow-server:latest & +sleep 60 + +docker cp ../.github/workflows/configServer.sh testNC:/tmp/ +docker exec testNC chmod +x /tmp/configServer.sh +docker exec testNC /tmp/configServer.sh $1 +docker cp ../.github/workflows/configNC_$1.sh testNC:/tmp/ +docker exec testNC chmod +x /tmp/configNC_$1.sh +docker exec --user www-data testNC /tmp/configNC_$1.sh + +echo "Docker IP Address is:" +docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' testNC diff --git a/scripts/runTests.sh b/scripts/runTests.sh new file mode 100755 index 000000000..51d633814 --- /dev/null +++ b/scripts/runTests.sh @@ -0,0 +1,18 @@ +# +# Nextcloud Android Library +# +# SPDX-FileCopyrightText: 2024 Tobias Kaminsky +# SPDX-License-Identifier: MIT +# + +scripts/wait_for_emulator.sh +adb logcat -c +adb logcat > logcat.txt & +./gradlew jacocoTestDebugUnitTestReport +./gradlew installDebugAndroidTest +./gradlew createDebugCoverageReport +stat=$? + +./gradlew combinedTestReport + +exit $stat diff --git a/scripts/uploadReport.sh b/scripts/uploadReport.sh index c9b4a0534..868b8aa45 100755 --- a/scripts/uploadReport.sh +++ b/scripts/uploadReport.sh @@ -19,11 +19,11 @@ URL=https://nextcloud.kaminsky.me/remote.php/dav/files/$USER/android-library-int # upload logcat log_filename=$ID"_logcat.txt.xz" log_file="${log_filename}" -upload_path="https://nextcloud.kaminsky.me/remote.php/webdav/library-logcat/$log_filename" +upload_path="https://nextcloud.kaminsky.me/remote.php/webdav/android-library-logcat/$log_filename" xz logcat.txt mv logcat.txt.xz "$log_file" curl -u "$USER:$PASS" -X PUT "$upload_path" --upload-file "$log_file" -echo >&2 "Uploaded logcat to https://www.kaminsky.me/nc-dev/library-logcat/$log_filename" +echo >&2 "Uploaded logcat to https://www.kaminsky.me/nc-dev/android-library-logcat/$log_filename" if [ $TYPE = "IT" ]; then cd library/build/reports/androidTests/connected @@ -39,7 +39,7 @@ fi find . -type d -exec curl -u $USER:$PASS -X MKCOL $URL/$REMOTE_FOLDER/$(echo {} | sed s#\./##) \; find . -type f -exec curl -u $USER:$PASS -X PUT $URL/$REMOTE_FOLDER/$(echo {} | sed s#\./##) --upload-file {} \; -echo "Uploaded failing library tests to https://www.kaminsky.me/nc-dev/android-library-integrationTests/$REMOTE_FOLDER" +echo "Uploaded failing library tests to https://www.kaminsky.me/nc-dev/android-library-integrationTests/$REMOTE_FOLDER/debug/" curl -u $GIT_USERNAME:$GIT_TOKEN -X POST https://api.github.com/repos/nextcloud/android-library/issues/$PR_ID/comments -d "{ \"body\" : \"$BRANCH_TYPE test failed: https://www.kaminsky.me/nc-dev/android-library-integrationTests/$REMOTE_FOLDER/debug/ \" }" exit 1