Skip to content

Commit

Permalink
polished CI
Browse files Browse the repository at this point in the history
  • Loading branch information
petrparolek committed Jan 27, 2021
1 parent 504d3b4 commit b848027
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 21 deletions.
89 changes: 68 additions & 21 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
run: "${{ env.composer-install }}"

- name: "Coding Standard"
run: "vendor/bin/codesniffer src tests"
run: "make cs"

static-analysis:
name: "Static analysis"
Expand Down Expand Up @@ -122,7 +122,7 @@ jobs:
run: "${{ env.composer-install }}"

- name: "PHPStan"
run: "vendor/bin/phpstan analyse -l max -c phpstan.neon src"
run: "make phpstan"

tests:
runs-on: ubuntu-latest
Expand All @@ -141,9 +141,8 @@ jobs:
extensions: "${{ env.extensions }}"
coverage: none

- run: mkdir -p tests/tmp
- run: composer install --no-interaction --prefer-source
- run: vendor/bin/tester tests -s -C
- run: make tests
- if: failure()
uses: actions/upload-artifact@v1
with:
Expand All @@ -161,24 +160,72 @@ jobs:
extensions: "${{ env.extensions }}"
coverage: none

- run: mkdir -p tests/tmp
- run: composer update --no-interaction --prefer-dist --prefer-lowest --prefer-stable
- run: vendor/bin/tester tests -s -C
- run: make tests

tests-code-coverage:
name: "Tests with code coverage"
runs-on: "${{ matrix.operating-system }}"

code_coverage:
name: Code Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v1
with:
php-version: 7.4
extensions: "${{ env.extensions }}"
coverage: none
strategy:
matrix:
php-version: [ "7.4" ]
operating-system: [ "ubuntu-latest" ]
fail-fast: false

if: "github.event_name == 'push'"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: "Setup PHP cache environment"
id: "extcache"
uses: "shivammathur/cache-extensions@v1"
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.extensions }}"
key: "${{ env.cache-version }}"

- name: "Cache PHP extensions"
uses: "actions/cache@v2"
with:
path: "${{ steps.extcache.outputs.dir }}"
key: "${{ steps.extcache.outputs.key }}"
restore-keys: "${{ steps.extcache.outputs.key }}"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.extensions }}"
tools: "composer:${{ env.composer-version }} "

- name: "Setup problem matchers for PHP"
run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"'

- name: "Get Composer cache directory"
id: "composercache"
run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"'

- name: "Cache PHP dependencies"
uses: "actions/cache@v2"
with:
path: "${{ steps.composercache.outputs.dir }}"
key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}"
restore-keys: "${{ runner.os }}-composer-"

- name: "Install dependencies"
run: "${{ env.composer-install }}"

- run: mkdir -p tests/tmp
- run: composer install --no-progress --prefer-dist
- run: wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar
- run: vendor/bin/tester -p phpdbg tests -s -C -d memory_limit=512M --coverage ./coverage.xml --coverage-src ./src
- run: php coveralls.phar --verbose --config tests/.coveralls.yml
- name: "Tests"
run: "make coverage-clover"

- name: "Coveralls.io"
env:
CI_NAME: github
CI: true
COVERALLS_REPO_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: |
wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.1.0/php-coveralls.phar
php php-coveralls.phar --verbose --config tests/.coveralls.yml
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.PHONY: install qa cs csf phpstan tests coverage-clover coverage-html

install:
composer update

qa: phpstan cs

cs:
vendor/bin/codesniffer src tests

csf:
vendor/bin/codefixer src tests

phpstan:
vendor/bin/phpstan analyse -c phpstan.neon src

tests:
vendor/bin/tester tests -s -C

coverage-clover:
vendor/bin/tester -s -p phpdbg --colors 1 -C -d memory_limit=512M --coverage ./coverage.xml --coverage-src ./src tests

coverage-html:
vendor/bin/tester -s -p phpdbg --colors 1 -C -d memory_limit=512M --coverage ./coverage.html --coverage-src ./src tests

0 comments on commit b848027

Please sign in to comment.