From 010ae8c1cedfd085c1727a661aed76c680793424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6?= Date: Thu, 1 Jun 2023 18:00:26 +0200 Subject: [PATCH 1/3] chore: update workflows from templates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ --- .github/workflows/appstore-build-publish.yml | 59 +++++++++----- .../workflows/dependabot-approve-merge.yml | 10 ++- .github/workflows/lint-eslint.yml | 78 +++++++++++++++---- .github/workflows/lint-info-xml.yml | 20 ++--- .github/workflows/lint-php-cs.yml | 15 ++-- .github/workflows/lint-php.yml | 21 +++-- .github/workflows/lint-stylelint.yml | 28 ++++--- .github/workflows/node.yml | 71 +++++++++++++---- .github/workflows/test-action.yml | 2 +- .github/workflows/update-nextcloud-ocp.yml | 73 ++++++++++++++--- 10 files changed, 277 insertions(+), 100 deletions(-) diff --git a/.github/workflows/appstore-build-publish.yml b/.github/workflows/appstore-build-publish.yml index ba532ca..1ff8375 100644 --- a/.github/workflows/appstore-build-publish.yml +++ b/.github/workflows/appstore-build-publish.yml @@ -10,7 +10,7 @@ on: types: [published] env: - PHP_VERSION: 7.4 + PHP_VERSION: 8.2 jobs: build_and_publish: @@ -21,9 +21,9 @@ jobs: steps: - name: Check actor permission - uses: skjnldsv/check-actor-permission@v2 + uses: skjnldsv/check-actor-permission@e591dbfe838300c007028e1219ca82cc26e8d7c5 # v2.1 with: - require: admin + require: write - name: Set app env run: | @@ -32,31 +32,31 @@ jobs: echo "APP_VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 with: path: ${{ env.APP_NAME }} - name: Get appinfo data id: appinfo - uses: skjnldsv/xpath-action@master + uses: skjnldsv/xpath-action@7e6a7c379d0e9abc8acaef43df403ab4fc4f770c # master with: filename: ${{ env.APP_NAME }}/appinfo/info.xml - expression: '//info//dependencies//nextcloud/@min-version' + expression: "//info//dependencies//nextcloud/@min-version" - name: Read package.json node and npm engines version - uses: skjnldsv/read-package-engines-version-actions@v1.1 + uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2 id: versions # Continue if no package.json continue-on-error: true with: path: ${{ env.APP_NAME }} - fallbackNode: '^12' - fallbackNpm: '^6' + fallbackNode: '^20' + fallbackNpm: '^9' - name: Set up node ${{ steps.versions.outputs.nodeVersion }} # Skip if no package.json if: ${{ steps.versions.outputs.nodeVersion }} - uses: actions/setup-node@v2 + uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v3 with: node-version: ${{ steps.versions.outputs.nodeVersion }} @@ -66,14 +66,16 @@ jobs: run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}" - name: Set up php ${{ env.PHP_VERSION }} - uses: shivammathur/setup-php@v2 + uses: shivammathur/setup-php@81cd5ae0920b34eef300e1775313071038a53429 # v2 with: php-version: ${{ env.PHP_VERSION }} coverage: none + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Check composer.json id: check_composer - uses: andstor/file-existence-action@v1 + uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2 with: files: "${{ env.APP_NAME }}/composer.json" @@ -86,16 +88,36 @@ jobs: - name: Build ${{ env.APP_NAME }} # Skip if no package.json if: ${{ steps.versions.outputs.nodeVersion }} + env: + CYPRESS_INSTALL_BINARY: 0 run: | cd ${{ env.APP_NAME }} npm ci npm run build - - name: Package ${{ env.APP_NAME }} ${{ env.APP_VERSION }} - # Try krankerl, fallback to makefile + - name: Check Krankerl config + id: krankerl + uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2 + with: + files: ${{ env.APP_NAME }}/krankerl.toml + + - name: Install Krankerl + if: steps.krankerl.outputs.files_exists == 'true' + run: | + wget https://github.com/ChristophWurst/krankerl/releases/download/v0.14.0/krankerl_0.14.0_amd64.deb + sudo dpkg -i krankerl_0.14.0_amd64.deb + + - name: Package ${{ env.APP_NAME }} ${{ env.APP_VERSION }} with krankerl + if: steps.krankerl.outputs.files_exists == 'true' + run: | + cd ${{ env.APP_NAME }} + krankerl package + + - name: Package ${{ env.APP_NAME }} ${{ env.APP_VERSION }} with makefile + if: steps.krankerl.outputs.files_exists != 'true' run: | cd ${{ env.APP_NAME }} - krankerl package || make appstore + make appstore - name: Checkout server ${{ fromJSON(steps.appinfo.outputs.result).nextcloud.min-version }} continue-on-error: true @@ -106,9 +128,10 @@ jobs: unzip latest-$NCVERSION.zip - name: Checkout server master fallback - uses: actions/checkout@v2 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 if: ${{ steps.server-checkout.outcome != 'success' }} with: + submodules: true repository: nextcloud/server path: nextcloud @@ -128,7 +151,7 @@ jobs: tar -zcvf ${{ env.APP_NAME }}.tar.gz ${{ env.APP_NAME }} - name: Attach tarball to github release - uses: svenstaro/upload-release-action@v2 + uses: svenstaro/upload-release-action@1beeb572c19a9242f4361f4cee78f8e0d9aec5df # v2 id: attach_to_release with: repo_token: ${{ secrets.GITHUB_TOKEN }} @@ -138,7 +161,7 @@ jobs: overwrite: true - name: Upload app to Nextcloud appstore - uses: nextcloud-releases/nextcloud-appstore-push-action@v1 + uses: nextcloud-releases/nextcloud-appstore-push-action@a011fe619bcf6e77ddebc96f9908e1af4071b9c1 # v1 with: app_name: ${{ env.APP_NAME }} appstore_token: ${{ secrets.APPSTORE_TOKEN }} diff --git a/.github/workflows/dependabot-approve-merge.yml b/.github/workflows/dependabot-approve-merge.yml index 0d6e343..9951547 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 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-eslint.yml b/.github/workflows/lint-eslint.yml index 5f48fb5..99b624d 100644 --- a/.github/workflows/lint-eslint.yml +++ b/.github/workflows/lint-eslint.yml @@ -2,36 +2,68 @@ # # https://github.com/nextcloud/.github # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization +# +# Use lint-eslint together with lint-eslint-when-unrelated to make eslint a required check for GitHub actions +# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks + +name: Lint eslint + +on: pull_request -name: Lint +permissions: + contents: read -on: - pull_request: - push: - branches: - - main - - master - - stable* +concurrency: + group: lint-eslint-${{ github.head_ref || github.run_id }} + cancel-in-progress: true jobs: + 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/**' + - 'src/**' + - 'appinfo/info.xml' + - 'package.json' + - 'package-lock.json' + - 'tsconfig.json' + - '.eslintrc.*' + - '.eslintignore' + - '**.js' + - '**.ts' + - '**.vue' + lint: runs-on: ubuntu-latest - name: eslint + needs: changes + if: needs.changes.outputs.src != 'false' + + name: NPM lint steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Read package.json node and npm engines version - uses: skjnldsv/read-package-engines-version-actions@v1.2 + uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2 id: versions with: - fallbackNode: '^12' - fallbackNpm: '^6' + fallbackNode: '^20' + fallbackNpm: '^9' - name: Set up node ${{ steps.versions.outputs.nodeVersion }} - uses: actions/setup-node@v3 + uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v3 with: node-version: ${{ steps.versions.outputs.nodeVersion }} @@ -39,7 +71,25 @@ jobs: run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}" - name: Install dependencies + env: + CYPRESS_INSTALL_BINARY: 0 + PUPPETEER_SKIP_DOWNLOAD: true run: npm ci - name: Lint run: npm run lint + + summary: + permissions: + contents: none + runs-on: ubuntu-latest + needs: [changes, lint] + + if: always() + + # This is the summary, we just avoid to rename it so that branch protection rules still match + name: eslint + + steps: + - name: Summary status + run: if ${{ needs.changes.outputs.src != 'false' && needs.lint.result != 'success' }}; then exit 1; fi diff --git a/.github/workflows/lint-info-xml.yml b/.github/workflows/lint-info-xml.yml index cea2a2b..bf6f178 100644 --- a/.github/workflows/lint-info-xml.yml +++ b/.github/workflows/lint-info-xml.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 info.xml -on: - pull_request: - push: - branches: - - 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: @@ -19,13 +21,13 @@ jobs: name: info.xml lint steps: - name: Checkout - uses: actions/checkout@master + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Download schema run: wget https://raw.githubusercontent.com/nextcloud/appstore/master/nextcloudappstore/api/v1/release/info.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: ./info.xsd diff --git a/.github/workflows/lint-php-cs.yml b/.github/workflows/lint-php-cs.yml index 2814102..c23fc7c 100644 --- a/.github/workflows/lint-php-cs.yml +++ b/.github/workflows/lint-php-cs.yml @@ -3,14 +3,14 @@ # 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 permissions: contents: read -concurrency: +concurrency: group: lint-php-cs-${{ github.head_ref || github.run_id }} cancel-in-progress: true @@ -22,13 +22,16 @@ jobs: 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@81cd5ae0920b34eef300e1775313071038a53429 # v2 with: - php-version: "7.4" + php-version: 8.2 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 62476c9..92769c4 100644 --- a/.github/workflows/lint-php.yml +++ b/.github/workflows/lint-php.yml @@ -3,20 +3,14 @@ # 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: - - main - - master - - stable* +on: pull_request permissions: contents: read -concurrency: +concurrency: group: lint-php-${{ github.head_ref || github.run_id }} cancel-in-progress: true @@ -25,19 +19,22 @@ jobs: 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@v3 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Set up php ${{ matrix.php-versions }} - uses: shivammathur/setup-php@v2 + uses: shivammathur/setup-php@81cd5ae0920b34eef300e1775313071038a53429 # v2 with: php-version: ${{ matrix.php-versions }} coverage: none + ini-file: development + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Lint run: composer run lint diff --git a/.github/workflows/lint-stylelint.yml b/.github/workflows/lint-stylelint.yml index 64edcfb..684bb61 100644 --- a/.github/workflows/lint-stylelint.yml +++ b/.github/workflows/lint-stylelint.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 stylelint -on: - pull_request: - push: - branches: - - master - - stable* +on: pull_request + +permissions: + contents: read + +concurrency: + group: lint-stylelint-${{ github.head_ref || github.run_id }} + cancel-in-progress: true jobs: lint: @@ -20,17 +22,17 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Read package.json node and npm engines version - uses: skjnldsv/read-package-engines-version-actions@v1.1 + uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2 id: versions with: - fallbackNode: '^12' - fallbackNpm: '^6' + fallbackNode: '^20' + fallbackNpm: '^9' - name: Set up node ${{ steps.versions.outputs.nodeVersion }} - uses: actions/setup-node@v2 + uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v3 with: node-version: ${{ steps.versions.outputs.nodeVersion }} @@ -38,6 +40,8 @@ jobs: run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}" - name: Install dependencies + env: + CYPRESS_INSTALL_BINARY: 0 run: npm ci - name: Lint diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index 9150d1f..75c32b4 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -5,35 +5,59 @@ name: Node -on: - pull_request: - push: - branches: - - main - - master - - stable* +on: pull_request permissions: contents: read +concurrency: + group: node-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + jobs: + 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/**' + - 'src/**' + - 'appinfo/info.xml' + - 'package.json' + - 'package-lock.json' + - 'tsconfig.json' + - '**.js' + - '**.ts' + - '**.vue' + build: runs-on: ubuntu-latest - name: node + needs: changes + if: needs.changes.outputs.src != 'false' + + name: NPM build steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Read package.json node and npm engines version - uses: skjnldsv/read-package-engines-version-actions@v1.2 + uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2 id: versions with: - fallbackNode: '^12' - fallbackNpm: '^6' + fallbackNode: '^20' + fallbackNpm: '^9' - name: Set up node ${{ steps.versions.outputs.nodeVersion }} - uses: actions/setup-node@v3 + uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v3 with: node-version: ${{ steps.versions.outputs.nodeVersion }} @@ -41,16 +65,35 @@ jobs: run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}" - name: Install dependencies & build + env: + CYPRESS_INSTALL_BINARY: 0 + PUPPETEER_SKIP_DOWNLOAD: true run: | npm ci npm run build --if-present - name: Check webpack build changes run: | - bash -c "[[ ! \"`git status --porcelain `\" ]] || exit 1" + bash -c "[[ ! \"`git status --porcelain `\" ]] || (echo 'Please recompile and commit the assets, see the section \"Show changes on failure\" for details' && exit 1)" - name: Show changes on failure if: failure() run: | git status git --no-pager diff + exit 1 # make it red to grab attention + + summary: + permissions: + contents: none + runs-on: ubuntu-latest + needs: [changes, build] + + if: always() + + # This is the summary, we just avoid to rename it so that branch protection rules still match + name: node + + steps: + - name: Summary status + run: if ${{ needs.changes.outputs.src != 'false' && needs.build.result != 'success' }}; then exit 1; fi diff --git a/.github/workflows/test-action.yml b/.github/workflows/test-action.yml index 35bb459..29a57fa 100644 --- a/.github/workflows/test-action.yml +++ b/.github/workflows/test-action.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - php-versions: ['8.0'] + php-versions: ['8.1'] server-versions: ['master'] name: performance-${{ matrix.php-versions }} diff --git a/.github/workflows/update-nextcloud-ocp.yml b/.github/workflows/update-nextcloud-ocp.yml index 312764e..9f67593 100644 --- a/.github/workflows/update-nextcloud-ocp.yml +++ b/.github/workflows/update-nextcloud-ocp.yml @@ -17,42 +17,93 @@ jobs: strategy: fail-fast: false matrix: - branches: ["master", "stable28", "stable27", "stable26"] + 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@81cd5ae0920b34eef300e1775313071038a53429 # 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@153407881ec5c347639a548ade7d8ad1d6740e38 # 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 From 769c1a09bc955e5f8932307fc99c71a433c86605 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 27 Nov 2023 09:07:54 +0100 Subject: [PATCH 2/3] Add psalm CI Signed-off-by: Joas Schilling --- .github/workflows/psalm.yml | 36 +++++++++++++++++ composer.json | 2 +- psalm.xml | 56 ++++++++++++++++++++++++++ tests/psalm-baseline.xml | 32 +++++++++++++++ tests/stubs/oc_core_command_base.php | 60 ++++++++++++++++++++++++++++ 5 files changed, 185 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/psalm.yml create mode 100644 psalm.xml create mode 100644 tests/psalm-baseline.xml create mode 100644 tests/stubs/oc_core_command_base.php diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml new file mode 100644 index 0000000..302873b --- /dev/null +++ b/.github/workflows/psalm.yml @@ -0,0 +1,36 @@ +# 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 + +concurrency: + group: psalm-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + static-analysis: + runs-on: ubuntu-latest + + name: Nextcloud + steps: + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Set up php8.2 + uses: shivammathur/setup-php@81cd5ae0920b34eef300e1775313071038a53429 # v2 + with: + php-version: 8.2 + coverage: none + ini-file: development + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Install dependencies + run: composer i + + - name: Run coding standards check + run: composer run psalm diff --git a/composer.json b/composer.json index 6331d42..1b4beab 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,6 @@ { "autoload-dev": { "psr-4": { - "OCP\\": "vendor/nextcloud/ocp/OCP", "OCA\\Profiler\\": "lib/" } }, @@ -26,6 +25,7 @@ "cs:check": "php-cs-fixer fix --dry-run --diff", "cs:fix": "php-cs-fixer fix", "psalm": "psalm --threads=1", + "psalm:dev": "psalm --no-cache --threads=$(nproc)", "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" diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 0000000..e1738d0 --- /dev/null +++ b/psalm.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/psalm-baseline.xml b/tests/psalm-baseline.xml new file mode 100644 index 0000000..247fda1 --- /dev/null +++ b/tests/psalm-baseline.xml @@ -0,0 +1,32 @@ + + + + + $dbCollector + $dbCollector + + + + + $collector + + + getQueries + + + + + Request + + + + + Request + + + + + Request + + + diff --git a/tests/stubs/oc_core_command_base.php b/tests/stubs/oc_core_command_base.php new file mode 100644 index 0000000..3fc248f --- /dev/null +++ b/tests/stubs/oc_core_command_base.php @@ -0,0 +1,60 @@ + Date: Mon, 27 Nov 2023 09:10:03 +0100 Subject: [PATCH 3/3] Add automerge of OCP Signed-off-by: Joas Schilling --- .editorconfig | 4 ++ .../update-nextcloud-ocp-approve-merge.yml | 49 +++++++++++++++++++ .reuse/dep5 | 2 +- 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/update-nextcloud-ocp-approve-merge.yml diff --git a/.editorconfig b/.editorconfig index 198996b..f0a0a66 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,3 +7,7 @@ indent_size = 4 end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true + +[*.yml] +indent_style = space +indent_size = 2 diff --git a/.github/workflows/update-nextcloud-ocp-approve-merge.yml b/.github/workflows/update-nextcloud-ocp-approve-merge.yml new file mode 100644 index 0000000..58d5182 --- /dev/null +++ b/.github/workflows/update-nextcloud-ocp-approve-merge.yml @@ -0,0 +1,49 @@ +# 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: Auto approve nextcloud/ocp + +on: + pull_request_target: + branches: + - main + - master + - stable* + +permissions: + contents: read + +concurrency: + group: update-nextcloud-ocp-approve-merge-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + auto-approve-merge: + if: github.actor == 'nextcloud-command' + runs-on: ubuntu-latest + permissions: + # for hmarr/auto-approve-action to approve PRs + pull-requests: write + # for alexwilson/enable-github-automerge-action to approve PRs + contents: write + + steps: + - uses: mdecoleman/pr-branch-name@bab4c71506bcd299fb350af63bb8e53f2940a599 # v2.0.0 + id: branchname + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + # GitHub actions bot approve + - uses: hmarr/auto-approve-action@b40d6c9ed2fa10c9a2749eca7eb004418a705501 # v2 + if: startsWith(steps.branchname.outputs.branch, 'automated/noid/') && endsWith(steps.branchname.outputs.branch, 'update-nextcloud-ocp') + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + + # Enable GitHub auto merge + - name: Auto merge + uses: alexwilson/enable-github-automerge-action@f3e77fa17ba5a11771671361c01f382322c6db03 # main + if: startsWith(steps.branchname.outputs.branch, 'automated/noid/') && endsWith(steps.branchname.outputs.branch, 'update-nextcloud-ocp') + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.reuse/dep5 b/.reuse/dep5 index c520f75..d303964 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -3,6 +3,6 @@ Upstream-Name: profiler Upstream-Contact: Carl Schwan Source: https://github.com/nextcloud/profiler -Files: .github/* .editorconfig babel.config.js .php-cs-fixer.dist.php package-lock.json package.json composer.json composer.lock README.md img/app-dark.svg img/app.svg webpack.js stylelint.config.js .eslintrc.js .gitignore .jshintrc .l10nignore action/.gitignore action/package.json action/package-lock.json action/dist/index.js +Files: .github/* .editorconfig babel.config.js .php-cs-fixer.dist.php package-lock.json package.json composer.json composer.lock README.md img/app-dark.svg img/app.svg webpack.js stylelint.config.js .eslintrc.js .gitignore .jshintrc .l10nignore action/.gitignore action/package.json action/package-lock.json action/dist/index.js tests/* psalm.xml Copyright: none License: CC0-1.0