-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Code Analysis and Code Style validation (#5)
- Loading branch information
Showing
22 changed files
with
308 additions
and
76 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/.* export-ignore | ||
/Makefile export-ignore | ||
/*.dist export-ignore | ||
/*.dist.* export-ignore | ||
/tests export-ignore | ||
|
||
# Test with: | ||
# git archive --format=tar HEAD | tar t |
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,47 @@ | ||
# yamllint disable rule:line-length | ||
# yamllint disable rule:braces | ||
|
||
name: Code Analysis | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
name: Static code analysis with PHP ${{ matrix.php-version }} | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
php-version: | ||
- "7.4" | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-version }} | ||
coverage: none | ||
|
||
- name: Cache Composer packages | ||
id: composer-cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: vendor | ||
key: composer-${{ matrix.php-version }}-${{ hashFiles('composer.*') }} | ||
restore-keys: | | ||
composer-${{ matrix.php-version }}- | ||
composer- | ||
- name: Install dependencies | ||
run: | | ||
composer install --prefer-dist --no-progress | ||
- name: Run Psalm | ||
run: | | ||
php vendor/bin/psalm --output-format=github --long-progress --php-version=${{ matrix.php-version }} |
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,65 @@ | ||
# yamllint disable rule:line-length | ||
# yamllint disable rule:braces | ||
|
||
name: Code Style | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
name: Code style with PHP ${{ matrix.php-version }} | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
php-version: | ||
- "7.4" | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-version }} | ||
coverage: none | ||
|
||
- name: Cache Composer packages | ||
id: composer-cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: vendor | ||
key: composer-${{ matrix.php-version }}-${{ hashFiles('composer.*') }} | ||
restore-keys: | | ||
composer-${{ matrix.php-version }}- | ||
composer- | ||
- name: Install dependencies | ||
run: | | ||
composer install --prefer-dist --no-progress | ||
- name: Validate composer.json | ||
run: | | ||
composer validate --strict | ||
- name: Normalize composer.json | ||
run: | | ||
composer normalize --dry-run --diff | ||
- name: Restore PHP-CS-Fixer cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: build/cache/.php_cs.cache | ||
key: php-cs-fixer-${{ matrix.php-version }}-${{ hashFiles('composer.*') }} | ||
restore-keys: | | ||
php-cs-fixer-${{ matrix.php-version }}- | ||
php-cs-fixer- | ||
- name: Run PHP-CS-Fixer | ||
run: | | ||
mkdir -p build/cache/ | ||
vendor/bin/php-cs-fixer fix --diff --dry-run --verbose --cache-file=build/cache/.php_cs.cache |
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 |
---|---|---|
|
@@ -7,7 +7,6 @@ on: | |
push: | ||
branches: | ||
- main | ||
- v*.* | ||
|
||
jobs: | ||
tests: | ||
|
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,72 @@ | ||
<?php declare(strict_types=1); | ||
/** | ||
* The Sliding Window Counter, a short-lived time series library. | ||
* Copyright 2023 Automattic, Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
|
||
$header = <<<'EOF' | ||
The Sliding Window Counter, a short-lived time series library. | ||
Copyright 2023 Automattic, Inc. | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
as published by the Free Software Foundation; either version 2 | ||
of the License, or (at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License along | ||
with this program; if not, write to the Free Software Foundation, Inc., | ||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
EOF; | ||
|
||
$config = new PhpCsFixer\Config(); | ||
$config | ||
->setRiskyAllowed(true) | ||
->setRules([ | ||
'header_comment' => [ | ||
'comment_type' => 'PHPDoc', | ||
'header' => $header, | ||
'separate' => 'bottom', | ||
'location' => 'after_declare_strict', | ||
], | ||
'@PER-CS1.0' => true, | ||
'array_indentation' => true, | ||
'native_function_invocation' => [ | ||
'include' => ['@internal'], | ||
'scope' => 'namespaced', | ||
], | ||
'global_namespace_import' => [ | ||
'import_classes' => true, | ||
'import_constants' => true, | ||
'import_functions' => true, | ||
], | ||
'declare_equal_normalize' => ['space' => 'none'], | ||
'blank_line_after_opening_tag' => false, | ||
'linebreak_after_opening_tag' => false, | ||
]) | ||
->setFinder( | ||
PhpCsFixer\Finder::create() | ||
->in(__DIR__) | ||
->append([__FILE__]) | ||
) | ||
; | ||
|
||
return $config; |
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,16 @@ | ||
<?xml version="1.0"?> | ||
<psalm | ||
errorLevel="2" | ||
resolveFromConfigFile="true" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="https://getpsalm.org/schema/config" | ||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" | ||
> | ||
<projectFiles> | ||
<directory name="src" /> | ||
<file name="example.php" /> | ||
<ignoreFiles> | ||
<directory name="vendor" /> | ||
</ignoreFiles> | ||
</projectFiles> | ||
</psalm> |
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
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
Oops, something went wrong.