Skip to content

Commit

Permalink
Use GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
olvlvl committed Dec 9, 2020
1 parent 053aa52 commit fb6f17a
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 21 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/coding-standards.yml
@@ -0,0 +1,21 @@
name: Coding Standards

on:
push:

jobs:
phpstan:
name: phpstan
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: "7.2"
ini-values: memory_limit=-1
tools: phpcs, cs2pr
- name: Run PHP Code Sniffer
run: phpcs -q --report=checkstyle | cs2pr
37 changes: 37 additions & 0 deletions .github/workflows/phpstan.yml
@@ -0,0 +1,37 @@
name: analyze

on:
push:

jobs:
phpstan:
name: phpstan
runs-on: ubuntu-20.04
strategy:
matrix:
php-version:
- "7.2"
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: "${{ matrix.php-version }}"
ini-values: memory_limit=-1
tools: composer:v2
- name: Cache dependencies
uses: actions/cache@v2
with:
path: |
~/.composer/cache
vendor
key: "php-${{ matrix.php-version }}"
restore-keys: "php-${{ matrix.php-version }}"

- name: Install dependencies
run: composer install --no-interaction --no-progress

- name: Analyze
run: vendor/bin/phpstan analyse
56 changes: 56 additions & 0 deletions .github/workflows/phpunit.yml
@@ -0,0 +1,56 @@
name: test

on:
push:

jobs:
phpunit:
name: phpunit
runs-on: ubuntu-20.04
strategy:
matrix:
dependencies:
- lowest
- highest
php-version:
- "7.2"
- "7.4"
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
coverage: xdebug
php-version: "${{ matrix.php-version }}"
ini-values: memory_limit=-1
tools: composer:v2
- name: Cache dependencies
uses: actions/cache@v2
with:
path: |
~/.composer/cache
vendor
key: "php-${{ matrix.php-version }}"
restore-keys: "php-${{ matrix.php-version }}"

- name: Install dependencies, lowest
if: ${{ matrix.dependencies == 'lowest' }}
run: composer update --prefer-lowest --no-interaction --no-progress

- name: Install dependencies, highest
if: ${{ matrix.dependencies == 'highest' }}
run: composer update --no-interaction --no-progress

- name: Run PHPUnit
run: |
mkdir -p build/logs
vendor/bin/phpunit --coverage-clover build/logs/clover.xml
- name: Upload code coverage
if: ${{ matrix.php-version == '7.2' }}
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
composer global require php-coveralls/php-coveralls
php-coveralls --coverage_clover=build/logs/clover.xml -v
24 changes: 3 additions & 21 deletions Makefile
Expand Up @@ -2,9 +2,6 @@

PACKAGE_NAME = icanboogie/message-bus
PACKAGE_VERSION = 0.8
PHPUNIT_VERSION = phpunit-8.5.phar
PHPUNIT_FILENAME = build/$(PHPUNIT_VERSION)
PHPUNIT = php $(PHPUNIT_FILENAME)
PHPCS_FILENAME = build/phpcs

# do not edit the following lines
Expand All @@ -18,35 +15,20 @@ vendor:
update:
@COMPOSER_ROOT_VERSION=$(PACKAGE_VERSION) composer update

autoload: vendor
@composer dump-autoload

test-dependencies: vendor $(PHPUNIT_FILENAME)

$(PHPUNIT_FILENAME):
mkdir -p build
wget https://phar.phpunit.de/$(PHPUNIT_VERSION) -O $(PHPUNIT_FILENAME) -q

test: test-dependencies
test: vendor
@$(PHPUNIT)

test-coverage: test-dependencies
test-coverage: vendor
@mkdir -p build/coverage
@$(PHPUNIT) --coverage-html build/coverage

test-coveralls: test-dependencies
@mkdir -p build/logs
COMPOSER_ROOT_VERSION=$(PACKAGE_VERSION) composer require satooshi/php-coveralls
@$(PHPUNIT) --coverage-clover build/logs/clover.xml
php vendor/bin/php-coveralls -v

$(PHPCS_FILENAME):
curl -L -o $@ https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
chmod +x $@

lint: vendor $(PHPCS_FILENAME)
$(PHPCS_FILENAME)
./vendor/bin/phpstan analyse
vendor/bin/phpstan analyse

doc: vendor
@mkdir -p build/docs
Expand Down
1 change: 1 addition & 0 deletions composer.json
Expand Up @@ -27,6 +27,7 @@
},
"require-dev": {
"phpstan/phpstan": "^0.12.55",
"phpunit/phpunit": "^8.5",
"psr/container": "^1.0",
"symfony/config": "^4.0|^5.1",
"symfony/dependency-injection": "^4.0|^5.1",
Expand Down

0 comments on commit fb6f17a

Please sign in to comment.