Skip to content

Commit

Permalink
feat: add PHPStan and automated tests to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Joedmin committed Oct 24, 2024
1 parent f1be517 commit ba8c2ba
Show file tree
Hide file tree
Showing 7 changed files with 318 additions and 6 deletions.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "monthly"
52 changes: 52 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Automated tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:

tests:
# https://github.com/actions/virtual-environments
runs-on: ubuntu-22.04
defaults:
run:
working-directory: ./Extensions

steps:
- name: Git checkout source code
uses: actions/checkout@v4
with:
path: Extensions

# Composer tests

- name: Check PHP syntax
run: composer run-script php-lint

- name: Check PHTML syntax
run: composer run-script phtml-lint

- name: Use Composer cache
id: composer-cache
uses: actions/cache@v4
with:
path: Extensions/vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Run Composer install
run: composer install --prefer-dist --no-progress
if: steps.composer-cache.outputs.cache-hit != 'true'

- name: Git checkout FreshRSS source code
uses: actions/checkout@v4
with:
repository: FreshRSS/FreshRSS
path: FreshRSS

- name: PHPStan
run: composer run-script phpstan
2 changes: 1 addition & 1 deletion Controllers/readeckButtonController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function jsVarsAction(): void
)
));

$this->view->_layout(false);
$this->view->_layout(null);

Check failure on line 25 in Controllers/readeckButtonController.php

View workflow job for this annotation

GitHub Actions / tests

Call to method _layout() on an unknown class ReadeckButton\View.
$this->view->_path('readeckButton/vars.js');

Check failure on line 26 in Controllers/readeckButtonController.php

View workflow job for this annotation

GitHub Actions / tests

Call to method _path() on an unknown class ReadeckButton\View.

header('Content-Type: application/javascript; charset=utf-8');
Expand Down
55 changes: 55 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"description": "Extension for FreshRSS",
"type": "project",
"require": {
"php": ">=8.1",
"ext-ctype": "*",
"ext-curl": "*",
"ext-dom": "*",
"ext-fileinfo": "*",
"ext-gmp": "*",
"ext-intl": "*",
"ext-json": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
"ext-openssl": "*",
"ext-pcre": "*",
"ext-pdo": "*",
"ext-pdo_sqlite": "*",
"ext-session": "*",
"ext-simplexml": "*",
"ext-xml": "*",
"ext-xmlreader": "*",
"ext-zend-opcache": "*",
"ext-zip": "*",
"ext-zlib": "*"
},
"suggest": {
"ext-iconv": "*",
"ext-pdo_mysql": "*",
"ext-pdo_pgsql": "*"
},
"require-dev": {
"php": ">=8.1",
"ext-phar": "*",
"ext-tokenizer": "*",
"ext-xmlwriter": "*",
"phpstan/phpstan": "^1.11",
"phpstan/phpstan-strict-rules": "^1.6"
},
"scripts": {
"php-lint": "find . -type d -name 'vendor' -prune -o -name '*.php' -print0 | xargs -0 -n1 -P4 php -l 1>/dev/null",
"phtml-lint": "find . -type d -name 'vendor' -prune -o -name '*.phtml' -print0 | xargs -0 -n1 -P4 php -l 1>/dev/null",
"phpstan": "phpstan analyse --memory-limit 512M .",
"test": [
"@php-lint",
"@phtml-lint",
"@phpstan"
]
},
"config": {
"allow-plugins": {
"phpstan/extension-installer": false
}
}
}
153 changes: 153 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@ services:
freshrss:
image: freshrss/freshrss:latest
container_name: freshrss
restart: unless-stopped
logging:
options:
max-size: 10m
volumes:
- ./fresh_rss_data:/var/www/FreshRSS/data
- ./:/var/www/FreshRSS/extensions/freshrss-readeck-button
- ./:/var/www/FreshRSS/extensions/freshrss-readeck-button:ro
ports:
- 8080:80
44 changes: 44 additions & 0 deletions phpstan.dist.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
parameters:
level: 6 # TODO: Increase to 9
fileExtensions:
- php
- phtml
paths:
- ../FreshRSS
- .
excludePaths:
analyse:
- ../FreshRSS
- vendor/
- fresh_rss_data/
analyseAndScan:
- .github/
- .vscode/
- .git/
- node_modules/
checkMissingOverrideMethodAttribute: true
reportMaybesInPropertyPhpDocTypes: false
treatPhpDocTypesAsCertain: false
strictRules:
allRules: false
booleansInConditions: true
closureUsesThis: true
disallowedConstructs: false
disallowedLooseComparison: false
matchingInheritedMethodNames: true
noVariableVariables: true
numericOperandsInArithmeticOperators: true
overwriteVariablesWithLoop: true
requireParentConstructorCall: true
strictCalls: true
switchConditionsMatchingType: true
uselessCast: true
exceptions:
check:
missingCheckedExceptionInThrows: false # TODO pass
tooWideThrowType: true
implicitThrows: false
checkedExceptionClasses:
- 'Minz_Exception'
includes:
- vendor/phpstan/phpstan-strict-rules/rules.neon

0 comments on commit ba8c2ba

Please sign in to comment.