Skip to content

Commit 1d431a6

Browse files
authored
Merge pull request #24 from LibreCodeCoop/feat/reusable-psalm
feat: centralize Psalm static analysis
2 parents 4917497 + ec05ba3 commit 1d431a6

4 files changed

Lines changed: 93 additions & 0 deletions

File tree

‎.github/workflows/psalm.yml‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
2+
# SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
3+
# SPDX-License-Identifier: MIT
4+
5+
name: Static analysis
6+
7+
on:
8+
workflow_call:
9+
10+
permissions:
11+
contents: read
12+
13+
concurrency:
14+
group: psalm-${{ github.head_ref || github.run_id }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
static-analysis:
19+
runs-on: ubuntu-latest
20+
name: static-psalm-analysis
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: Check minimum PHP version in psalm.xml
32+
env:
33+
PHP_MIN: ${{ steps.versions.outputs.php-min }}
34+
run: grep "phpVersion=\"$PHP_MIN" psalm.xml
35+
36+
- name: Set up php${{ steps.versions.outputs.php-available }}
37+
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2
38+
with:
39+
php-version: ${{ steps.versions.outputs.php-available }}
40+
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
41+
coverage: none
42+
ini-file: development
43+
ini-values: disable_functions=
44+
env:
45+
GITHUB_TOKEN: ${{ github.token }}
46+
47+
- name: Remove nextcloud/ocp
48+
run: composer remove nextcloud/ocp --dev --no-scripts
49+
50+
- name: Install composer dependencies
51+
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0
52+
53+
- name: Install supported nextcloud/ocp
54+
env:
55+
OCP_BRANCH: ${{ steps.versions.outputs.branches-max }}
56+
run: >-
57+
composer require --dev
58+
"nextcloud/ocp:dev-$OCP_BRANCH"
59+
--ignore-platform-reqs
60+
--with-dependencies
61+
62+
- name: Run Psalm
63+
run: composer run psalm -- --threads=1 --monochrome --no-progress --output-format=github
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "Psalm static analysis",
3+
"description": "Run Psalm static analysis with the PHP and Nextcloud versions supported by the app.",
4+
"iconName": "octicon codescan-checkmark",
5+
"categories": [
6+
"PHP"
7+
],
8+
"filePatterns": [
9+
"^composer.json$",
10+
"^psalm.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/psalm.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: Static analysis
8+
9+
on: pull_request
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
psalm:
16+
uses: LibreCodeCoop/github-workflows/.github/workflows/psalm.yml@bedd8421ad6c95914f10f0dc631333223d17c515

0 commit comments

Comments
 (0)