diff --git a/.github/workflows/lint-php-cs.yml b/.github/workflows/lint-php-cs.yml new file mode 100644 index 0000000..d7a1522 --- /dev/null +++ b/.github/workflows/lint-php-cs.yml @@ -0,0 +1,48 @@ +# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors +# SPDX-FileCopyrightText: 2026 LibreCode coop and contributors +# SPDX-License-Identifier: MIT + +name: Lint php-cs + +on: + workflow_call: + +permissions: + contents: read + +concurrency: + group: lint-php-cs-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + lint: + runs-on: ubuntu-latest + name: php-cs + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Get php version + id: versions + uses: nextcloud-libraries/nextcloud-version-matrix@cd0211ffcef1065e2020cd579e4843b8746e7a58 # v1.3.3 + + - name: Set up php${{ steps.versions.outputs.php-min }} + uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2 + with: + php-version: ${{ steps.versions.outputs.php-min }} + 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: ${{ github.token }} + + - name: Remove nextcloud/ocp + run: composer remove nextcloud/ocp --dev --no-scripts + + - name: Install composer dependencies + uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0 + + - name: Lint + run: composer run cs:check diff --git a/.github/workflows/lint-php.yml b/.github/workflows/lint-php.yml new file mode 100644 index 0000000..bfbca76 --- /dev/null +++ b/.github/workflows/lint-php.yml @@ -0,0 +1,77 @@ +# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors +# SPDX-FileCopyrightText: 2026 LibreCode coop and contributors +# SPDX-License-Identifier: MIT + +name: Lint php + +on: + workflow_call: + +permissions: + contents: read + +concurrency: + group: lint-php-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + matrix: + runs-on: ubuntu-latest + outputs: + php-min: ${{ steps.versions.outputs.php-min }} + php-max: ${{ steps.versions.outputs.php-max }} + steps: + - name: Checkout app + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Get version matrix + id: versions + uses: nextcloud-libraries/nextcloud-version-matrix@cd0211ffcef1065e2020cd579e4843b8746e7a58 # v1.3.3 + + php-lint: + runs-on: ubuntu-latest + needs: matrix + strategy: + matrix: + php-versions: + - '${{ needs.matrix.outputs.php-min }}' + - '${{ needs.matrix.outputs.php-max }}' + + name: php-lint + + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Set up php ${{ matrix.php-versions }} + uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2 + 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: ${{ github.token }} + + - name: Lint + run: composer run lint + + summary: + permissions: + contents: none + runs-on: ubuntu-latest + needs: php-lint + if: always() + name: php-lint-summary + steps: + - name: Summary status + env: + RESULT: ${{ needs.php-lint.result }} + run: | + if [ "$RESULT" != "success" ] && [ "$RESULT" != "skipped" ]; then + exit 1 + fi diff --git a/workflow-templates/lint-php-cs.properties.json b/workflow-templates/lint-php-cs.properties.json new file mode 100644 index 0000000..e97fd80 --- /dev/null +++ b/workflow-templates/lint-php-cs.properties.json @@ -0,0 +1,11 @@ +{ + "name": "Lint PHP coding standards", + "description": "Run the project's PHP coding standards check using the minimum supported PHP version.", + "iconName": "octicon check-circle", + "categories": [ + "PHP" + ], + "filePatterns": [ + "^composer.json$" + ] +} diff --git a/workflow-templates/lint-php-cs.properties.json.license b/workflow-templates/lint-php-cs.properties.json.license new file mode 100644 index 0000000..1ce4e0c --- /dev/null +++ b/workflow-templates/lint-php-cs.properties.json.license @@ -0,0 +1,2 @@ +SPDX-FileCopyrightText: 2026 LibreCode coop and contributors +SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/workflow-templates/lint-php-cs.yml b/workflow-templates/lint-php-cs.yml new file mode 100644 index 0000000..04b650d --- /dev/null +++ b/workflow-templates/lint-php-cs.yml @@ -0,0 +1,16 @@ +# SPDX-FileCopyrightText: 2026 LibreCode coop and contributors +# SPDX-License-Identifier: AGPL-3.0-or-later + +# This workflow is published through the LibreCode organization catalog. +# Implementation: LibreCodeCoop/github-workflows + +name: Lint php-cs + +on: pull_request + +permissions: + contents: read + +jobs: + lint-php-cs: + uses: LibreCodeCoop/github-workflows/.github/workflows/lint-php-cs.yml@bc97b54e3d33d58d6075a0994883acde00f0556c diff --git a/workflow-templates/lint-php.properties.json b/workflow-templates/lint-php.properties.json new file mode 100644 index 0000000..7da9558 --- /dev/null +++ b/workflow-templates/lint-php.properties.json @@ -0,0 +1,12 @@ +{ + "name": "Lint PHP", + "description": "Lint PHP code against the minimum and maximum PHP versions supported by the app.", + "iconName": "octicon code-square", + "categories": [ + "PHP" + ], + "filePatterns": [ + "^composer.json$", + "^appinfo/info.xml$" + ] +} diff --git a/workflow-templates/lint-php.properties.json.license b/workflow-templates/lint-php.properties.json.license new file mode 100644 index 0000000..1ce4e0c --- /dev/null +++ b/workflow-templates/lint-php.properties.json.license @@ -0,0 +1,2 @@ +SPDX-FileCopyrightText: 2026 LibreCode coop and contributors +SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/workflow-templates/lint-php.yml b/workflow-templates/lint-php.yml new file mode 100644 index 0000000..a54876f --- /dev/null +++ b/workflow-templates/lint-php.yml @@ -0,0 +1,16 @@ +# SPDX-FileCopyrightText: 2026 LibreCode coop and contributors +# SPDX-License-Identifier: AGPL-3.0-or-later + +# This workflow is published through the LibreCode organization catalog. +# Implementation: LibreCodeCoop/github-workflows + +name: Lint php + +on: pull_request + +permissions: + contents: read + +jobs: + lint-php: + uses: LibreCodeCoop/github-workflows/.github/workflows/lint-php.yml@bc97b54e3d33d58d6075a0994883acde00f0556c