From f3332b81d75cf9720ce51b247c645653e034b658 Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Fri, 15 Jan 2021 12:59:38 +0100 Subject: [PATCH 1/3] add github action to run checks on push and pr to main --- .github/workflows/build.yml | 44 +++++++++++++++++++++++++++++++++++++ README.md | 9 +++++++- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..0d0dddf --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,44 @@ +name: build + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + php-checks: + name: php checks + runs-on: ubuntu-latest + steps: + - name: Git checkout + uses: actions/checkout@v2 + + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php + with: + php-version: 7.2 + extensions: mbstring + + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache dependencies + uses: actions/cache@v1 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + + - name: Install dependencies + run: composer install --prefer-dist --no-progress + + - name: Run checks + run: composer check diff --git a/README.md b/README.md index 79fcabb..830b594 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# Antilope +# Antilope + +[![build][build-badge]][build-url] ![style][codestyle] ![phpstan][phpstan] __Antilope__ is the name of this __Sharable Network Tracker__. @@ -131,3 +133,8 @@ For now, the only way to install an Antilope app is via Symfony and `composer`. bin/console doctrine:migrations:diff --db-configuration sqlite + +[build-badge]:https://img.shields.io/github/workflow/status/vincent-peugnet/antilope/build/main +[build-url]:https://github.com/vincent-peugnet/antilope/actions?query=branch%3Amain++workflow%3Abuild +[codestyle]: https://img.shields.io/badge/code%20style-PSR12-brightgreen +[phpstan]: https://img.shields.io/badge/phpstan-level%205-green From 0ae58483986fb2b96645c874e1c7d3ff84107cf3 Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Fri, 15 Jan 2021 13:45:56 +0100 Subject: [PATCH 2/3] run phplint on post install before symfony script as a syntax error in a symfony sroce file will make symfony scripts fail --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index a318982..905dbb4 100644 --- a/composer.json +++ b/composer.json @@ -93,6 +93,7 @@ }, "scripts": { "auto-scripts": { + "parallel-lint src": "script", "cache:clear": "symfony-cmd", "assets:install %PUBLIC_DIR%": "symfony-cmd" }, From bef2ec36216d61091fdf51e2ab3abcbe1db3c568 Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Fri, 15 Jan 2021 13:24:50 +0100 Subject: [PATCH 3/3] add flag input vars to composer script and GA problemMatchers --- .github/matchers/phpcs.json | 19 +++++++++++++++++++ .github/matchers/phplint.json | 16 ++++++++++++++++ .github/matchers/phpunit.json | 25 +++++++++++++++++++++++++ .github/workflows/build.yml | 18 ++++++++++++++++-- composer.json | 6 +++--- 5 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 .github/matchers/phpcs.json create mode 100644 .github/matchers/phplint.json create mode 100644 .github/matchers/phpunit.json diff --git a/.github/matchers/phpcs.json b/.github/matchers/phpcs.json new file mode 100644 index 0000000..af784fc --- /dev/null +++ b/.github/matchers/phpcs.json @@ -0,0 +1,19 @@ +{ + "problemMatcher": [ + { + "owner": "phpcs", + "fileLocation": "relative", + "pattern": [ + { + "regexp": "^\"(.+)\",(\\d+),(\\d+),(.+),\"(.+)\",(.+),(\\d+),(\\d+)$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "message": 5, + "code": 6 + } + ] + } + ] +} diff --git a/.github/matchers/phplint.json b/.github/matchers/phplint.json new file mode 100644 index 0000000..0f9b9fe --- /dev/null +++ b/.github/matchers/phplint.json @@ -0,0 +1,16 @@ +{ + "problemMatcher": [ + { + "owner": "phplint", + "fileLocation": "relative", + "pattern": [ + { + "regexp": "^(.+)\\sin\\s(\\./.+\\.php)\\son\\sline\\s(\\d+)$", + "message": 1, + "file": 2, + "line": 3 + } + ] + } + ] +} diff --git a/.github/matchers/phpunit.json b/.github/matchers/phpunit.json new file mode 100644 index 0000000..d405be9 --- /dev/null +++ b/.github/matchers/phpunit.json @@ -0,0 +1,25 @@ +{ + "problemMatcher": [ + { + "owner": "phpunit", + "fileLocation": "absolute", + "pattern": [ + { + "regexp": "^\\d+\\)\\s.*$" + }, + { + "regexp": "^(.*)$", + "message": 1 + }, + { + "regexp": "^\\s*$" + }, + { + "regexp": "^(.*):(\\d+)$", + "file": 1, + "line": 2 + } + ] + } + ] +} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0d0dddf..48a2c7d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,7 +38,21 @@ jobs: ${{ runner.os }}-composer- - name: Install dependencies - run: composer install --prefer-dist --no-progress + run: | + echo "::add-matcher::.github/matchers/phplint.json" + composer install --prefer-dist --no-progress - name: Run checks - run: composer check + run: | + echo "::add-matcher::.github/matchers/phpcs.json" + echo "::add-matcher::.github/matchers/phpunit.json" + + export PHPLINT_FLAGS="--no-progress" + export PHPCS_FLAGS="--report=csv -q" + export PHPSTAN_FLAGS="--no-progress" + + composer check + + echo "::remove-matcher owner=phpunit::" + echo "::remove-matcher owner=phpcs::" + echo "::remove-matcher owner=phplint::" diff --git a/composer.json b/composer.json index 905dbb4..e5418c8 100644 --- a/composer.json +++ b/composer.json @@ -111,12 +111,12 @@ "fix": [ "@phpcbf" ], - "lint": "parallel-lint --exclude app --exclude var --exclude vendor .", - "phpcs": "phpcs --runtime-set ignore_warnings_on_exit 1", + "lint": "parallel-lint $PHPLINT_FLAGS --exclude app --exclude var --exclude vendor .", + "phpcs": "phpcs $PHPCS_FLAGS --runtime-set ignore_warnings_on_exit 1", "phpcbf": "phpcbf", "phpstan": [ "@php bin/console cache:warmup -q", - "phpstan analyse --ansi" + "phpstan analyse $PHPSTAN_FLAGS --ansi" ], "post-install-cmd": [ "@auto-scripts"