diff --git a/.github/workflows/block-merge-freeze.yml b/.github/workflows/block-merge-freeze.yml index e56884c..2e4b3e2 100644 --- a/.github/workflows/block-merge-freeze.yml +++ b/.github/workflows/block-merge-freeze.yml @@ -3,19 +3,34 @@ # https://github.com/nextcloud/.github # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization -name: Pull request checks +name: Block merges during freezes -on: pull_request +on: + pull_request: + types: [opened, ready_for_review, reopened, synchronize] + +permissions: + contents: read + +concurrency: + group: block-merge-freeze-${{ github.head_ref || github.run_id }} + cancel-in-progress: true jobs: block-merges-during-freeze: name: Block merges during freezes - runs-on: ubuntu-latest + if: github.event.pull_request.draft == false + + runs-on: ubuntu-latest-low steps: - - name: Download version.php from ${{ github.base_ref }} - run: curl https://raw.githubusercontent.com/nextcloud/server/${{ github.base_ref }}/version.php --output version.php + - name: Register server reference to fallback to master branch + run: | + server_ref="$(if [ "${{ github.base_ref }}" = "main" ]; then echo -n "master"; else echo -n "${{ github.base_ref }}"; fi)" + echo "server_ref=$server_ref" >> $GITHUB_ENV + - name: Download version.php from ${{ env.server_ref }} + run: curl https://raw.githubusercontent.com/nextcloud/server/${{ env.server_ref }}/version.php --output version.php - name: Run check run: cat version.php | grep 'OC_VersionString' | grep -i -v 'RC' diff --git a/.github/workflows/dependabot-approve-merge.yml b/.github/workflows/dependabot-approve-merge.yml index 0d6e343..00b0196 100644 --- a/.github/workflows/dependabot-approve-merge.yml +++ b/.github/workflows/dependabot-approve-merge.yml @@ -15,22 +15,26 @@ on: permissions: contents: read +concurrency: + group: dependabot-approve-merge-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + jobs: auto-approve-merge: if: github.actor == 'dependabot[bot]' - runs-on: ubuntu-latest + runs-on: ubuntu-latest-low permissions: # for hmarr/auto-approve-action to approve PRs - pull-requests: write + pull-requests: write steps: # Github actions bot approve - - uses: hmarr/auto-approve-action@v2 + - uses: hmarr/auto-approve-action@b40d6c9ed2fa10c9a2749eca7eb004418a705501 # v2 with: github-token: ${{ secrets.GITHUB_TOKEN }} # Nextcloud bot approve and merge request - - uses: ahmadnassri/action-dependabot-auto-merge@v2 + - uses: ahmadnassri/action-dependabot-auto-merge@45fc124d949b19b6b8bf6645b6c9d55f4f9ac61a # v2 with: target: minor github-token: ${{ secrets.DEPENDABOT_AUTOMERGE_TOKEN }} diff --git a/.github/workflows/lint-info-xml.yml b/.github/workflows/lint-info-xml.yml index b5d4aff..bfcd581 100644 --- a/.github/workflows/lint-info-xml.yml +++ b/.github/workflows/lint-info-xml.yml @@ -3,15 +3,16 @@ # https://github.com/nextcloud/.github # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization -name: Lint +name: Lint info.xml -on: - pull_request: - push: - branches: - - main - - master - - stable* +on: pull_request + +permissions: + contents: read + +concurrency: + group: lint-info-xml-${{ github.head_ref || github.run_id }} + cancel-in-progress: true jobs: xml-linters: @@ -20,13 +21,14 @@ jobs: name: info.xml lint steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Download schema run: wget https://raw.githubusercontent.com/nextcloud/server/master/resources/app-info-shipped.xsd + - name: Lint info.xml - uses: ChristophWurst/xmllint-action@v1 + uses: ChristophWurst/xmllint-action@36f2a302f84f8c83fceea0b9c59e1eb4a616d3c1 # v1.2 with: xml-file: ./appinfo/info.xml xml-schema-file: ./app-info-shipped.xsd diff --git a/.github/workflows/lint-php-cs.yml b/.github/workflows/lint-php-cs.yml index 9aad514..bfdcb14 100644 --- a/.github/workflows/lint-php-cs.yml +++ b/.github/workflows/lint-php-cs.yml @@ -3,14 +3,16 @@ # https://github.com/nextcloud/.github # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization -name: Lint +name: Lint php-cs -on: - pull_request: - push: - branches: - - master - - stable* +on: pull_request + +permissions: + contents: read + +concurrency: + group: lint-php-cs-${{ github.head_ref || github.run_id }} + cancel-in-progress: true jobs: lint: @@ -20,13 +22,17 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - name: Set up php ${{ matrix.php-versions }} - uses: shivammathur/setup-php@v2 + - name: Set up php8.2 + uses: shivammathur/setup-php@6d7209f44a25a59e904b1ee9f3b0c33ab2cd888d # v2 with: - php-version: "7.4" + php-version: 8.2 + extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite coverage: none + ini-file: development + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Install dependencies run: composer i diff --git a/.github/workflows/lint-php.yml b/.github/workflows/lint-php.yml index 9cfb484..ace4276 100644 --- a/.github/workflows/lint-php.yml +++ b/.github/workflows/lint-php.yml @@ -3,39 +3,47 @@ # https://github.com/nextcloud/.github # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization -name: Lint +name: Lint php -on: - pull_request: - push: - branches: - - master - - stable* +on: pull_request + +permissions: + contents: read + +concurrency: + group: lint-php-${{ github.head_ref || github.run_id }} + cancel-in-progress: true jobs: php-lint: runs-on: ubuntu-latest strategy: matrix: - php-versions: ["7.4", "8.0", "8.1"] + php-versions: [ '8.0', '8.1', '8.2', '8.3' ] name: php-lint steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Set up php ${{ matrix.php-versions }} - uses: shivammathur/setup-php@v2 + uses: shivammathur/setup-php@6d7209f44a25a59e904b1ee9f3b0c33ab2cd888d # v2 with: php-version: ${{ matrix.php-versions }} + extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite coverage: none + ini-file: development + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Lint run: composer run lint summary: - runs-on: ubuntu-latest + permissions: + contents: none + runs-on: ubuntu-latest-low needs: php-lint if: always() diff --git a/.github/workflows/phpunit-sqlite.yml b/.github/workflows/phpunit-sqlite.yml index 7678151..cc22555 100644 --- a/.github/workflows/phpunit-sqlite.yml +++ b/.github/workflows/phpunit-sqlite.yml @@ -3,32 +3,65 @@ # https://github.com/nextcloud/.github # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization -name: PHPUnit +name: PHPUnit sqlite -on: - pull_request: - push: - branches: - - main - - master - - stable* +on: pull_request permissions: contents: read -env: - # Location of the phpunit.xml and phpunit.integration.xml files - PHPUNIT_CONFIG: ./tests/phpunit.xml - PHPUNIT_INTEGRATION_CONFIG: ./tests/phpunit.integration.xml +concurrency: + group: phpunit-sqlite-${{ github.head_ref || github.run_id }} + cancel-in-progress: true jobs: + matrix: + runs-on: ubuntu-latest + outputs: + php-max: ${{ steps.versions.outputs.php-max-list }} + server-max: ${{ steps.versions.outputs.branches-max-list }} + steps: + - name: Checkout app + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Get version matrix + id: versions + uses: icewind1991/nextcloud-version-matrix@d594a6929da316b732c53355e52a1ead77ba36c7 # v1.2.0 + + changes: + runs-on: ubuntu-latest + + outputs: + src: ${{ steps.changes.outputs.src}} + + steps: + - uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1 + id: changes + continue-on-error: true + with: + filters: | + src: + - '.github/workflows/**' + - 'appinfo/**' + - 'lib/**' + - 'templates/**' + - 'tests/**' + - 'vendor/**' + - 'vendor-bin/**' + - '.php-cs-fixer.dist.php' + - 'composer.json' + - 'composer.lock' + phpunit-sqlite: runs-on: ubuntu-latest + needs: [changes, matrix] + if: needs.changes.outputs.src != 'false' + strategy: matrix: - php-versions: ['8.0', '8.1', '8.2', '8.3'] - server-versions: ['stable28'] + php-versions: ${{ fromJson(needs.matrix.outputs.php-max) }} + server-versions: ${{ fromJson(needs.matrix.outputs.server-max) }} steps: - name: Set app env @@ -37,32 +70,35 @@ jobs: echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV - name: Checkout server - uses: actions/checkout@v3 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 with: submodules: true repository: nextcloud/server ref: ${{ matrix.server-versions }} - name: Checkout app - uses: actions/checkout@v3 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 with: path: apps/${{ env.APP_NAME }} - name: Set up php ${{ matrix.php-versions }} - uses: shivammathur/setup-php@v2 + uses: shivammathur/setup-php@6d7209f44a25a59e904b1ee9f3b0c33ab2cd888d # v2 with: php-version: ${{ matrix.php-versions }} - tools: phpunit - extensions: ctype, curl, dom, fileinfo, gd, imagick, intl, json, mbstring, oci8, openssl, pcntl, pdo_sqlite, posix, sqlite, xml, zip + # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation + extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite coverage: none + ini-file: development + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Check composer file existence id: check_composer - uses: andstor/file-existence-action@v1 + uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2 with: files: apps/${{ env.APP_NAME }}/composer.json - - name: Set up PHPUnit + - name: Set up dependencies # Only run if phpunit config file exists if: steps.check_composer.outputs.files_exists == 'true' working-directory: apps/${{ env.APP_NAME }} @@ -73,43 +109,57 @@ jobs: DB_PORT: 4444 run: | mkdir data - ./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password - ./occ app:enable ${{ env.APP_NAME }} + ./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin + ./occ app:enable --force ${{ env.APP_NAME }} - - name: Check PHPUnit config file existence + - name: Check PHPUnit script is defined id: check_phpunit - uses: andstor/file-existence-action@v1 - with: - files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_CONFIG }} + continue-on-error: true + working-directory: apps/${{ env.APP_NAME }} + run: | + composer run --list | grep "^ test:unit " | wc -l | grep 1 - name: PHPUnit # Only run if phpunit config file exists - if: steps.check_phpunit.outputs.files_exists == 'true' + if: steps.check_phpunit.outcome == 'success' working-directory: apps/${{ env.APP_NAME }} - run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_CONFIG }} + run: composer run test:unit - - name: Check PHPUnit integration config file existence + - name: Check PHPUnit integration script is defined id: check_integration - uses: andstor/file-existence-action@v1 - with: - files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_INTEGRATION_CONFIG }} + continue-on-error: true + working-directory: apps/${{ env.APP_NAME }} + run: | + composer run --list | grep "^ test:integration " | wc -l | grep 1 - name: Run Nextcloud # Only run if phpunit integration config file exists - if: steps.check_integration.outputs.files_exists == 'true' + if: steps.check_integration.outcome == 'success' run: php -S localhost:8080 & - name: PHPUnit integration # Only run if phpunit integration config file exists - if: steps.check_integration.outputs.files_exists == 'true' + if: steps.check_integration.outcome == 'success' working-directory: apps/${{ env.APP_NAME }} - run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_INTEGRATION_CONFIG }} + run: composer run test:integration + + - name: Print logs + if: always() + run: | + cat data/nextcloud.log + + - name: Skipped + # Fail the action when neither unit nor integration tests ran + if: steps.check_phpunit.outcome == 'failure' && steps.check_integration.outcome == 'failure' + run: | + echo 'Neither PHPUnit nor PHPUnit integration tests are specified in composer.json scripts' + exit 1 summary: permissions: contents: none runs-on: ubuntu-latest - needs: phpunit-sqlite + needs: [changes, phpunit-sqlite] if: always() @@ -117,4 +167,4 @@ jobs: steps: - name: Summary status - run: if ${{ needs.phpunit-sqlite.result != 'success' }}; then exit 1; fi + run: if ${{ needs.changes.outputs.src != 'false' && needs.phpunit-sqlite.result != 'success' }}; then exit 1; fi diff --git a/.github/workflows/pr-feedback.yml b/.github/workflows/pr-feedback.yml index 559e183..0e7359d 100644 --- a/.github/workflows/pr-feedback.yml +++ b/.github/workflows/pr-feedback.yml @@ -30,5 +30,5 @@ jobs: Thank you for contributing to Nextcloud and we hope to hear from you soon! days-before-feedback: 14 start-date: "2023-07-10" - exempt-authors: "${{ steps.scrape.outputs.users }},nextcloud-command,nextcloud-android-bot" + exempt-authors: "${{ steps.scrape.outputs.users }},nextcloud-command,nextcloud-android-bot,skjnldsv,datenangebot" exempt-bots: true diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml index ff271c1..ff526a2 100644 --- a/.github/workflows/psalm.yml +++ b/.github/workflows/psalm.yml @@ -1,27 +1,34 @@ +# 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 + name: Static analysis -on: - pull_request: - push: - branches: - - master - - main - - stable* +on: pull_request + +concurrency: + group: psalm-${{ github.head_ref || github.run_id }} + cancel-in-progress: true jobs: static-analysis: runs-on: ubuntu-latest - name: Nextcloud ${{ matrix.ocp-version }} + name: static-psalm-analysis steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - name: Set up php - uses: shivammathur/setup-php@v2 + - name: Set up php8.2 + uses: shivammathur/setup-php@6d7209f44a25a59e904b1ee9f3b0c33ab2cd888d # v2 with: - php-version: 7.4 + php-version: 8.2 + extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite coverage: none + ini-file: development + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Install dependencies run: composer i diff --git a/.github/workflows/update-nextcloud-ocp.yml b/.github/workflows/update-nextcloud-ocp.yml index 9859036..b71c21a 100644 --- a/.github/workflows/update-nextcloud-ocp.yml +++ b/.github/workflows/update-nextcloud-ocp.yml @@ -8,7 +8,7 @@ name: Update nextcloud/ocp on: workflow_dispatch: schedule: - - cron: "5 4 * * 0" + - cron: "5 2 * * 0" jobs: update-nextcloud-ocp: @@ -17,42 +17,93 @@ jobs: strategy: fail-fast: false matrix: - branches: ["master", "stable27", "stable26", "stable25", "stable24"] + branches: ['main', 'master', 'stable28', 'stable27', 'stable26'] name: update-nextcloud-ocp-${{ matrix.branches }} steps: - - uses: actions/checkout@v3 + - id: checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 with: ref: ${{ matrix.branches }} submodules: true + continue-on-error: true - - name: Set up php7.4 - uses: shivammathur/setup-php@v2 + - name: Set up php8.2 + if: steps.checkout.outcome == 'success' + uses: shivammathur/setup-php@6d7209f44a25a59e904b1ee9f3b0c33ab2cd888d # v2 with: - php-version: 7.4 - extensions: ctype,curl,dom,fileinfo,gd,intl,json,mbstring,openssl,pdo_sqlite,posix,sqlite,xml,zip + php-version: 8.2 + # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation + extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite coverage: none + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Read codeowners + if: steps.checkout.outcome == 'success' + id: codeowners + run: | + grep '/appinfo/info.xml' .github/CODEOWNERS | cut -f 2- -d ' ' | xargs | awk '{ print "codeowners="$0 }' >> $GITHUB_OUTPUT + continue-on-error: true - name: Composer install + if: steps.checkout.outcome == 'success' run: composer install - name: Composer update nextcloud/ocp + id: update_branch + if: ${{ steps.checkout.outcome == 'success' && matrix.branches != 'main' }} run: composer require --dev nextcloud/ocp:dev-${{ matrix.branches }} - continue-on-error: true - - name: Reset checkout dirs + - name: Raise on issue on failure + uses: dacbd/create-issue-action@ba4d1c45cccf9c483f2720cefb40e437f0ee6f7d # v1.2.1 + if: ${{ steps.checkout.outcome == 'success' && failure() && steps.update_branch.conclusion == 'failure' }} + with: + token: ${{ secrets.GITHUB_TOKEN }} + title: Failed to update nextcloud/ocp package on branch ${{ matrix.branches }} + body: Please check the output of the GitHub action and manually resolve the issues
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
${{ steps.codeowners.outputs.codeowners }} + + - name: Composer update nextcloud/ocp + id: update_main + if: ${{ steps.checkout.outcome == 'success' && matrix.branches == 'main' }} + run: composer require --dev nextcloud/ocp:dev-master + + - name: Raise on issue on failure + uses: dacbd/create-issue-action@ba4d1c45cccf9c483f2720cefb40e437f0ee6f7d # v1.2.1 + if: ${{ steps.checkout.outcome == 'success' && failure() && steps.update_main.conclusion == 'failure' }} + with: + token: ${{ secrets.GITHUB_TOKEN }} + title: Failed to update nextcloud/ocp package on branch ${{ matrix.branches }} + body: Please check the output of the GitHub action and manually resolve the issues
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
${{ steps.codeowners.outputs.codeowners }} + + - name: Reset checkout 3rdparty + if: steps.checkout.outcome == 'success' run: | git clean -f 3rdparty + git checkout 3rdparty + continue-on-error: true + + - name: Reset checkout vendor + if: steps.checkout.outcome == 'success' + run: | git clean -f vendor - git checkout 3rdparty vendor + git checkout vendor + continue-on-error: true + + - name: Reset checkout vendor-bin + if: steps.checkout.outcome == 'success' + run: | + git clean -f vendor-bin + git checkout vendor-bin continue-on-error: true - name: Create Pull Request - uses: peter-evans/create-pull-request@v3 + if: steps.checkout.outcome == 'success' + uses: peter-evans/create-pull-request@b1ddad2c994a25fbc81a28b3ec0e368bb2021c50 # v3 with: token: ${{ secrets.COMMAND_BOT_PAT }} - commit-message: Update psalm baseline + commit-message: "chore(dev-deps): Bump nextcloud/ocp package" committer: GitHub author: nextcloud-command signoff: true diff --git a/composer.json b/composer.json index 7912981..7ce8ebd 100644 --- a/composer.json +++ b/composer.json @@ -28,6 +28,7 @@ "psalm": "psalm --threads=1", "psalm:update-baseline": "psalm --threads=1 --update-baseline --set-baseline=tests/psalm-baseline.xml", "psalm:clear": "psalm --clear-cache && psalm --clear-global-cache", - "psalm:fix": "psalm --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType" + "psalm:fix": "psalm --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType", + "test:unit": "echo 'Only testing installation of the app'" } }