Skip to content

Commit ad00924

Browse files
authored
Merge pull request #22 from dotkernel/issue-21
Issue #21: Implemented Codecov
2 parents 0200033 + 5a73847 commit ad00924

5 files changed

Lines changed: 76 additions & 20 deletions

File tree

.github/workflows/codecov.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
on:
2+
- push
3+
4+
name: Run Codecov checks
5+
6+
jobs:
7+
code-coverage:
8+
name: Code Coverage
9+
10+
runs-on: ${{ matrix.os }}
11+
12+
strategy:
13+
matrix:
14+
os:
15+
- ubuntu-latest
16+
17+
php:
18+
- "8.1"
19+
- "8.2"
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v3
24+
25+
- name: Install PHP
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: "${{ matrix.php }}"
29+
coverage: pcov
30+
ini-values: assert.exception=1, zend.assertions=1, error_reporting=-1, log_errors_max_len=0, display_errors=On
31+
tools: composer:v2, cs2pr
32+
33+
- name: Determine composer cache directory
34+
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
35+
36+
- name: Cache dependencies installed with composer
37+
uses: actions/cache@v3
38+
with:
39+
path: ${{ env.COMPOSER_CACHE_DIR }}
40+
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
41+
restore-keys: |
42+
php${{ matrix.php }}-composer-
43+
44+
- name: Install dependencies with composer
45+
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
46+
47+
- name: Collect code coverage with PHPUnit
48+
run: vendor/bin/phpunit --colors=always --coverage-clover clover.xml
49+
50+
- name: Send code coverage report to Codecov.io
51+
uses: codecov/codecov-action@v3
52+
with:
53+
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/cs-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
restore-keys: |
4141
php${{ matrix.php }}-composer-
4242
- name: Install dependencies with composer
43-
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
43+
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
4444

4545
- name: Run phpcs checks
4646
run: vendor/bin/phpcs

.github/workflows/static-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
restore-keys: |
4141
php${{ matrix.php }}-composer-
4242
- name: Install dependencies with composer
43-
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
43+
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
4444

4545
- name: Run static analysis
4646
run: vendor/bin/psalm --no-cache --output-format=github --show-info=false --threads=4

README.md

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,25 @@ DotKernel component used to create services through [Laminas Service Manager](ht
55
This package can clean up your code, by getting rid of all the factories you write, sometimes just to inject a dependency or two.
66

77
![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-annotated-services)
8-
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-annotated-services/4.1.0)
8+
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-annotated-services/4.1.3)
99

1010
[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-annotated-services)](https://github.com/dotkernel/dot-annotated-services/issues)
1111
[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-annotated-services)](https://github.com/dotkernel/dot-annotated-services/network)
1212
[![GitHub stars](https://img.shields.io/github/stars/dotkernel/dot-annotated-services)](https://github.com/dotkernel/dot-annotated-services/stargazers)
1313
[![GitHub license](https://img.shields.io/github/license/dotkernel/dot-annotated-services)](https://github.com/dotkernel/dot-annotated-services/blob/4.0/LICENSE.md)
1414

1515
[![Build Static](https://github.com/dotkernel/dot-annotated-services/actions/workflows/static-analysis.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/dot-annotated-services/actions/workflows/static-analysis.yml)
16+
[![codecov](https://codecov.io/gh/dotkernel/dot-annotated-services/graph/badge.svg?token=ZBZDEA3LY8)](https://codecov.io/gh/dotkernel/dot-annotated-services)
1617

1718
[![SymfonyInsight](https://insight.symfony.com/projects/a0d7016e-fc3f-46b8-9b36-571ff060d744/big.svg)](https://insight.symfony.com/projects/a0d7016e-fc3f-46b8-9b36-571ff060d744)
1819

1920

2021
## Installation
2122

2223
Run the following command in your project directory
23-
```bash
24-
$ composer require dotkernel/dot-annotated-services
25-
```
24+
25+
composer require dotkernel/dot-annotated-services
26+
2627

2728
After installing, add the `ConfigProvider` class to your configuration aggregate.
2829

@@ -43,28 +44,30 @@ return [
4344

4445
The next step is to annotate the service constructor or setters with the service names to inject
4546
```php
46-
use Dot\AnnotatedServices\Annotation\Service;
4747
use Dot\AnnotatedServices\Annotation\Inject;
4848

4949
/**
50-
* Service constructor
51-
* @param Dependency1 $dep1
52-
* ...
53-
*
54-
* @Inject({Dependency1::class, Dependency2::class, ...})
50+
* @Inject({
51+
* Dependency1::class,
52+
* Dependency2::class,
53+
* "config"
54+
* })
5555
*/
56-
public function __construct(Dependency1 $dep1, Dependency2 $dep2, ...)
57-
{
58-
$this->dep1 = $dep1;
59-
//...
56+
public function __construct(
57+
protected Dependency1 $dep1,
58+
protected Dependency2 $dep2,
59+
protected array $config
60+
) {
6061
}
6162
```
6263

6364
The annotation `@Inject` is telling the factory to inject the services between curly braces.
64-
Valid service names should be provided, as registerd in the service manager.
65+
Valid service names should be provided, as registered in the service manager.
6566

6667
To inject an array value from the service manager, you can use dot notation as below
6768
```php
69+
use Dot\AnnotatedServices\Annotation\Inject;
70+
6871
/**
6972
* @Inject({"config.debug"})
7073
*/
@@ -93,6 +96,7 @@ The `name` field has to be the fully qualified class name.
9396
Every repository should extend `Doctrine\ORM\EntityRepository`.
9497
```php
9598
use Doctrine\ORM\EntityRepository;
99+
use Dot\AnnotatedServices\Annotation\Entity;
96100

97101
/**
98102
* @Entity(name="App\Entity\Example")
@@ -111,7 +115,6 @@ Using this approach, no service manager configuration is required. It uses the r
111115
In order to tell the abstract factory which services are to be created, you need to annotate the service class with the `@Service` annotation.
112116
```php
113117
use Dot\AnnotatedServices\Annotation\Service;
114-
use Dot\AnnotatedServices\Annotation\Inject;
115118

116119
/*
117120
* @Service

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@
3333
},
3434
"autoload": {
3535
"psr-4": {
36-
"Dot\\AnnotatedServices\\": "src"
36+
"Dot\\AnnotatedServices\\": "src/"
3737
}
3838
},
3939
"autoload-dev": {
4040
"psr-4": {
41-
"DotTest\\AnnotatedServices\\": "test"
41+
"DotTest\\AnnotatedServices\\": "test/"
4242
}
4343
},
4444
"scripts": {

0 commit comments

Comments
 (0)