Skip to content

Commit c66a28c

Browse files
committed
Issue #21: Implemented Codecov
Signed-off-by: alexmerlin <alex.merlin.1985@gmail.com>
1 parent 0200033 commit c66a28c

5 files changed

Lines changed: 75 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: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ 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)
@@ -20,9 +20,9 @@ This package can clean up your code, by getting rid of all the factories you wri
2020
## Installation
2121

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

2727
After installing, add the `ConfigProvider` class to your configuration aggregate.
2828

@@ -43,28 +43,30 @@ return [
4343

4444
The next step is to annotate the service constructor or setters with the service names to inject
4545
```php
46-
use Dot\AnnotatedServices\Annotation\Service;
4746
use Dot\AnnotatedServices\Annotation\Inject;
4847

4948
/**
50-
* Service constructor
51-
* @param Dependency1 $dep1
52-
* ...
53-
*
54-
* @Inject({Dependency1::class, Dependency2::class, ...})
49+
* @Inject({
50+
* Dependency1::class,
51+
* Dependency2::class,
52+
* "config"
53+
* })
5554
*/
56-
public function __construct(Dependency1 $dep1, Dependency2 $dep2, ...)
57-
{
58-
$this->dep1 = $dep1;
59-
//...
55+
public function __construct(
56+
protected Dependency1 $dep1,
57+
protected Dependency2 $dep2,
58+
protected array $config
59+
) {
6060
}
6161
```
6262

6363
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.
64+
Valid service names should be provided, as registered in the service manager.
6565

6666
To inject an array value from the service manager, you can use dot notation as below
6767
```php
68+
use Dot\AnnotatedServices\Annotation\Inject;
69+
6870
/**
6971
* @Inject({"config.debug"})
7072
*/
@@ -93,6 +95,7 @@ The `name` field has to be the fully qualified class name.
9395
Every repository should extend `Doctrine\ORM\EntityRepository`.
9496
```php
9597
use Doctrine\ORM\EntityRepository;
98+
use Dot\AnnotatedServices\Annotation\Entity;
9699

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

116118
/*
117119
* @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)