From b848027465da78193041fa6b28f98d71a91f25cd Mon Sep 17 00:00:00 2001 From: Petr Parolek Date: Tue, 26 Jan 2021 20:00:43 +0100 Subject: [PATCH] polished CI --- .github/workflows/tests.yml | 89 ++++++++++++++++++++++++++++--------- Makefile | 24 ++++++++++ 2 files changed, 92 insertions(+), 21 deletions(-) create mode 100644 Makefile diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e3d3abc..844df1d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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" @@ -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 @@ -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: @@ -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 \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7030d29 --- /dev/null +++ b/Makefile @@ -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 \ No newline at end of file