Skip to content

Commit 4917497

Browse files
authored
Merge pull request #23 from LibreCodeCoop/feat/reusable-php-lints
feat: centralize PHP lint workflows
2 parents d4260ca + 45e8f8f commit 4917497

8 files changed

Lines changed: 184 additions & 0 deletions

File tree

‎.github/workflows/lint-php-cs.yml‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
2+
# SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
3+
# SPDX-License-Identifier: MIT
4+
5+
name: Lint php-cs
6+
7+
on:
8+
workflow_call:
9+
10+
permissions:
11+
contents: read
12+
13+
concurrency:
14+
group: lint-php-cs-${{ github.head_ref || github.run_id }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
lint:
19+
runs-on: ubuntu-latest
20+
name: php-cs
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
24+
with:
25+
persist-credentials: false
26+
27+
- name: Get php version
28+
id: versions
29+
uses: nextcloud-libraries/nextcloud-version-matrix@cd0211ffcef1065e2020cd579e4843b8746e7a58 # v1.3.3
30+
31+
- name: Set up php${{ steps.versions.outputs.php-min }}
32+
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2
33+
with:
34+
php-version: ${{ steps.versions.outputs.php-min }}
35+
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
36+
coverage: none
37+
ini-file: development
38+
env:
39+
GITHUB_TOKEN: ${{ github.token }}
40+
41+
- name: Remove nextcloud/ocp
42+
run: composer remove nextcloud/ocp --dev --no-scripts
43+
44+
- name: Install composer dependencies
45+
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0
46+
47+
- name: Lint
48+
run: composer run cs:check

‎.github/workflows/lint-php.yml‎

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
2+
# SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
3+
# SPDX-License-Identifier: MIT
4+
5+
name: Lint php
6+
7+
on:
8+
workflow_call:
9+
10+
permissions:
11+
contents: read
12+
13+
concurrency:
14+
group: lint-php-${{ github.head_ref || github.run_id }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
matrix:
19+
runs-on: ubuntu-latest
20+
outputs:
21+
php-min: ${{ steps.versions.outputs.php-min }}
22+
php-max: ${{ steps.versions.outputs.php-max }}
23+
steps:
24+
- name: Checkout app
25+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
26+
with:
27+
persist-credentials: false
28+
29+
- name: Get version matrix
30+
id: versions
31+
uses: nextcloud-libraries/nextcloud-version-matrix@cd0211ffcef1065e2020cd579e4843b8746e7a58 # v1.3.3
32+
33+
php-lint:
34+
runs-on: ubuntu-latest
35+
needs: matrix
36+
strategy:
37+
matrix:
38+
php-versions:
39+
- '${{ needs.matrix.outputs.php-min }}'
40+
- '${{ needs.matrix.outputs.php-max }}'
41+
42+
name: php-lint
43+
44+
steps:
45+
- name: Checkout
46+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
47+
with:
48+
persist-credentials: false
49+
50+
- name: Set up php ${{ matrix.php-versions }}
51+
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2
52+
with:
53+
php-version: ${{ matrix.php-versions }}
54+
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
55+
coverage: none
56+
ini-file: development
57+
env:
58+
GITHUB_TOKEN: ${{ github.token }}
59+
60+
- name: Lint
61+
run: composer run lint
62+
63+
summary:
64+
permissions:
65+
contents: none
66+
runs-on: ubuntu-latest
67+
needs: php-lint
68+
if: always()
69+
name: php-lint-summary
70+
steps:
71+
- name: Summary status
72+
env:
73+
RESULT: ${{ needs.php-lint.result }}
74+
run: |
75+
if [ "$RESULT" != "success" ] && [ "$RESULT" != "skipped" ]; then
76+
exit 1
77+
fi
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "Lint PHP coding standards",
3+
"description": "Run the project's PHP coding standards check using the minimum supported PHP version.",
4+
"iconName": "octicon check-circle",
5+
"categories": [
6+
"PHP"
7+
],
8+
"filePatterns": [
9+
"^composer.json$"
10+
]
11+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
2+
SPDX-License-Identifier: AGPL-3.0-or-later

‎workflow-templates/lint-php-cs.yml‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
2+
# SPDX-License-Identifier: AGPL-3.0-or-later
3+
4+
# This workflow is published through the LibreCode organization catalog.
5+
# Implementation: LibreCodeCoop/github-workflows
6+
7+
name: Lint php-cs
8+
9+
on: pull_request
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
lint-php-cs:
16+
uses: LibreCodeCoop/github-workflows/.github/workflows/lint-php-cs.yml@bc97b54e3d33d58d6075a0994883acde00f0556c
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "Lint PHP",
3+
"description": "Lint PHP code against the minimum and maximum PHP versions supported by the app.",
4+
"iconName": "octicon code-square",
5+
"categories": [
6+
"PHP"
7+
],
8+
"filePatterns": [
9+
"^composer.json$",
10+
"^appinfo/info.xml$"
11+
]
12+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
2+
SPDX-License-Identifier: AGPL-3.0-or-later

‎workflow-templates/lint-php.yml‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
2+
# SPDX-License-Identifier: AGPL-3.0-or-later
3+
4+
# This workflow is published through the LibreCode organization catalog.
5+
# Implementation: LibreCodeCoop/github-workflows
6+
7+
name: Lint php
8+
9+
on: pull_request
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
lint-php:
16+
uses: LibreCodeCoop/github-workflows/.github/workflows/lint-php.yml@bc97b54e3d33d58d6075a0994883acde00f0556c

0 commit comments

Comments
 (0)