Skip to content

Commit

Permalink
Merge pull request #1105 from nextcloud/feat/use-psalm
Browse files Browse the repository at this point in the history
feat: Add psalm workflow and adjust code
  • Loading branch information
susnux authored Feb 27, 2024
2 parents 6a4b368 + 2e48366 commit c9afec5
Show file tree
Hide file tree
Showing 10 changed files with 1,077 additions and 2,683 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# 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:
changes:
runs-on: ubuntu-latest-low

outputs:
src: ${{ steps.changes.outputs.src}}

steps:
- uses: dorny/paths-filter@ebc4d7e9ebcb0b1eb21480bb8f43113e996ac77a # v3.0.1
id: changes
continue-on-error: true
with:
filters: |
src:
- '.github/workflows/**'
- 'appinfo/**'
- 'lib/**'
- 'templates/**'
- 'tests/**'
- 'vendor/**'
- 'vendor-bin/**'
- '.php-cs-fixer.dist.php'
- 'composer.json'
- 'composer.lock'
psalm-static-analysis:
runs-on: ubuntu-latest

needs: [changes]
if: needs.changes.outputs.src != 'false'

name: psalm-static-analysis
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Get php version
id: versions
uses: icewind1991/nextcloud-version-matrix@7d433286e92318f51ed0537b6c77374759e12f46 # v1.3.0

- name: Set up php${{ steps.versions.outputs.php-available }}
uses: shivammathur/setup-php@6d7209f44a25a59e904b1ee9f3b0c33ab2cd888d # v2
with:
php-version: ${{ steps.versions.outputs.php-available }}
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: ${{ secrets.GITHUB_TOKEN }}

- name: Install dependencies
run: composer i

- name: Run coding standards check
run: composer run psalm

static-analysis:
permissions:
contents: none
runs-on: ubuntu-latest-low
needs: [changes, psalm-static-analysis]

if: always()

name: static-psalm-analysis

steps:
- name: Summary status
run: if ${{ needs.changes.outputs.src != 'false' && needs.psalm-static-analysis.result != 'success' }}; then exit 1; fi
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
"require-dev": {
"phpunit/phpunit": "^9.5",
"nextcloud/coding-standard": "^1.0.0",
"vimeo/psalm": "^5.18",
"psalm/phar": "^5.22",
"nextcloud/ocp": "dev-master"
},
"scripts": {
"lint": "find . -name \\*.php -not -path './vendor/*' -not -path './build/*' -print0 | xargs -0 -n1 php -l",
"cs:check": "php-cs-fixer fix --dry-run --diff",
"cs:fix": "php-cs-fixer fix",
"psalm": "psalm.phar --threads=1",
"psalm:update-baseline": "psalm.phar --threads=1 --update-baseline",
"test:unit": "vendor/bin/phpunit --color --fail-on-warning -c tests/phpunit.xml"
},
"autoload-dev": {
Expand Down
Loading

0 comments on commit c9afec5

Please sign in to comment.