-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PHPStan and other quality checks (#185)
* Add PHPStan and other quality checks Similar to FreshRSS core Contributes to #184 * Bump versions * markdownlint * Draft of GitHub Actions * Wrong branch * Remove wrong tests * Change path approach * Move checkout * cache-dependency-path * fix rm symbolic * Remove irrelevant tests * Fix composer cache path * Fix hashFiles * fix shell cache
- Loading branch information
Showing
70 changed files
with
1,286 additions
and
417 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
*.min.js | ||
.git/ | ||
*.min.js | ||
node_modules/ | ||
symbolic/ | ||
tmp/ | ||
vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
name: Automated tests | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
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@v3 | ||
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: PHP_CodeSniffer | ||
run: composer run-script phpcs | ||
|
||
- name: Git checkout FreshRSS source code | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: FreshRSS/FreshRSS | ||
path: FreshRSS | ||
|
||
- name: PHPStan | ||
run: composer run-script phpstan | ||
|
||
- name: PHPStan Next Level | ||
run: composer run-script phpstan-next | ||
|
||
# NPM tests | ||
|
||
- name: Uses Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
# https://nodejs.org/en/about/releases/ | ||
node-version: '18' | ||
cache: 'npm' | ||
cache-dependency-path: 'Extensions/composer.lock' | ||
|
||
- run: npm ci | ||
|
||
- name: Check JavaScript syntax | ||
run: npm run --silent eslint | ||
|
||
- name: Check Markdown syntax | ||
run: npm run --silent markdownlint | ||
|
||
- name: Check CSS syntax | ||
run: npm run --silent stylelint | ||
|
||
- name: Check Right-to-left CSS | ||
run: npm run --silent rtlcss && git diff --exit-code | ||
|
||
# Shell tests | ||
|
||
- name: Use shell cache | ||
id: shell-cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: Extensions/bin | ||
key: ${{ runner.os }}[email protected] | ||
|
||
- name: Add ./bin/ to $PATH | ||
run: mkdir -p bin/ && echo "${PWD}/bin" >> $GITHUB_PATH | ||
|
||
- name: Install typos | ||
if: steps.shell-cache.outputs.cache-hit != 'true' | ||
run: | | ||
cd bin ; | ||
wget -q 'https://github.com/crate-ci/typos/releases/download/v1.16.21/typos-v1.16.21-x86_64-unknown-linux-musl.tar.gz' && | ||
tar -xvf *.tar.gz './typos' && | ||
chmod +x typos && | ||
rm *.tar.gz ; | ||
cd .. | ||
- name: Check spelling | ||
run: bin/typos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
tmp | ||
/node_modules/ | ||
.vscode/ | ||
bin/ | ||
node_modules/ | ||
symbolic/ | ||
tmp/ | ||
vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.git/ | ||
node_modules/ | ||
symbolic/ | ||
tmp/ | ||
vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.git/ | ||
node_modules/ | ||
symbolic/ | ||
tmp/ | ||
vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.git/ | ||
node_modules/ | ||
symbolic/ | ||
tmp/ | ||
vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[default.extend-identifiers] | ||
ot = "ot" | ||
Ths2 = "Ths2" | ||
|
||
[default.extend-words] | ||
referer = "referer" | ||
|
||
[files] | ||
extend-exclude = [ | ||
".git/", | ||
"*.fr.md", | ||
"*.map", | ||
"*.min.js", | ||
"*.rtl.css", | ||
"*/i18n/de", | ||
"*/i18n/fr", | ||
"bin/", | ||
"node_modules/", | ||
"symbolic/", | ||
"tmp/", | ||
"vendor/", | ||
"xExtension-ReadingTime/README.md" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
{ | ||
"name": "freshrss.org/freshrss-extensions", | ||
"description": "Extensions for FreshRSS", | ||
"type": "project", | ||
"homepage": "https://freshrss.org/", | ||
"license": "AGPL-3.0", | ||
"support": { | ||
"docs": "https://freshrss.github.io/FreshRSS/", | ||
"issues": "https://github.com/FreshRSS/Extensions/issues", | ||
"source": "https://github.com/FreshRSS/Extensions/" | ||
}, | ||
"keywords": [ | ||
"news", | ||
"aggregator", | ||
"RSS", | ||
"Atom", | ||
"WebSub" | ||
], | ||
"require": { | ||
"php": ">=7.4", | ||
"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.0", | ||
"ext-phar": "*", | ||
"ext-tokenizer": "*", | ||
"ext-xmlwriter": "*", | ||
"phpstan/phpstan": "^1.10", | ||
"phpstan/phpstan-strict-rules": "^1.5", | ||
"squizlabs/php_codesniffer": "^3.7" | ||
}, | ||
"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", | ||
"phpcs": "phpcs . -s", | ||
"phpcbf": "phpcbf . -p -s", | ||
"phpstan": "phpstan analyse --memory-limit 512M .", | ||
"phpstan-next": "phpstan analyse --level 9 --memory-limit 512M $(find . -type d -name 'vendor' -prune -o -name '*.php' -o -name '*.phtml' | grep -Fxvf ./tests/phpstan-next.txt | sort | paste -s -)", | ||
"test": [ | ||
"@php-lint", | ||
"@phtml-lint", | ||
"@phpcs", | ||
"@phpstan", | ||
"@phpstan-next" | ||
], | ||
"fix": [ | ||
"@phpcbf" | ||
] | ||
}, | ||
"config": { | ||
"allow-plugins": { | ||
"phpstan/extension-installer": false | ||
} | ||
} | ||
} |
Oops, something went wrong.