From 65609c77259b96b587b24c5a1fb4fcea4b143cc0 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 16 Jan 2023 16:49:01 +0100 Subject: [PATCH] chore(CI): Update main php testing versions and workflow templates Signed-off-by: Joas Schilling --- .github/workflows/appstore-build-publish.yml | 59 +++++++++++------- .../workflows/dependabot-approve-merge.yml | 10 ++- .github/workflows/fixup.yml | 17 +++++- .../workflows/lint-eslint-when-unrelated.yml | 2 + .github/workflows/lint-eslint.yml | 11 +++- .github/workflows/lint-info-xml.yml | 2 +- .github/workflows/lint-php-cs.yml | 4 +- .github/workflows/lint-php.yml | 4 +- .github/workflows/psalm-matrix.yml | 61 +++++++++++++++++++ .github/workflows/static-analysis.yml | 42 ------------- 10 files changed, 138 insertions(+), 74 deletions(-) create mode 100644 .github/workflows/psalm-matrix.yml delete mode 100644 .github/workflows/static-analysis.yml diff --git a/.github/workflows/appstore-build-publish.yml b/.github/workflows/appstore-build-publish.yml index fab9969400..90453eb0c3 100644 --- a/.github/workflows/appstore-build-publish.yml +++ b/.github/workflows/appstore-build-publish.yml @@ -10,19 +10,21 @@ on: types: [published] env: - PHP_VERSION: 7.4 + PHP_VERSION: 8.1 jobs: build_and_publish: - permissions: - contents: write # for release creation (svenstaro/upload-release-action) - runs-on: ubuntu-latest # Only allowed to be run on nextcloud-releases repositories if: ${{ github.repository_owner == 'nextcloud-releases' }} steps: + - name: Check actor permission + uses: skjnldsv/check-actor-permission@e591dbfe838300c007028e1219ca82cc26e8d7c5 # v2.1 + with: + require: write + - name: Set app env run: | # Split and keep last @@ -30,31 +32,31 @@ jobs: echo "APP_VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 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" - name: Read package.json node and npm engines version - uses: skjnldsv/read-package-engines-version-actions@v2.0 + uses: skjnldsv/read-package-engines-version-actions@1bdcee71fa343c46b18dc6aceffb4cd1e35209c6 # v1.2 id: versions # Continue if no package.json continue-on-error: true with: path: ${{ env.APP_NAME }} - fallbackNode: "^12" - fallbackNpm: "^6" + fallbackNode: "^16" + fallbackNpm: "^7" - name: Set up node ${{ steps.versions.outputs.nodeVersion }} # Skip if no package.json if: ${{ steps.versions.outputs.nodeVersion }} - uses: actions/setup-node@v3 + uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3 with: node-version: ${{ steps.versions.outputs.nodeVersion }} @@ -64,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@1a18b2267f80291a81ca1d33e7c851fe09e7dfc4 # 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@v2 + uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2 with: files: "${{ env.APP_NAME }}/composer.json" @@ -86,19 +90,32 @@ jobs: if: ${{ steps.versions.outputs.nodeVersion }} run: | cd ${{ env.APP_NAME }} - npm install --deps + npm ci npm run build + - 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: | - wget https://github.com/ChristophWurst/krankerl/releases/download/v0.13.0/krankerl_0.13.0_amd64.deb - sudo dpkg -i krankerl_0.13.0_amd64.deb + cd ${{ env.APP_NAME }} + krankerl package - - name: Package ${{ env.APP_NAME }} ${{ env.APP_VERSION }} - # Try krankerl, fallback to makefile + - 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 @@ -109,7 +126,7 @@ jobs: unzip latest-$NCVERSION.zip - name: Checkout server master fallback - uses: actions/checkout@v3 + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 if: ${{ steps.server-checkout.outcome != 'success' }} with: repository: nextcloud/server @@ -131,7 +148,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@133984371c30d34e38222a64855679a414cb7575 # v2 id: attach_to_release with: repo_token: ${{ secrets.GITHUB_TOKEN }} @@ -141,7 +158,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 78faa9a04e..9951547f76 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@v3 + - 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/fixup.yml b/.github/workflows/fixup.yml index 6092cc3a5f..b9e3920789 100644 --- a/.github/workflows/fixup.yml +++ b/.github/workflows/fixup.yml @@ -5,16 +5,29 @@ name: Pull request checks -on: pull_request +on: + pull_request: + types: [opened, ready_for_review, reopened] + +permissions: + contents: read + +concurrency: + group: fixup-${{ github.head_ref || github.run_id }} + cancel-in-progress: true jobs: commit-message-check: + if: github.event.pull_request.draft == false + + permissions: + pull-requests: write name: Block fixup and squash commits runs-on: ubuntu-latest steps: - name: Run check - uses: xt0rted/block-autosquash-commits-action@v2 + uses: xt0rted/block-autosquash-commits-action@79880c36b4811fe549cfffe20233df88876024e7 # v2 with: repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/lint-eslint-when-unrelated.yml b/.github/workflows/lint-eslint-when-unrelated.yml index fda76fa08c..63710eb665 100644 --- a/.github/workflows/lint-eslint-when-unrelated.yml +++ b/.github/workflows/lint-eslint-when-unrelated.yml @@ -17,6 +17,8 @@ on: - 'package.json' - 'package-lock.json' - 'tsconfig.json' + - '.eslintrc.*' + - '.eslintignore' - '**.js' - '**.ts' - '**.vue' diff --git a/.github/workflows/lint-eslint.yml b/.github/workflows/lint-eslint.yml index 80ec2445e2..628e8fefa9 100644 --- a/.github/workflows/lint-eslint.yml +++ b/.github/workflows/lint-eslint.yml @@ -2,6 +2,9 @@ # # 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 @@ -14,6 +17,8 @@ on: - 'package.json' - 'package-lock.json' - 'tsconfig.json' + - '.eslintrc.*' + - '.eslintignore' - '**.js' - '**.ts' - '**.vue' @@ -33,14 +38,14 @@ jobs: steps: - name: Checkout - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3 + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 - name: Read package.json node and npm engines version uses: skjnldsv/read-package-engines-version-actions@1bdcee71fa343c46b18dc6aceffb4cd1e35209c6 # v1.2 id: versions with: - fallbackNode: '^12' - fallbackNpm: '^6' + fallbackNode: '^16' + fallbackNpm: '^7' - name: Set up node ${{ steps.versions.outputs.nodeVersion }} uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3 diff --git a/.github/workflows/lint-info-xml.yml b/.github/workflows/lint-info-xml.yml index c5f57dd5e2..8f024cfcb9 100644 --- a/.github/workflows/lint-info-xml.yml +++ b/.github/workflows/lint-info-xml.yml @@ -27,7 +27,7 @@ jobs: name: info.xml lint steps: - name: Checkout - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3 + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 - name: Download schema run: wget https://raw.githubusercontent.com/nextcloud/appstore/master/nextcloudappstore/api/v1/release/info.xsd diff --git a/.github/workflows/lint-php-cs.yml b/.github/workflows/lint-php-cs.yml index b03d84d782..df490fb23b 100644 --- a/.github/workflows/lint-php-cs.yml +++ b/.github/workflows/lint-php-cs.yml @@ -22,13 +22,15 @@ jobs: steps: - name: Checkout - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3 + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 - name: Set up php uses: shivammathur/setup-php@1a18b2267f80291a81ca1d33e7c851fe09e7dfc4 # v2 with: php-version: 8.1 coverage: none + 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 fc0e268f97..45bf08292a 100644 --- a/.github/workflows/lint-php.yml +++ b/.github/workflows/lint-php.yml @@ -31,13 +31,15 @@ jobs: steps: - name: Checkout - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3 + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 - name: Set up php ${{ matrix.php-versions }} uses: shivammathur/setup-php@1a18b2267f80291a81ca1d33e7c851fe09e7dfc4 # v2 with: php-version: ${{ matrix.php-versions }} coverage: none + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Lint run: composer run lint diff --git a/.github/workflows/psalm-matrix.yml b/.github/workflows/psalm-matrix.yml new file mode 100644 index 0000000000..1bb33f3bb9 --- /dev/null +++ b/.github/workflows/psalm-matrix.yml @@ -0,0 +1,61 @@ +# 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* + +concurrency: + group: psalm-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + static-analysis: + runs-on: ubuntu-latest + strategy: + # do not stop on another job's failure + fail-fast: false + matrix: + ocp-version: [ 'dev-master', 'dev-stable25' ] + + name: Nextcloud ${{ matrix.ocp-version }} + steps: + - name: Checkout + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 + + - name: Set up php + uses: shivammathur/setup-php@1a18b2267f80291a81ca1d33e7c851fe09e7dfc4 # v2 + with: + php-version: 8.0 + coverage: none + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Install dependencies + run: composer i + + - name: Install dependencies + run: composer require --dev nextcloud/ocp:${{ matrix.ocp-version }} --ignore-platform-reqs + + - name: Run coding standards check + run: composer run psalm + + summary: + runs-on: ubuntu-latest + needs: static-analysis + + if: always() + + name: static-psalm-analysis-summary + + steps: + - name: Summary status + run: if ${{ needs.static-analysis.result != 'success' }}; then exit 1; fi diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml deleted file mode 100644 index 4b3b13c59d..0000000000 --- a/.github/workflows/static-analysis.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Static analysis -on: pull_request - -permissions: - contents: read - -jobs: - static-psalm-analysis: - runs-on: ubuntu-latest - strategy: - matrix: - ocp-version: [ 'dev-master', 'dev-stable25' ] - name: Nextcloud ${{ matrix.ocp-version }} - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up php - uses: shivammathur/setup-php@v2 - with: - php-version: 7.4 - coverage: none - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Install dependencies - run: composer i - - name: Install OCP package - run: composer require --dev nextcloud/ocp:${{ matrix.ocp-version }} --ignore-platform-reqs - - name: Run coding standards check - run: composer run psalm - - summary: - runs-on: ubuntu-latest - needs: - - static-psalm-analysis - - if: always() - - name: static-analysis-summary - - steps: - - name: Static analysis status - run: if ${{ needs.static-psalm-analysis.result != 'success' && needs.static-psalm-analysis.result != 'skipped' }}; then exit 1; fi