Implement GitHub wokflow for CI

This commit is contained in:
Phil Davis 2021-11-03 20:11:18 +05:45
parent a0723e795a
commit eb3774b91b
No known key found for this signature in database
GPG key ID: 23F482AD80551904
3 changed files with 55 additions and 47 deletions

48
.github/workflows/ci.yml vendored Normal file
View file

@ -0,0 +1,48 @@
name: continuous-integration
on:
push:
branches:
- master
- release/*
pull_request:
jobs:
code-analysis:
name: Code Analysis (PHP ${{ matrix.php-versions }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
steps:
- name: 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: ${{ matrix.php-versions }}
extensions: mbstring, dom, fileinfo, mysql, redis, opcache
coverage: ${{ matrix.coverage }}
tools: composer
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Code Analysis (PHP CS-Fixer)
run: php vendor/bin/php-cs-fixer fix --dry-run --diff
- name: Code Analysis (PHPStan)
run: composer phpstan

View file

@ -1,45 +0,0 @@
language: php
dist: trusty
php:
- 7.1
- 7.2
- 7.3
- 7.4
env:
global:
- RUN_PHPSTAN="FALSE"
matrix:
- PREFER_LOWEST=""
- PREFER_LOWEST="--prefer-lowest"
install:
- if [ $RUN_PHPSTAN == "TRUE" ]; then composer require --dev phpstan/phpstan:^0.12; fi
matrix:
include:
- name: 'PHPStan'
php: 7.4
env:
- RUN_PHPSTAN="TRUE"
fast_finish: true
services:
- mysql
sudo: false
before_script:
# - mysql -e 'create database sabredav'
- rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
# - composer self-update
- composer update $PREFER_LOWEST
script:
- if [ $RUN_PHPSTAN == "FALSE" ]; then find Core -name "*.php" | xargs -n1 php -l; fi
- if [ $RUN_PHPSTAN == "FALSE" ]; then php vendor/bin/php-cs-fixer fix --dry-run --diff; fi
- if [ $RUN_PHPSTAN == "TRUE" ]; then php vendor/bin/phpstan.phar analyse Core html; fi
cache:
directories:
- $HOME/.composer/cache

View file

@ -19,7 +19,8 @@
"symfony/yaml" : "^3.4"
},
"require-dev" : {
"friendsofphp/php-cs-fixer": "2.18.0"
"friendsofphp/php-cs-fixer": "2.18.0",
"phpstan/phpstan": "^0.12"
},
"replace" : {
"jeromeschneider/baikal" : "self.version"
@ -38,8 +39,12 @@
"cs-fixer": [
"php-cs-fixer fix"
],
"phpstan": [
"phpstan analyse Core html"
],
"test": [
"composer cs-fixer"
"composer cs-fixer",
"composer phpstan"
]
}
}