Настройка gh-actions для работы с codecov.io

This commit is contained in:
Anthony Axenov 2021-12-02 14:34:21 +08:00
parent 267431ec28
commit 96137d20b2
6 changed files with 59 additions and 55 deletions

49
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,49 @@
# https://github.com/shivammathur/setup-php/blob/master/README.md
name: CI
on:
push:
branches: [ master, dev ]
pull_request:
branches: [ master, dev ]
jobs:
Tests:
runs-on: ubuntu-latest
strategy:
matrix:
php-version:
- 8.0
- 8.1
steps:
- uses: actions/checkout@v2
- name: Cache Composer dependencies
uses: actions/cache@v2
with:
path: ~/.composer/cache
key: php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }}
restore-keys: php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-
- name: Setup PHP v ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: json, curl, tokenizer, mbstring, xdebug
coverage: xdebug
tools: composer, phpunit
- name: Install dependencies with composer
run: composer install --no-ansi --no-interaction --no-progress
- name: Run tests with phpunit/phpunit
run: vendor/bin/phpunit --coverage-clover=coverage.xml --configuration=phpunit.xml
- name: Send code coverage report to Codecov.io
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: bash <(curl -s https://codecov.io/bash) || true

View File

@ -1,25 +0,0 @@
name: Dev build
on:
push:
branches: [ dev ]
pull_request:
branches: [ dev ]
jobs:
Tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Validate composer.json and composer.lock
uses: php-actions/composer@40-env
with:
version: 2
php_version: 8.0
only_args: --prefer-dist --no-progress
- name: Run phpunit tests
uses: php-actions/phpunit@v9
with:
configuration: ./phpunit.xml

View File

@ -1,25 +0,0 @@
name: Master build
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
Tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Validate composer.json and composer.lock
uses: php-actions/composer@40-env
with:
version: 2
php_version: 7.4
only_args: --prefer-dist --no-progress
- name: Run phpunit tests
uses: php-actions/phpunit@v8
with:
configuration: ./phpunit.xml

1
.gitignore vendored
View File

@ -5,3 +5,4 @@
/config.php /config.php
*cache* *cache*
/test.php /test.php
/.coverage-report

View File

@ -10,9 +10,10 @@
[![Master build](https://github.com/anthonyaxenov/atol-online/actions/workflows/master.yml/badge.svg)](https://github.com/anthonyaxenov/atol-online/actions/workflows/master.yml) [![Master build](https://github.com/anthonyaxenov/atol-online/actions/workflows/master.yml/badge.svg)](https://github.com/anthonyaxenov/atol-online/actions/workflows/master.yml)
[![Dev build](https://github.com/anthonyaxenov/atol-online/actions/workflows/dev.yml/badge.svg)](https://github.com/anthonyaxenov/atol-online/actions/workflows/dev.yml) [![Dev build](https://github.com/anthonyaxenov/atol-online/actions/workflows/dev.yml/badge.svg)](https://github.com/anthonyaxenov/atol-online/actions/workflows/dev.yml)
[![Latest Stable Version](http://poser.pugx.org/axenov/atol-online/v)](https://packagist.org/packages/axenov/atol-online) [![Latest Stable Version](http://poser.pugx.org/axenov/atol-online/v)](https://packagist.org/packages/axenov/atol-online)
[![Latest Unstable Version](http://poser.pugx.org/axenov/atol-online/v/unstable)](https://packagist.org/packages/axenov/atol-online) [![codecov](https://codecov.io/gh/anthonyaxenov/atol-online/branch/master/graph/badge.svg?token=WR2IV7FTF0)](https://codecov.io/gh/anthonyaxenov/atol-online)
[![Total Downloads](http://poser.pugx.org/axenov/atol-online/downloads)](https://packagist.org/packages/axenov/atol-online)
[![License](http://poser.pugx.org/axenov/atol-online/license)](https://packagist.org/packages/axenov/atol-online) [![License](http://poser.pugx.org/axenov/atol-online/license)](https://packagist.org/packages/axenov/atol-online)
<!--[![Latest Unstable Version](http://poser.pugx.org/axenov/atol-online/v/unstable)](https://packagist.org/packages/axenov/atol-online)-->
<!--[![Total Downloads](http://poser.pugx.org/axenov/atol-online/downloads)](https://packagist.org/packages/axenov/atol-online)-->
Библиотека для фискализации чеков по 54-ФЗ через [облачную ККТ АТОЛ](https://online.atol.ru/). Библиотека для фискализации чеков по 54-ФЗ через [облачную ККТ АТОЛ](https://online.atol.ru/).
@ -63,12 +64,15 @@
Файлы тестов находятся в директории `/tests` корня репозитория. Файлы тестов находятся в директории `/tests` корня репозитория.
Для запуска тестов необходимо перейти в корень вашего проекта и выполнить команду: Для запуска тестов необходимо перейти в корень репозитория и выполнить одну из команд:
```bash ```bash
composer test composer test # обычное тестирование
composer test-cov # тестирование с покрытием
``` ```
После тестирования с покрытием создаётся отчёт в директории `.coverage-report` в корне репозитория.
## Использование библиотеки ## Использование библиотеки
Весь исходный код находится в директории [`/src`](/src). Весь исходный код находится в директории [`/src`](/src).

View File

@ -73,6 +73,6 @@
}, },
"scripts": { "scripts": {
"test": "vendor/bin/phpunit --colors=always", "test": "vendor/bin/phpunit --colors=always",
"test-cov": "vendor/bin/phpunit --coverage-html coverage" "test-cov": "php -dxdebug.mode=coverage vendor/bin/phpunit --coverage-html .coverage-report"
} }
} }