Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement phpstan #39

Merged
merged 9 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ name: CI
jobs:
build:
name: CI
strategy:
matrix:
nextcloudVersion: [ v23.0.0, master ]
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down Expand Up @@ -34,7 +37,14 @@ jobs:
restore-keys: ${{ runner.os }}-composer-

- name: Install PHP Dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
run: |
composer install --no-progress --prefer-dist --optimize-autoloader
git clone --depth 1 https://github.com/nextcloud/server.git -b ${{ matrix.nextcloudVersion }}
cd server && git submodule update --init
./occ maintenance:install --admin-pass=admin

- name: PHP stan
run: make phpstan

- name: PHP code style
run: composer run cs:check || ( echo 'Please run `composer run cs:fix` to format your code' && exit 1 )
Expand All @@ -49,12 +59,10 @@ jobs:
run: npm run stylelint

- name: PHP & Vue Unit Tests
run: |
git clone --depth 1 https://github.com/nextcloud/server.git -b v23.0.0
make test
run: make test

- name: JS Code Coverage Summary Report
if: ${{ github.event_name == 'pull_request' }}
if: ${{ github.event_name == 'pull_request' && matrix.nextcloudVersion == 'master' }}
uses: romeovs/lcov-reporter-action@v0.3.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -63,7 +71,7 @@ jobs:
title: "JS Code Coverage"

- name: Convert PHP cobertura coverage to lcov
if: ${{ github.event_name == 'pull_request' }}
if: ${{ github.event_name == 'pull_request' && matrix.nextcloudVersion == 'master' }}
uses: danielpalme/ReportGenerator-GitHub-Action@5.0.3
with:
reports: './coverage/php/cobertura.xml' # REQUIRED # The coverage reports that should be parsed (separated by semicolon). Globbing is supported.
Expand All @@ -82,7 +90,7 @@ jobs:
toolpath: 'reportgeneratortool' # Default directory for installing the dotnet tool.

- name: PHP Code Coverage Summary Report
if: ${{ github.event_name == 'pull_request' }}
if: ${{ github.event_name == 'pull_request' && matrix.nextcloudVersion == 'master' }}
uses: romeovs/lcov-reporter-action@v0.3.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -91,14 +99,14 @@ jobs:
title: "PHP Code Coverage"

- name: JS coverage check
if: ${{ github.event_name == 'pull_request' }}
if: ${{ github.event_name == 'pull_request' && matrix.nextcloudVersion == 'master' }}
uses: VeryGoodOpenSource/very_good_coverage@v1.2.0
with:
min_coverage: '24'
path: './coverage/jest/lcov.info'

- name: PHP coverage check
if: ${{ github.event_name == 'pull_request' }}
if: ${{ github.event_name == 'pull_request' && matrix.nextcloudVersion == 'master' }}
uses: VeryGoodOpenSource/very_good_coverage@v1.2.0
with:
min_coverage: '36'
Expand Down
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
->notPath('l10n')
->notPath('src')
->notPath('vendor')
->notPath('server')
->in(__DIR__);
return $config;
4 changes: 4 additions & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

define('PHPUNIT_RUN', 1);
use Composer\Autoload\ClassLoader;

include_once __DIR__.'/vendor/autoload.php';
Expand All @@ -8,11 +9,14 @@
} else {
$serverPath = __DIR__ . '/../..';
}
include_once $serverPath.'/3rdparty/autoload.php';
require_once $serverPath. '/lib/base.php';

$classLoader = new ClassLoader();
$classLoader->addPsr4("OCA\\OpenProject\\Service\\", __DIR__ . '/lib/Service', true);
$classLoader->addPsr4("OCP\\", $serverPath . '/lib/public', true);
$classLoader->addPsr4("OC\\", $serverPath . '/lib/private', true);
$classLoader->addPsr4("OCA\\Files\\Event\\", $serverPath . '/apps/files/lib/Event', true);
$classLoader->addPsr4("OCA\\OpenProject\\AppInfo\\", __DIR__ . '/lib/AppInfo', true);
$classLoader->addPsr4("OCA\\OpenProject\\Controller\\", __DIR__ . '/lib/Controller', true);
$classLoader->register();
Expand Down
8 changes: 6 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
"phpunit/phpunit": "^9.5",
"pact-foundation/pact-php": "^7.1",
"friendsofphp/php-cs-fixer": "^3.5",
"nextcloud/coding-standard": "^1.0"
"nextcloud/coding-standard": "^1.0",
"phpstan/phpstan": "^1.4",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/extension-installer": "^1.1"
},
"scripts": {
"cs:fix": "php-cs-fixer fix",
"cs:check": "php-cs-fixer fix --dry-run --diff"
"cs:check": "php-cs-fixer fix --dry-run --diff",
"phpstan": "phpstan analyse"
}
}
Loading